]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/commitdiff
make cookie deletion optional
authorMike Frysinger <vapier@gentoo.org>
Tue, 29 Jan 2013 23:45:54 +0000 (18:45 -0500)
committerMike Frysinger <vapier@gentoo.org>
Wed, 30 Jan 2013 03:40:09 +0000 (22:40 -0500)
_locales/en/messages.json
css/options.css
javascript/clearhistory.js
javascript/options.js
views/options.html

index 16e84dd2f6457b124ad22344615cc1309a56c111..82ff685f12803eb10230eacc53890e7087779889 100644 (file)
@@ -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!"},
index 9b8ed3480ce1bbb975abceda001d23593f4ffc8d..cdd6c74d388e1d2ca5b4907a76b3372f33566048 100644 (file)
@@ -50,7 +50,8 @@ hr {
   width: 400px;
 }
 #opt-time,
-#opt-prompt {
+#opt-prompt,
+#opt-cookies {
   background-color: white;
   clear: left;
   margin: 5px auto;
index d73827a7e57aed5349752130ab9baa38eea0044b..3766f6bf83e3a3d1adc440a3838e9f3b1f6b652e 100644 (file)
@@ -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();
   }
 });
index 682347bff6c00e2e6d68980bba947938c3030673..62721cbdd7d44c888c5a25d7bb02584a64c5b992 100644 (file)
@@ -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;
 /**
index 29de38af55641ed1df80fd66131ea432de1c19e9..2c508f47cae8b3cc2c29a960783f02c11006921a 100644 (file)
           </div>
         </div>
         <hr>
+        <div id="opt-cookies">
+          <div class="opt-name">
+            <b>&nbsp;</b>
+          </div>
+          <div class="opt-value">
+            <div class="opt-option">
+              <input name="cookies" class="opt-chk" type="checkbox">
+              <div class="opt-label" id="optionsCookies"></div>
+            </div>
+          </div>
+        </div>
+        <hr>
         <div id="optionsSaved">
           <b></b>
         </div>