diff --git a/css/main.css b/css/main.css index 7ce1d48..9b29874 100644 --- a/css/main.css +++ b/css/main.css @@ -152,3 +152,14 @@ body { color: black; text-decoration: none; cursor: pointer; } + +#settings-cog { + width: 48px; + height: 48px; + position: absolute; + bottom: 25px; + right: 25px; +} +.cog:hover { + fill: white; + } diff --git a/index.html b/index.html index 7178528..1c7312d 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,9 @@
+ + + @@ -43,4 +46,4 @@ - \ No newline at end of file + diff --git a/js/main.js b/js/main.js index f0b3ccf..a2e9876 100644 --- a/js/main.js +++ b/js/main.js @@ -79,7 +79,7 @@ function initSearchBar(jsonData) { query = document.getElementById(searchBarId).value // Open settings - if (query == "--setting") { + if (query == "--setting" || query == "--settings") { showSettings() document.getElementById(searchBarId).value = "" // Remove the autocomplete boxes @@ -392,7 +392,6 @@ function extractQuickLinks(passedSqrs) { autocomplete(document.getElementById("search-bar-input"), this.validQuickLinks); } - // Listen to key click function listenForSettings() { diff --git a/js/settings.js b/js/settings.js index 6926384..7936538 100644 --- a/js/settings.js +++ b/js/settings.js @@ -14,6 +14,10 @@ jsonContainer = "jsoneditor" // Detect browser BROWSER = detectBrowser() +document.getElementById('settings-cog').onclick = function() { + showSettings() +} + function showSettings() { modalEl = document.getElementById(modalId) closeBtn = document.getElementsByClassName(closeId)[0] @@ -36,6 +40,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) { @@ -47,7 +59,7 @@ async function loadJson(editor) { // Populate the editor editor.set(result) }) -} +}; function detectBrowser() { // Firefox @@ -56,5 +68,5 @@ function detectBrowser() { else if (!!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime)) BROWSER = chrome - return BROWSER -} \ No newline at end of file + return BROWSER; +};