Skip to content

Commit 56bdfd8

Browse files
committed
store sizes, alt texts, and titles when convert. they will be restored if app restarts.
1 parent b11163d commit 56bdfd8

File tree

3 files changed

+179
-3
lines changed

3 files changed

+179
-3
lines changed

src/index.html

+30-1
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,46 @@ <h5 class="modal-title modal-title-danger">エラー</h5>
119119
<script src="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
120120

121121
<script>
122+
function storeSettings() {
123+
var storage = require('electron-json-storage');
124+
var data = {};
125+
126+
data.photoSize = $("#photoSize")[0].value;
127+
data.photoAlt = $("#photoAlt")[0].value;
128+
data.photoTitle = $("#photoTitle")[0].value;
129+
130+
storage.set('config', data, function (error) {
131+
if (error) throw error;
132+
});
133+
}
134+
135+
function restoreSettings() {
136+
var storage = require('electron-json-storage');
137+
138+
storage.get('config', function (error, data) {
139+
if (error) throw error;
140+
if (Object.keys(data).length === 0) return;
141+
142+
$("#photoSize")[0].value = data.photoSize;
143+
$("#photoAlt")[0].value = data.photoAlt;
144+
$("#photoTitle")[0].value = data.photoTitle;
145+
});
146+
}
147+
122148
function pasteFromClipboard() {
123149
var clipboard = require('electron').clipboard;
124150
$("#photoLink")[0].value = clipboard.readText();
125151
}
126152

127153
function convert() {
154+
storeSettings();
155+
128156
if (!$("#photoLink")[0].value) {
129157
$('#errorModal').modal('show');
130158
return;
131159
}
132160
$('#processingModal').modal('show');
133-
getOgImageUrl()
161+
getOgImageUrl();
134162
}
135163

136164
function getOgImageUrl() {
@@ -210,6 +238,7 @@ <h5 class="modal-title modal-title-danger">エラー</h5>
210238
}
211239

212240
disableZoom();
241+
restoreSettings();
213242
</script>
214243
</body>
215244

src/package-lock.json

+146
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"bootstrap": "^4.1.1",
77
"jquery": "^3.3.1",
8-
"request": "^2.87.0"
8+
"request": "^2.87.0",
9+
"electron-json-storage": "^4.1.0"
910
}
10-
}
11+
}

0 commit comments

Comments
 (0)