]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/commitdiff
add an option to run silently -- no notifications at all v1.5.4
authorMike Frysinger <vapier@gentoo.org>
Sat, 29 Mar 2014 06:03:04 +0000 (02:03 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 29 Mar 2014 06:03:04 +0000 (02:03 -0400)
_locales/en/messages.json
javascript/clearhistory.js
javascript/options.js
manifest.json
views/options.html

index 9ad84d36980f573492f5e7948b158305d2bbca96..d62529a1c2dd338eea362c30c5567bcad471c84f 100644 (file)
@@ -25,6 +25,7 @@
   "optionsDownloads": {"message": "Clear download history"},
   "optionsSaved": {"message": "Preferences saved!"},
   "optionsAutoclear": {"message": "Automatically purge old entries"},
+  "optionsNotify": {"message": "Display a notification whenever data is cleared"},
   "confirmPrompt": {"message": "Are you sure you want to delete the history?"},
   "notificationTitle": {"message": "History deleted successfully!"},
   "notificationTimeNewer": {
index 28eb2b060676ec161b554e177389f5316b24885a..b40f5958a187ef542f93230b1dd081a55a49f4df 100644 (file)
@@ -65,6 +65,9 @@ function clearDownloads(s) {
  * Callback for when history deletion is successful
  */
 function didClearHistory(s) {
+  if (s.notify !== CONSTANTS.YES)
+    return;
+
   var time = ~~(s.time) || CONSTANTS.DEFAULT_TIME;
   time = getUnitsForTime(time);
   var timeMsg = (time.time === -1) ? 'notificationTimeAll' :
@@ -72,14 +75,17 @@ function didClearHistory(s) {
                 'notificationTimeOlder';
   var timeString = chrome.i18n.getMessage(timeMsg, [time.time, time.units]);
   var message = chrome.i18n.getMessage('notificationBody', timeString);
-  var notification = webkitNotifications.createNotification(
-      chrome.extension.getURL('/images/icon48.png'),
-      chrome.i18n.getMessage('notificationTitle'),
-      message);
-  notification.show();
-  setTimeout(function() {
-    notification.cancel();
-  }, 5000);
+  var options = {
+    type: 'basic',
+    title: chrome.i18n.getMessage('notificationTitle'),
+    message: message,
+    iconUrl: chrome.extension.getURL('/images/icon128.png'),
+  };
+
+  var id = 'clearhistory advance notify';
+  chrome.notifications.clear(id, function(wasCleared) {
+    chrome.notifications.create(id, options, function(){});
+  });
 }
 
 /**
@@ -122,7 +128,7 @@ function clearAll(s) {
 
 function runCleaner() {
   var keys = [
-    'cookies', 'downloads', 'time', 'timeStart',
+    'cookies', 'downloads', 'time', 'timeStart', 'notify',
   ];
   chrome.storage.sync.get(keys, function(s) {
     if (s.cookies === CONSTANTS.YES) {
index bd3a2275c1b341372d9bc3f7f7d0b61556d7fb42..c4ffda4634b32cc5255b86a395d4df369a25bbf1 100644 (file)
@@ -40,7 +40,7 @@ function init() {
 
   // Load or set localStorage data
   var settings = [
-    'timeStart', 'time', 'prompt', 'cookies', 'downloads', 'autoclear',
+    'timeStart', 'time', 'prompt', 'cookies', 'downloads', 'autoclear', 'notify',
   ];
   chrome.storage.sync.get(settings, function(s) {
     var timeStart = s.timeStart || CONSTANTS.YES;
@@ -49,6 +49,7 @@ function init() {
     var clearCookies = s.cookies || CONSTANTS.NO;
     var clearDownloads = s.downloads || CONSTANTS.NO;
     var autoClear = s.autoclear || CONSTANTS.NO;
+    var notify = s.notify || CONSTANTS.YES;
 
     $('input[name=timeStart][value="' + timeStart + '"]')[0].checked = true;
     $('input[name=time][value="' + time + '"]')[0].checked = true;
@@ -56,6 +57,7 @@ function init() {
     $('input[name=cookies]')[0].checked = (clearCookies === CONSTANTS.YES);
     $('input[name=downloads]')[0].checked = (clearDownloads === CONSTANTS.YES);
     $('input[name=autoclear]')[0].checked = (autoClear === CONSTANTS.YES);
+    $('input[name=notify]')[0].checked = (notify === CONSTANTS.YES);
   });
 }
 
index ce21c70c1890bb5604f6cf83c7f3897631209fd8..05070f787688b723d7d3d4dfd8aadbcdc07d2628 100644 (file)
@@ -2,7 +2,8 @@
   "name": "__MSG_name__",
   "default_locale": "en",
   "manifest_version": 2,
-  "version": "1.5.3",
+  "minimum_chrome_version": "28",
+  "version": "1.5.4",
   "description": "__MSG_description__",
   "permissions": [
     "alarms",
@@ -35,6 +36,6 @@
     "128": "images/icon128.png"
   },
   "web_accessible_resources": [
-    "images/icon48.png"
+    "images/icon128.png"
   ]
 }
index 33e3748297b98f3d4cc6308ef0447c3a4a80b22a..78373245a7d0ab7c250f89868c407f1191a84e47 100644 (file)
  </label>
  </div>
 
+ <div class="checkbox">
+ <label>
+  <input name="notify" type="checkbox"/>
+  <span i18n-content="optionsNotify"></span>
+ </label>
+ </div>
+
  <div class="checkbox">
  <label>
   <input name="autoclear" type="checkbox"/>