mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Fixed: options page did not update and checkboxes were not displayed.
This commit is contained in:
parent
584f178ff7
commit
b6dd2ff011
@ -109,12 +109,12 @@ document.body.appendChild(table);
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"name": "notificationDisplayTime",
|
||||
"title": "notification display time",
|
||||
"type": "integer",
|
||||
"value": 30
|
||||
},
|
||||
// {
|
||||
// "name": "notificationDisplayTime",
|
||||
// "title": "notification display time",
|
||||
// "type": "integer",
|
||||
// "value": 30
|
||||
// },
|
||||
{
|
||||
"name": "ignoreList",
|
||||
"title": "Ignore list",
|
||||
@ -161,7 +161,7 @@ document.body.appendChild(table);
|
||||
html += '<input type="text"' + inputAttributes + ' value="' + pref.value + '">';
|
||||
break;
|
||||
case "bool":
|
||||
html += '<input type="checkbox"' + inputAttributes + (pref.value? ' checked="checked"': "") + '>';
|
||||
html += '<input type="checkbox" style="display: inline"' + inputAttributes + (pref.value? ' checked="checked"': "") + '>';
|
||||
break;
|
||||
case "menulist":
|
||||
html += '<select' + inputAttributes + '>' +
|
||||
|
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<title>CanvasBlocker Settings</title>
|
||||
<link href="options.css" rel="stylesheet" type="text/css">
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<script src="buildPrefInputs.js"></script>
|
||||
|
@ -20,30 +20,39 @@
|
||||
|
||||
Array.from(document.querySelectorAll("input.setting, select.setting")).forEach(function(input){
|
||||
var storageName = input.dataset.storageName;
|
||||
browser.storage.local.get(storageName).then(function(value){
|
||||
// console.log(storageName, "got storage value", value);
|
||||
if (value.hasOwnProperty(storageName)){
|
||||
input.value = value[storageName];
|
||||
}
|
||||
});
|
||||
|
||||
input.addEventListener("change", function(){
|
||||
var value;
|
||||
if (this.type === "checkbox"){
|
||||
value = this.checked;
|
||||
}
|
||||
else {
|
||||
value = this.value;
|
||||
}
|
||||
var obj = {};
|
||||
obj[storageName] = value;
|
||||
browser.storage.local.set(obj);
|
||||
});
|
||||
if (input.type === "checkbox"){
|
||||
browser.storage.local.get(storageName).then(function(value){
|
||||
// console.log(storageName, "got storage value", value);
|
||||
if (value.hasOwnProperty(storageName)){
|
||||
input.checked = value[storageName];
|
||||
}
|
||||
});
|
||||
|
||||
input.addEventListener("click", function(){
|
||||
var value = this.checked;
|
||||
var obj = {};
|
||||
obj[storageName] = value;
|
||||
browser.storage.local.set(obj);
|
||||
});}
|
||||
else {
|
||||
browser.storage.local.get(storageName).then(function(value){
|
||||
// console.log(storageName, "got storage value", value);
|
||||
if (value.hasOwnProperty(storageName)){
|
||||
input.value = value[storageName];
|
||||
}
|
||||
});
|
||||
|
||||
input.addEventListener("change", function(){
|
||||
var value = this.value;
|
||||
var obj = {};
|
||||
obj[storageName] = value;
|
||||
browser.storage.local.set(obj);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var callbacks = {
|
||||
showReleaseNotes: function(){
|
||||
console.log("sdsdsdsd");
|
||||
window.open("../releaseNotes.txt", "_blank");
|
||||
},
|
||||
clearPersistentRnd: function(){
|
||||
@ -60,9 +69,19 @@
|
||||
});
|
||||
});
|
||||
|
||||
browser.storage.onChanged.addListener(function(data){
|
||||
Object.keys(data).forEach(function(storageName){
|
||||
|
||||
});
|
||||
browser.storage.onChanged.addListener(function(change, area){
|
||||
if (area === "local"){
|
||||
Object.keys(change).forEach(function(key){
|
||||
var input = document.querySelector(".setting[data-storage-name=" + key + "]");
|
||||
if (input){
|
||||
if (input.type === "checkbox"){
|
||||
input.checked = change[key].newValue;
|
||||
}
|
||||
else {
|
||||
input.value = change[key].newValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
Loading…
x
Reference in New Issue
Block a user