From f8e0f2337f6e852bcadd4a37b1c15ae0292eb0cb Mon Sep 17 00:00:00 2001 From: Kyle Mitchell Date: Sun, 28 Jan 2018 00:37:48 -0500 Subject: [PATCH] updated storage function to fit chrome --- js/home.js | 15 +++++---------- js/options.js | 16 ++++++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/js/home.js b/js/home.js index 3dd2107..30010f6 100644 --- a/js/home.js +++ b/js/home.js @@ -1,5 +1,5 @@ function restore_options() { - browser.storage.sync.get("links", function(result){ + chrome.storage.sync.get("links", function(result){ var quads = document.querySelectorAll('a') for (i = 0; i < quads.length; i++) { if (result.links[i]) { @@ -9,7 +9,7 @@ function restore_options() { } } }) - browser.storage.sync.get("colors", function(result){ + chrome.storage.sync.get("colors", function(result){ var quads = document.querySelectorAll('a') var style = document.createElement('style'); for (i = 0; i < quads.length; i++) { @@ -19,14 +19,9 @@ function restore_options() { ) } } - document.head.appendChild(style); - for (i = 0; i < input_colors.length; i++) { - if (result.links[i]) { - input_colors[i].value = result.colors[i] - } - } + document.head.appendChild(style) }) - browser.storage.sync.get("mode", function(result){ + chrome.storage.sync.get("mode", function(result){ if (result.mode) { switch(result.mode) { case "light": @@ -40,7 +35,7 @@ function restore_options() { } } else { mode = "light" - browser.storage.sync.set({mode:"light"}) + chrome.storage.sync.set({mode:"light"}) } }) } diff --git a/js/options.js b/js/options.js index 814e294..571fde1 100644 --- a/js/options.js +++ b/js/options.js @@ -13,12 +13,12 @@ function save_options() { links.push(input_links[i].value) colors.push(input_colors[i].value) } - browser.storage.sync.set({links:links, colors:colors}) + chrome.storage.sync.set({links:links, colors:colors}) console.log("Settings Saved ") } function restore_options() { var mode - browser.storage.sync.get("mode", function(result){ + chrome.storage.sync.get("mode", function(result){ if (result.mode) { switch(result.mode) { case "light": @@ -32,17 +32,17 @@ function restore_options() { } } else { mode = "light" - browser.storage.sync.set({mode:"light"}) + chrome.storage.sync.set({mode:"light"}) save_options() } }) - browser.storage.sync.get("links", function(result){ + chrome.storage.sync.get("links", function(result){ var input_links = document.querySelectorAll('input[type="text"]') for (i = 0; i < input_links.length; i++) { input_links[i].value = result.links[i] } }) - browser.storage.sync.get("colors", function(result){ + chrome.storage.sync.get("colors", function(result){ var input_colors = document.querySelectorAll('input[type="color"]') for (i = 0; i < input_colors.length; i++) { if (result.colors[i]) { @@ -52,13 +52,13 @@ function restore_options() { }) } function change_mode() { - browser.storage.sync.get("mode", function(result){ + chrome.storage.sync.get("mode", function(result){ var input_colors = document.querySelectorAll('input[type="color"]') switch(result.mode) { case "light": document.body.classList.add('dark') mode = "dark" - browser.storage.sync.set({mode:"dark"}) + chrome.storage.sync.set({mode:"dark"}) for (i = 0; i < input_colors.length; i++) { if (input_colors[i].value == "#cfcfcf") { input_colors[i].value = "#323234" @@ -69,7 +69,7 @@ function change_mode() { case "dark": document.body.classList.remove('dark') mode = "light" - browser.storage.sync.set({mode:"light"}) + chrome.storage.sync.set({mode:"light"}) for (i = 0; i < input_colors.length; i++) { if (input_colors[i].value == "#323234") { input_colors[i].value = "#cfcfcf"