]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/blobdiff - javascript/options.js
make cookie deletion optional
[chrome-ext/clearhistory-advance-fork.git] / javascript / options.js
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;
 /**