mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 22:25:36 +07:00
100
popup.js
100
popup.js
@@ -1,47 +1,67 @@
|
||||
var status = "enabled";
|
||||
var exception = "false";
|
||||
var exception = "off";
|
||||
var resultFormRestore;
|
||||
|
||||
function changeStatus() {
|
||||
var text = $("#statusText");
|
||||
var button = $("#statusBtn");
|
||||
if(status == "enabled") {
|
||||
console.log("was enabled");
|
||||
text.html("Dis");
|
||||
button.removeClass("statusEnabled").addClass("statusDisabled");
|
||||
status = "disabled";
|
||||
console.log("is disabled");
|
||||
}
|
||||
else {
|
||||
console.log("was disabled");
|
||||
text.html("En");
|
||||
button.removeClass("statusDisabled").addClass("statusEnabled");
|
||||
status = "enabled";
|
||||
console.log("is enabled");
|
||||
}
|
||||
function saveOptions(key, result) {
|
||||
console.log("Save with key"+key+" the result: "+result);
|
||||
browser.storage.local.set({
|
||||
key: result
|
||||
});
|
||||
};
|
||||
/*
|
||||
function handleException() {
|
||||
|
||||
function restoreOptions(key)
|
||||
{
|
||||
resultFormRestore = null;
|
||||
function setCurrentChoise(_result)
|
||||
{
|
||||
console.log("Reload config with key: "+key+" and result: ");
|
||||
resultFormRestore = _result;
|
||||
console.log(resultFormRestore);
|
||||
};
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
};
|
||||
|
||||
var getting = browser.storage.local.get(key);
|
||||
getting.then(setCurrentChoise, onError);
|
||||
return resultFormRestore;
|
||||
}
|
||||
|
||||
function changeStatus(){
|
||||
var status = restoreOptions("globalStatus");
|
||||
console.log("status: "+status);
|
||||
var element = $("#globalStatus");
|
||||
|
||||
if(status == null){
|
||||
saveOptions("globalStatus", true);
|
||||
status = true;
|
||||
}
|
||||
|
||||
if(status){
|
||||
status = saveOptions("globalStatus", false);
|
||||
element.removeClass().addClass("status statusDisabled");
|
||||
}else{
|
||||
status = saveOptions("globalStatus", true);
|
||||
element.removeClass().addClass("status statusEnabled");
|
||||
}
|
||||
};
|
||||
|
||||
function handleException(){
|
||||
var element = $("#exception");
|
||||
var val = "Enable on page";
|
||||
|
||||
if(exception == false) {
|
||||
val = "Disable on page";
|
||||
exception = "true";
|
||||
element.removeClass().addClass("disable");
|
||||
}
|
||||
else {
|
||||
exception = "false";
|
||||
element.removeClass().addClass("enable");
|
||||
|
||||
if(exception == "off"){
|
||||
val = "Disable on page";
|
||||
exception = "on";
|
||||
element.removeClass().addClass("disable");
|
||||
}else{
|
||||
exception = "off";
|
||||
element.removeClass().addClass("enable");
|
||||
}
|
||||
element.html(val);
|
||||
};
|
||||
*/
|
||||
/*
|
||||
$(document).ready(function() {
|
||||
$("#statusBtn").on("click", changeStatus);
|
||||
//$("#exception").on("click", handleException);
|
||||
});
|
||||
*/
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
$("#statusBtn").on("click", changeStatus);
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#globalStatus").on("click", changeStatus);
|
||||
$("#exception").on("click", handleException);
|
||||
});
|
||||
Reference in New Issue
Block a user