From 23121bb17d78e03f66de64fe8d7a1ad62baa6753 Mon Sep 17 00:00:00 2001 From: Nick Simmonds Date: Thu, 8 Nov 2012 15:43:37 -0500 Subject: [PATCH] all functions working --- mailscripts.js | 53 +++++++++++++++++++++++++----------------------- manifest.json | 3 ++- preferences.html | 3 +-- toggle.js | 1 + 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/mailscripts.js b/mailscripts.js index 128dc89..35f7d4d 100644 --- a/mailscripts.js +++ b/mailscripts.js @@ -13,39 +13,42 @@ var def; var mailUrl; var port = chrome.extension.connect({name: "localStorage"}) +function changeDefaults(string){ + switch (string) { + case "g": + mailUrl = gMailUrl; + // Gmail uses a different subject identifier + subject = gMailSub; + break; + + case "y": + mailUrl = yMailUrl; + break; + + case "l": + mailUrl = lMailUrl; + break; + + case "o": + mailUrl = owaUrl; + break; + + // use Gmail as the default option, just in case. + default: + mailUrl = gMailUrl; + subject = gMailSub; + } +} + port.onMessage.addListener(function(storage){ if (storage.toggle == "on") tog = true else tog = false def = storage["default"] + changeDefaults(def) }) -switch (def) { - case "g": - mailUrl = gMailUrl; - // Gmail uses a different subject identifier - subject = gMailSub; - break; - - case "y": - mailUrl = yMailUrl; - break; - - case "l": - mailUrl = lMailUrl; - break; - - case "o": - mailUrl = owaUrl; - break; - - // use Gmail as the default option, just in case. - default: - mailUrl = gMailUrl; - subject = gMailSub; -} - port.postMessage({sendMe: "localStorage"}) // note (for debugging/learning purposes) that the function above doesn't fire until diff --git a/manifest.json b/manifest.json index ecd00db..0aa3b07 100644 --- a/manifest.json +++ b/manifest.json @@ -25,7 +25,8 @@ }, "permissions": [ - "*://*/*" + "*://*/*", + "contextMenus" ], "icons": { diff --git a/preferences.html b/preferences.html index 40d3a3f..8675251 100644 --- a/preferences.html +++ b/preferences.html @@ -11,10 +11,9 @@ } + - -

Select the webmail providers you use:

Gmail
diff --git a/toggle.js b/toggle.js index e8559b9..acbb6ae 100644 --- a/toggle.js +++ b/toggle.js @@ -45,6 +45,7 @@ chrome.browserAction.onClicked.addListener(function (tab) { } chrome.extension.getBackgroundPage().window.location.reload(); for (tab in chrome.tabs){ + console.log(tab.id) chrome.tabs.reload(tab.id) } })