MCPcopy Index your code
hub / github.com/ClearURLs/Addon / changeSwitchButton

Function changeSwitchButton

core_js/settings.js:295–317  ·  view source on GitHub ↗

* Change the value of a switch button. * @param {string} id HTML id * @param {string} storageID storage internal id

(id, storageID)

Source from the content-addressed store, hash-verified

293 * @param {string} storageID storage internal id
294 */
295function changeSwitchButton(id, storageID) {
296 let element = document.getElementById(id);
297
298 element.onchange = function () {
299 browser.runtime.sendMessage({
300 function: "setData",
301 params: [storageID, element.checked]
302 }).then(() => {
303 if (storageID === "globalStatus") {
304 browser.runtime.sendMessage({
305 function: "changeIcon",
306 params: []
307 }).catch(handleError);
308 }
309
310 browser.runtime.sendMessage({
311 function: "saveOnExit",
312 params: []
313 }).catch(handleError);
314 }).catch(handleError);
315 };
316 setSwitchButton(id, storageID);
317}
318
319/**
320 * Helper function to inject the translated text and tooltip.

Callers 1

getDataFunction · 0.70

Calls 1

setSwitchButtonFunction · 0.70

Tested by

no test coverage detected