-
Notifications
You must be signed in to change notification settings - Fork 5
/
options.js
39 lines (32 loc) · 1.75 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"use strict";
document.addEventListener('DOMContentLoaded', function() {
const storage = (chrome.storage.sync ? chrome.storage.sync : chrome.storage.local);
storage.get(null, function(prefs)
{
document.getElementById("cbRotateImages").checked = !(prefs && (false === prefs["bRotateNonSecureImages"]));
document.getElementById("cbWarnOnNonSecureDownloads").checked = (prefs && (true === prefs["bWarnOnNonSecureDownloads"]));
document.getElementById("cbWarnOnNonSecureDocument").checked = !(prefs && (false === prefs["bWarnOnNonSecureDocument"]));
});
var checkboxes = document.querySelectorAll("input[type=checkbox]");
for (let i=0; i<checkboxes.length; i++) {
checkboxes[i].addEventListener('change', saveChanges, false);
}
}, false);
function saveChanges() {
const status = document.getElementById("txtStatus");
status.textContent = "Saving...";
const cbRotateImages = document.getElementById("cbRotateImages");
const cbWarnOnNonSecureDownloads = document.getElementById("cbWarnOnNonSecureDownloads");
const cbWarnOnNonSecureDocument = document.getElementById("cbWarnOnNonSecureDocument");
const storage = (chrome.storage.sync ? chrome.storage.sync : chrome.storage.local);
const oSettings =
{"bRotateNonSecureImages": cbRotateImages.checked,
"bWarnOnNonSecureDownloads": cbWarnOnNonSecureDownloads.checked,
"bWarnOnNonSecureDocument": cbWarnOnNonSecureDocument.checked
};
console.log(JSON.stringify(oSettings));
storage.set(oSettings, null);
status.textContent = "Saved";
setTimeout(function() { status.innerHTML = " "; }, 450);
}
// document.getElementById("btnSave").addEventListener('click', function() {