diff --git a/data/options.css b/data/options.css index 389cb42..c6bd61e 100644 --- a/data/options.css +++ b/data/options.css @@ -2,6 +2,10 @@ setting[pref-name="showNotifications"] { border-bottom: 0px transparent none; padding-top: 0.5em; } +setting[pref-name="notificationDisplayTime"]{ + border-top: 0px transparent none; + border-bottom: 0px transparent none; +} setting[pref-name="ignoreList"]{ border-top: 0px transparent none; padding-bottom: 0.5em; diff --git a/lib/main.js b/lib/main.js index 4c2b352..0380951 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,6 +24,9 @@ setShow: function(value){ prefs.showNotifications = value; prefService.set("extensions.CanvasBlocker@kkapsner.de.showNotifications", prefs.showNotifications); + }, + displayTime: function(){ + return prefs.notificationDisplayTime; } }; diff --git a/lib/notifications.js b/lib/notifications.js index aab433e..4f05e68 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -7,6 +7,7 @@ var URL = require("sdk/url").URL; const {parseErrorStack} = require("./callingStack"); +const {setTimeout, clearTimeout} = require("sdk/timers"); var tabUtils = require("sdk/tabs/utils"); exports.notify = function({url, errorStack, messageId}, {lists, notificationPref, _, browser, window}){ @@ -35,9 +36,7 @@ exports.notify = function({url, errorStack, messageId}, {lists, notificationPref var notification = notifyBox.getNotificationWithValue("fake-readout"); if (notification){ notification.label = message; - notification.url = url; - notification.domain = domain; - notification.callingStackMsg = callingStackMsg; + clearTimeout(notification.hideTimeout); } else { var buttons = [ @@ -116,10 +115,17 @@ exports.notify = function({url, errorStack, messageId}, {lists, notificationPref priority, buttons ); - notification.url = url; - notification.domain = domain; - notification.callingStackMsg = callingStackMsg; } + notification.url = url; + notification.domain = domain; + notification.callingStackMsg = callingStackMsg; + var displayTime = notificationPref.displayTime(); + if (displayTime){ + notification.hideTimeout = setTimeout(function(){ + notification.close(); + }, displayTime * 1000); + } + return notification; } }; diff --git a/locale/de-DE.json b/locale/de-DE.json index d3897f4..69721fd 100644 --- a/locale/de-DE.json +++ b/locale/de-DE.json @@ -55,6 +55,8 @@ "showCompleteCallingStack_title": "Kompletten Aufrufestack anzeigen", "showNotifications_description": "Benachrichtigungen anzeigen, wenn der Blockiermodus auf \"Auslese-API vortäuschen\" gesetzt ist.", "showNotifications_title": "Benachrichtigungen anzeigen", + "notificationDisplayTime_description": "Anzahl Sekunden, die die Benachrichtigungen anzeigen werdne sollen. (Null eingeben, um die Benachrichtigungen nicht automatisch zu schließen.)", + "notificationDisplayTime_title": "Benachrichtigungsanzeigezeit", "sourceOutput": "Aufrufende Datei", "stackEntryOutput": "{url} Zeile {line} Spalte {column}", "stackList_description": "JS-Dateien, die die -API verwenden dürfen. Die Angabe muss hier im JSON-Format vorliegen. Beispiel: [{\"url\": \"http://domain/datei1.js\"}, {\"url\": \"http://domain/datei2.js\", \"line\": 1, \"column\": 4, \"stackPosition\": -3}]", diff --git a/locale/en-US.json b/locale/en-US.json index 0900946..d0ed0aa 100644 --- a/locale/en-US.json +++ b/locale/en-US.json @@ -55,6 +55,8 @@ "showCompleteCallingStack_title": "Display complete calling stack", "showNotifications_description": "Show a notification when the block mode is set to \"fake readout API\".", "showNotifications_title": "Show notifications", + "notificationDisplayTime_description": "Number of seconds the notifications are shown. (Enter zero to disable automatic closing.)", + "notificationDisplayTime_title": "Notification display time", "sourceOutput": "Calling file", "stackEntryOutput": "{url} line {line} column {column}", "stackList_description": "JS files which are allowed to use the -API. The input has to be in JSON format. Example: [{\"url\": \"http://domain/file1.js\"}, {\"url\": \"http://domain/file2.js\", \"line\": 1, \"column\": 4, \"stackPosition\": -3}]", diff --git a/package.json b/package.json index 424b9f8..11c0023 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,12 @@ "type": "bool", "value": true }, + { + "name": "notificationDisplayTime", + "title": "notification display time", + "type": "integer", + "value": 30 + }, { "name": "ignoreList", "title": "Ignore list",