mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 18:42:00 +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",
|
"type": "bool",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
"name": "notificationDisplayTime",
|
// "name": "notificationDisplayTime",
|
||||||
"title": "notification display time",
|
// "title": "notification display time",
|
||||||
"type": "integer",
|
// "type": "integer",
|
||||||
"value": 30
|
// "value": 30
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
"name": "ignoreList",
|
"name": "ignoreList",
|
||||||
"title": "Ignore list",
|
"title": "Ignore list",
|
||||||
@ -161,7 +161,7 @@ document.body.appendChild(table);
|
|||||||
html += '<input type="text"' + inputAttributes + ' value="' + pref.value + '">';
|
html += '<input type="text"' + inputAttributes + ' value="' + pref.value + '">';
|
||||||
break;
|
break;
|
||||||
case "bool":
|
case "bool":
|
||||||
html += '<input type="checkbox"' + inputAttributes + (pref.value? ' checked="checked"': "") + '>';
|
html += '<input type="checkbox" style="display: inline"' + inputAttributes + (pref.value? ' checked="checked"': "") + '>';
|
||||||
break;
|
break;
|
||||||
case "menulist":
|
case "menulist":
|
||||||
html += '<select' + inputAttributes + '>' +
|
html += '<select' + inputAttributes + '>' +
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>CanvasBlocker Settings</title>
|
<title>CanvasBlocker Settings</title>
|
||||||
<link href="options.css" rel="stylesheet" type="text/css">
|
<link href="options.css" rel="stylesheet" type="text/css">
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="buildPrefInputs.js"></script>
|
<script src="buildPrefInputs.js"></script>
|
||||||
|
@ -20,6 +20,21 @@
|
|||||||
|
|
||||||
Array.from(document.querySelectorAll("input.setting, select.setting")).forEach(function(input){
|
Array.from(document.querySelectorAll("input.setting, select.setting")).forEach(function(input){
|
||||||
var storageName = input.dataset.storageName;
|
var storageName = input.dataset.storageName;
|
||||||
|
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){
|
browser.storage.local.get(storageName).then(function(value){
|
||||||
// console.log(storageName, "got storage value", value);
|
// console.log(storageName, "got storage value", value);
|
||||||
if (value.hasOwnProperty(storageName)){
|
if (value.hasOwnProperty(storageName)){
|
||||||
@ -28,22 +43,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener("change", function(){
|
input.addEventListener("change", function(){
|
||||||
var value;
|
var value = this.value;
|
||||||
if (this.type === "checkbox"){
|
|
||||||
value = this.checked;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
value = this.value;
|
|
||||||
}
|
|
||||||
var obj = {};
|
var obj = {};
|
||||||
obj[storageName] = value;
|
obj[storageName] = value;
|
||||||
browser.storage.local.set(obj);
|
browser.storage.local.set(obj);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
showReleaseNotes: function(){
|
showReleaseNotes: function(){
|
||||||
console.log("sdsdsdsd");
|
|
||||||
window.open("../releaseNotes.txt", "_blank");
|
window.open("../releaseNotes.txt", "_blank");
|
||||||
},
|
},
|
||||||
clearPersistentRnd: function(){
|
clearPersistentRnd: function(){
|
||||||
@ -60,9 +69,19 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.storage.onChanged.addListener(function(data){
|
browser.storage.onChanged.addListener(function(change, area){
|
||||||
Object.keys(data).forEach(function(storageName){
|
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