* Change the value of a switch button. * @param {string} id HTML id * @param {string} storageID storage internal id
(id, storageID)
| 85 | * @param {string} storageID storage internal id |
| 86 | */ |
| 87 | function changeSwitchButton(id, storageID) |
| 88 | { |
| 89 | let element = document.getElementById(id); |
| 90 | |
| 91 | changeVisibility(id, storageID); |
| 92 | |
| 93 | element.onchange = function(){ |
| 94 | browser.runtime.sendMessage({ |
| 95 | function: "setData", |
| 96 | params: [storageID, element.checked] |
| 97 | }).then((data) => { |
| 98 | if(storageID === "globalStatus"){ |
| 99 | browser.runtime.sendMessage({ |
| 100 | function: "changeIcon", |
| 101 | params: [] |
| 102 | }).catch(handleError); |
| 103 | } |
| 104 | changeVisibility(id, storageID); |
| 105 | |
| 106 | browser.runtime.sendMessage({ |
| 107 | function: "saveOnExit", |
| 108 | params: [] |
| 109 | }).catch(handleError); |
| 110 | }).catch(handleError); |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Change the visibility of sections. |
no test coverage detected