From: Mike Frysinger Date: Tue, 29 Jan 2013 23:45:54 +0000 (-0500) Subject: make cookie deletion optional X-Git-Tag: v1.5.0~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=77dffdcdb7a4c632fd98c566eb2b3f487f6efb0e;p=chrome-ext%2Fclearhistory-advance-fork.git make cookie deletion optional --- diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 16e84dd..82ff685 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -15,6 +15,7 @@ }, "optionsTimeAll": {"message": "Everything"}, "optionsPrompt": {"message": "Prompt before deleting"}, + "optionsCookies": {"message": "Clear cookies too"}, "optionsSaved": {"message": "Preferences saved!"}, "confirmPrompt": {"message": "Are you sure you want to delete the history?"}, "notificationTitle": {"message": "History deleted successfully!"}, diff --git a/css/options.css b/css/options.css index 9b8ed34..cdd6c74 100644 --- a/css/options.css +++ b/css/options.css @@ -50,7 +50,8 @@ hr { width: 400px; } #opt-time, -#opt-prompt { +#opt-prompt, +#opt-cookies { background-color: white; clear: left; margin: 5px auto; diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index d73827a..3766f6b 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -89,14 +89,19 @@ function clearHistory() { chrome.browserAction.onClicked.addListener(function(tab) { // Get the value from localStorage var showPrompt = localStorage['prompt'] || CONSTANTS.YES; + var clearCookies = localStorage['cookies'] || CONSTANTS.NO; // The confirmation message to ask var message = chrome.i18n.getMessage('confirmPrompt'); // Clear cookies, and then clear the history if (showPrompt === CONSTANTS.YES) { - confirm(message) && clearCookies(clearHistory); - } else { + if (!confirm(message)) + return; + } + if (clearCookies === CONSTANTS.YES) { clearCookies(clearHistory); + } else { + clearHistory(); } }); diff --git a/javascript/options.js b/javascript/options.js index 682347b..62721cb 100644 --- a/javascript/options.js +++ b/javascript/options.js @@ -30,12 +30,16 @@ function init() { $('#optionsHeader')[0].innerText = chrome.i18n.getMessage('optionsHeader'); $('#optionsPrompt')[0].innerText = chrome.i18n.getMessage('optionsPrompt'); $('#optionsTimeFor')[0].innerText = chrome.i18n.getMessage('optionsTimeFor'); + $('#optionsCookies')[0].innerText = chrome.i18n.getMessage('optionsCookies'); $('#optionsSaved > b')[0].innerText = chrome.i18n.getMessage('optionsSaved'); // Bind all the callbacks $('#opt-time input.opt-chk[type=radio]').forEach(function(e) { e.onclick = toggle; }); + $('input.opt-chk[type=checkbox]').forEach(function(e) { + e.onclick = setCheck; + }); $('#opt-prompt input.opt-chk[type=checkbox]').forEach(function(e) { e.onclick = setPrompt; }); @@ -45,9 +49,11 @@ function init() { (localStorage['time'] = CONSTANTS.DEFAULT_TIME); var showPrompt = localStorage['prompt'] || (localStorage['prompt'] = CONSTANTS.YES); + var clearCookies = localStorage['cookies'] || CONSTANTS.NO; $('input[name=time][value="' + time + '"]')[0].checked = true; $('input[name=prompt]')[0].checked = (showPrompt === CONSTANTS.YES); + $('input[name=cookies]')[0].checked = (clearCookies === CONSTANTS.YES); } /** @@ -68,6 +74,11 @@ function setPrompt() { optionSaved(); } +function setCheck() { + localStorage[this.name] = this.checked ? CONSTANTS.YES : CONSTANTS.NO; + optionSaved(); +} + // For rapid changes/saves var isSaving = null; /** diff --git a/views/options.html b/views/options.html index 29de38a..2c508f4 100644 --- a/views/options.html +++ b/views/options.html @@ -66,6 +66,18 @@
+
+
+   +
+
+
+ +
+
+
+
+