From 1edb16a47eb8a35fc3ea7991bfdfc8434d1d3bff Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Wed, 9 Feb 2011 23:05:40 -0800 Subject: Style --- background_page.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index d98967b4..77150244 100644 --- a/background_page.html +++ b/background_page.html @@ -18,8 +18,9 @@ var focusedFrame = null; var framesForTab = {}; - // Keys are either literal characters, or "named" - for example (alt+b), (the left arrow) or - // This regular expression captures two groups, the first is a named key, the second is the remainder of the string. + // Keys are either literal characters, or "named" - for example (alt+b), (left arrow) or + // This regular expression captures two groups: the first is a named key, the second is the remainder of + // the string. var namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/; var defaultSettings = { @@ -164,7 +165,8 @@ function showHelp(callback, frameId) { chrome.tabs.getSelected(null, function(tab) { - chrome.tabs.sendRequest(tab.id, { name: "showHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }); + chrome.tabs.sendRequest(tab.id, + { name: "showHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }); }); } -- cgit v1.2.3 From a036d2dac281b2528c2087b08839e118e3f449ae Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Wed, 9 Feb 2011 23:06:41 -0800 Subject: Preserve the "show advanced commands" setting after you close the vimium help dialog. --- background_page.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index 77150244..ee12a77d 100644 --- a/background_page.html +++ b/background_page.html @@ -79,7 +79,8 @@ upgradeNotificationClosed: upgradeNotificationClosed, updateScrollPosition: handleUpdateScrollPosition, copyToClipboard: copyToClipboard, - isEnabledForUrl: isEnabledForUrl + isEnabledForUrl: isEnabledForUrl, + saveHelpDialogSettings: saveHelpDialogSettings }; // Event handlers @@ -151,6 +152,10 @@ return { isEnabledForUrl: isEnabled }; } + function saveHelpDialogSettings(request) { + localStorage["helpDialog_showAdvancedCommands"] = request.showAdvancedCommands; + } + /* * Returns the previously saved zoom level for the current tab, or the default zoom level */ @@ -186,6 +191,8 @@ showUnboundCommands, showCommandNames)); dialogHtml = dialogHtml.replace("{{version}}", currentVersion); dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); + dialogHtml = dialogHtml.replace("{{showAdvancedCommands}}", + localStorage["helpDialog_showAdvancedCommands"] == "true"); return dialogHtml; } -- cgit v1.2.3 From e12b93096a05fe5b633f407c41c8dd9164308f1a Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 11 Feb 2011 13:49:35 -0800 Subject: fix default fetching with excludedUrls --- background_page.html | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index ee12a77d..0e47bbf7 100644 --- a/background_page.html +++ b/background_page.html @@ -141,7 +141,7 @@ */ function isEnabledForUrl(request) { // excludedUrls are stored as a series of URL expressions separated by newlines. - var excludedUrls = (localStorage["excludedUrls"] || defaultSettings.excludedUrls).split("\n"); + var excludedUrls = getSettingFromLocalStorage("excludedUrls").split("\n"); var isEnabled = true; for (var i = 0; i < excludedUrls.length; i++) { // The user can add "*" to the URL which means ".*" @@ -163,8 +163,7 @@ var returnPort = chrome.tabs.connect(port.tab.id, { name: "returnZoomLevel" }); var localStorageKey = "zoom" + args.domain; var zoomLevelForDomain = (localStorage[localStorageKey] || "").split(",")[1]; - var zoomLevel = parseInt(zoomLevelForDomain || localStorage["defaultZoomLevel"] || - defaultSettings.defaultZoomLevel); + var zoomLevel = parseInt(zoomLevelForDomain || getSettingFromLocalStorage("defaultZoomLevel")); returnPort.postMessage({ zoomLevel: zoomLevel }); } @@ -284,12 +283,22 @@ * Used by the content scripts to get settings from the local storage. */ function getSetting(args, port) { - var value = localStorage[args.key] ? localStorage[args.key] : defaultSettings[args.key]; - + var value = getSettingFromLocalStorage(args.key); var returnPort = chrome.tabs.connect(port.tab.id, { name: "returnSetting" }); returnPort.postMessage({ key: args.key, value: value }); } + /* + * Used by everyone to get settings from local storage. + */ + function getSettingFromLocalStorage(setting) { + if (localStorage[setting] != "" && !localStorage[setting]) { + return defaultSettings[setting]; + } else { + return localStorage[setting]; + } + } + /* * Persists the current zoom level for a given domain */ -- cgit v1.2.3