Make gear cog work with closing settings.

This commit is contained in:
reesericci
2020-09-09 18:13:40 -05:00
parent 19827e2957
commit 561e7cf491

View File

@@ -10,8 +10,7 @@
modalId = "settings"
closeId = "close"
jsonContainer = "jsoneditor"
let gear = false
let gear = false;
// Detect browser
BROWSER = detectBrowser()
@@ -20,15 +19,7 @@ document.getElementById('settings-cog').onclick = function() {
if (gear == false) {
gear = true;
showSettings()
} else if (gear == true) {
modalEl.style.display = "none"
gear = false;
// Get the updated JSON
updatedJson = editor.get()
BROWSER.storage.sync.set(updatedJson)
document.getElementById(jsonContainer).innerHTML = ""
location.reload()
}
}
}
function showSettings() {
@@ -53,6 +44,14 @@ function showSettings() {
document.getElementById(jsonContainer).innerHTML = ""
location.reload()
}
document.getElementById('settings-cog').onclick = () => {
modalEl.style.display = "none"
// Get the updated JSON
updatedJson = editor.get()
BROWSER.storage.sync.set(updatedJson)
document.getElementById(jsonContainer).innerHTML = ""
location.reload()
}
}
async function loadJson(editor) {
@@ -64,7 +63,7 @@ async function loadJson(editor) {
// Populate the editor
editor.set(result)
})
}
};
function detectBrowser() {
// Firefox
@@ -73,5 +72,5 @@ function detectBrowser() {
else if (!!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime))
BROWSER = chrome
return BROWSER
}
return BROWSER;
};