prefs: saved only the changed pref. #14

This commit is contained in:
mic 2024-04-03 21:57:56 +02:00
parent f2e4db183c
commit 8d4f3b564a
2 changed files with 5 additions and 3 deletions

View file

@ -7,7 +7,8 @@
<body>
<div id="miczRelNotes"><a href="mzta-release-notes.html">Release Notes</a></div>
<div id="miczPrefs"><label><input type="checkbox" id="force_msedge" name="force_msedge" class="option-input" /> __MSG_forceMsedgeOptionText__</label><br/>
<input type="checkbox" id="always_link" name="always_link" class="option-input" /> __MSG_AlwaysLinkOptionText__</label></div>
<label><input type="checkbox" id="always_link" name="always_link" class="option-input" /> __MSG_AlwaysLinkOptionText__</label><br/>
<label><input type="text" id="default_sign_name" name="default_sign_name" class="option-input" /> Default signature name</label></div>
<div id="miczDescription">
<h1>__MSG_prefsInfoTitle__</h1>
<p>__MSG_prefsInfoDesc_1__<br/>

View file

@ -1,7 +1,8 @@
function saveOptions(e) {
e.preventDefault();
let options = {};
document.querySelectorAll(".option-input").forEach(element => {
let element = e.target;
switch (element.type) {
case 'checkbox':
options[element.id] = element.checked;
@ -19,7 +20,7 @@ function saveOptions(e) {
console.log('Unhandled input type:', element.type);
}
}
});
browser.storage.sync.set(options);
}