Skip to content

Commit 6ca8e5d

Browse files
committed
✨feat: export import
1 parent 47a0f46 commit 6ca8e5d

3 files changed

Lines changed: 11 additions & 26 deletions

File tree

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_extensionName__",
44
"description": "__MSG_extensionDescription__",
5-
"version": "2.3",
5+
"version": "3.0",
66
"default_locale": "en",
77

88
"browser_specific_settings": {

‎src/options.html‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,10 @@ <h2 class="i18n">Pull_Distance</h2>
6666
<span class="radio-label i18n">Long</span>
6767
</label>
6868

69-
<!-- TODO -->
70-
<div class="hide">
71-
<h2 class="i18n">Export / Import</h2>
72-
<div class="item hide">
73-
<label id="exportSetting" class="icon-export button buttons-vertical i18n">Export settings to downloads folder</label><a id="exportSettingLink" download="simple-gesture.json" class="hide"></a><br>
74-
<label class="icon-import button buttons-vertical i18n">Import settings from JSON</label><input type="file" id="importSetting" accept="application/json" class="hide">
75-
</div>
69+
<h2 class="i18n">Export / Import</h2>
70+
<div class="item">
71+
<label id="exportSetting" class="icon-export button buttons-vertical i18n">Export settings to downloads folder</label><a id="exportSettingLink" download="pretty_refresh.json" class="hide"></a><br>
72+
<label for="importSetting" class="icon-import button buttons-vertical i18n">Import settings from JSON</label><input type="file" id="importSetting" accept="application/json" class="hide">
7673
</div>
7774

7875
<!-- Components -->

‎src/options.js‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,12 @@ const saveBindingValues = async () => {
271271
.replace('{bgshape}', getShapeCSS('bg'))
272272
.replace('{fgshape}', getShapeCSS('fg'))
273273
.replace('{shcolor}', PrettyRefresh.ini.shcolor)
274-
await browser.storage.local.set({ 'pretty_refresh': PrettyRefresh.ini });
274+
await saveIni();
275275
PrettyRefresh.loadIni();
276276
};
277+
const saveIni = async () => {
278+
await browser.storage.local.set({ 'pretty_refresh': PrettyRefresh.ini });
279+
};
277280
const saveBindingValuesDelay = () => {
278281
resetTimer('saveBindingValues', saveBindingValues, 3000);
279282
};
@@ -287,15 +290,7 @@ const importSetting = async text => {
287290
try {
288291
const obj = JSON.parse(text);
289292
Object.assign(PrettyRefresh.ini, obj.ini);
290-
exData = obj.exData;
291-
saveIni();
292-
if (obj.customGestureDetails) {
293-
for (const c of obj.customGestureDetails) {
294-
const d = {};
295-
d[c.id] = c.detail;
296-
await browser.storage.local.set(d);
297-
}
298-
}
293+
await saveIni();
299294
location.reload();
300295
} catch (e) {
301296
alert(e.message);
@@ -314,14 +309,7 @@ const importSettingOnChange = e => {
314309
const exportSetting = async () => {
315310
const data = {
316311
ini: PrettyRefresh.ini,
317-
exData: exData,
318-
customGestureDetails: []
319312
};
320-
for (const c of exData.customGestureList) {
321-
const id = `pretty_refresh_${c.id}`;
322-
const detail = await storageValue(id);
323-
data.customGestureDetails.push({ id: id, detail:detail });
324-
}
325313
const href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data));
326314
const link = byId('exportSettingLink');
327315
link.setAttribute('href', href);
@@ -350,6 +338,7 @@ const setupContents = () => {
350338
onChangeColorText({ target: elm });
351339
}
352340
};
341+
353342
const setupEventListeners = () => {
354343
for (const elm of $bidingForms) {
355344
elm.addEventListener('change', saveBindingValues);
@@ -382,7 +371,6 @@ const setupEventListeners = () => {
382371
});
383372
};
384373

385-
386374
// control Back button
387375
const changeState = state => {
388376
if (!state.dlg) return;

0 commit comments

Comments
 (0)