diff --git a/index.html b/index.html index 453745b..70fb84a 100644 --- a/index.html +++ b/index.html @@ -161,7 +161,17 @@

-
  • +
  • +
    +

    + + +

    +
  • @@ -232,6 +242,32 @@ + + + + + + + diff --git a/js/methods.js b/js/methods.js index 62ecf40..3783a0e 100644 --- a/js/methods.js +++ b/js/methods.js @@ -516,13 +516,13 @@ function updatePresetList() { content += `
  • ${presetName} - ${valueSummary} + ${valueSummary}
  • `; } diff --git a/js/preset.js b/js/preset.js new file mode 100644 index 0000000..ca4bfa5 --- /dev/null +++ b/js/preset.js @@ -0,0 +1,32 @@ +function preset_export() { + const modalTextArea = document.getElementById('modal-export-preset-textarea'); + const settings = require('electron-settings'); + var presets = settings.get('presets'); + + presets = JSON.stringify(presets); + modalTextArea.innerHTML = btoa(presets); +} + +function preset_import() { + const modalTextArea = document.getElementById('modal-import-preset-textarea'); + const settings = require('electron-settings'); + var currentPresets = settings.get('presets'); + var presetsToBeImported = atob(modalTextArea.value); + + try { + presetsToBeImported = JSON.parse(presetsToBeImported); + } catch (e) { + notification('danger', 'Unable to import presets, malformed data.'); + console.error(e); + return; + } + + var updatedPresets = Object.assign( + {}, + currentPresets, + presetsToBeImported + ); + settings.set('presets', updatedPresets); + updatePresetList(); + modalTextArea.innerText = ''; +}