From ed05c47d9929845a1ecb5b2ceea5b9dc6f15f341 Mon Sep 17 00:00:00 2001 From: Reese Date: Wed, 9 Sep 2020 07:27:12 -0500 Subject: [PATCH 1/8] Add --settings as a valid query --setting is kinda weird so I made --settings a valid query. --- js/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 2dc729c..6839667 100644 --- a/js/main.js +++ b/js/main.js @@ -84,6 +84,12 @@ function initSearchBar(jsonData) { // Remove the autocomplete boxes document.getElementById("search-bar-input-autocomplete-list").style.display = "none"; return + } else if (query == "--settings") { + showSettings() + document.getElementById(searchBarId).value = "" + // Remove the autocomplete boxes + document.getElementById("search-bar-input-autocomplete-list").style.display = "none"; + return } // If not others, then it's probably a search @@ -389,4 +395,4 @@ function extractQuickLinks(passedSqrs) { // Start the autocomplete autocomplete(document.getElementById("search-bar-input"), this.validQuickLinks); -} \ No newline at end of file +} From 4069f277504a9e52ddcc3c1d6ee70095dd926a62 Mon Sep 17 00:00:00 2001 From: Reese Date: Wed, 9 Sep 2020 07:59:46 -0500 Subject: [PATCH 2/8] Settings cog Add settings cog with onclick. Icon from materialdesignicons.com --- index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 7178528..dee030c 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,9 @@
+ + + @@ -43,4 +46,4 @@ - \ No newline at end of file + From 19827e2957a72b52a45d25f734f83e681d58e86d Mon Sep 17 00:00:00 2001 From: reesericci Date: Wed, 9 Sep 2020 12:54:02 -0500 Subject: [PATCH 3/8] Add settings cog (for real) --- css/main.css | 9 +++++++++ index.html | 4 ++-- js/settings.js | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/css/main.css b/css/main.css index 5b8606e..4da2389 100644 --- a/css/main.css +++ b/css/main.css @@ -151,3 +151,12 @@ body { color: black; text-decoration: none; cursor: pointer; } + +#settings-cog { + position: absolute; + bottom: 25px; + right: 25px; +} +.cog:hover { + fill: white; + } diff --git a/index.html b/index.html index dee030c..fb43853 100644 --- a/index.html +++ b/index.html @@ -35,8 +35,8 @@
- - + + diff --git a/js/settings.js b/js/settings.js index 6926384..3d5f8dc 100644 --- a/js/settings.js +++ b/js/settings.js @@ -11,9 +11,26 @@ modalId = "settings" closeId = "close" jsonContainer = "jsoneditor" +let gear = false + // Detect browser BROWSER = detectBrowser() +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() { modalEl = document.getElementById(modalId) closeBtn = document.getElementsByClassName(closeId)[0] @@ -57,4 +74,4 @@ function detectBrowser() { BROWSER = chrome return BROWSER -} \ No newline at end of file +} From 561e7cf49120cedb03a454ada45e73af02ce2e7d Mon Sep 17 00:00:00 2001 From: reesericci Date: Wed, 9 Sep 2020 18:13:40 -0500 Subject: [PATCH 4/8] Make gear cog work with closing settings. --- js/settings.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/js/settings.js b/js/settings.js index 3d5f8dc..36dff99 100644 --- a/js/settings.js +++ b/js/settings.js @@ -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; +}; From 1b9133db1befa0805238444c7847f71d0f230f34 Mon Sep 17 00:00:00 2001 From: reesericci Date: Wed, 9 Sep 2020 18:25:58 -0500 Subject: [PATCH 5/8] quick patch, make things simpler --- js/settings.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/js/settings.js b/js/settings.js index 36dff99..7936538 100644 --- a/js/settings.js +++ b/js/settings.js @@ -10,16 +10,12 @@ modalId = "settings" closeId = "close" jsonContainer = "jsoneditor" -let gear = false; // Detect browser BROWSER = detectBrowser() document.getElementById('settings-cog').onclick = function() { - if (gear == false) { - gear = true; - showSettings() - } + showSettings() } function showSettings() { From 7f888c0724663ab6531518e2addf742cb2d59008 Mon Sep 17 00:00:00 2001 From: Reese Date: Mon, 14 Sep 2020 08:45:35 -0500 Subject: [PATCH 6/8] cleaning up if statement resolving comment by @deepjyoti30` --- js/main.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/js/main.js b/js/main.js index 6839667..2d8351c 100644 --- a/js/main.js +++ b/js/main.js @@ -78,13 +78,7 @@ function initSearchBar(jsonData) { query = document.getElementById(searchBarId).value // Open settings - if (query == "--setting") { - showSettings() - document.getElementById(searchBarId).value = "" - // Remove the autocomplete boxes - document.getElementById("search-bar-input-autocomplete-list").style.display = "none"; - return - } else if (query == "--settings") { + if (query == "--setting" || query == "--settings") { showSettings() document.getElementById(searchBarId).value = "" // Remove the autocomplete boxes From 217fbe8229500751bb86d5649edd5ac9c30d104b Mon Sep 17 00:00:00 2001 From: Reese Date: Tue, 15 Sep 2020 10:27:45 -0500 Subject: [PATCH 7/8] set css for cog migrate from style attribute --- css/main.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/css/main.css b/css/main.css index 4da2389..125141b 100644 --- a/css/main.css +++ b/css/main.css @@ -153,6 +153,8 @@ body { cursor: pointer; } #settings-cog { + width: 48px; + height: 48px; position: absolute; bottom: 25px; right: 25px; From 75013e7211354afda1afb88cbe21567e04d03406 Mon Sep 17 00:00:00 2001 From: Reese Date: Tue, 15 Sep 2020 10:27:57 -0500 Subject: [PATCH 8/8] remove style attribute --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index fb43853..1c7312d 100644 --- a/index.html +++ b/index.html @@ -35,7 +35,7 @@
- +