Added notification display time.

Fixes #85.
This commit is contained in:
kkapsner 2016-11-11 00:19:25 +01:00
parent 410e92d1b0
commit d122f90655
6 changed files with 29 additions and 6 deletions

View File

@ -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;

View File

@ -24,6 +24,9 @@
setShow: function(value){
prefs.showNotifications = value;
prefService.set("extensions.CanvasBlocker@kkapsner.de.showNotifications", prefs.showNotifications);
},
displayTime: function(){
return prefs.notificationDisplayTime;
}
};

View File

@ -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;
}
};

View File

@ -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 <canvas>-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}]",

View File

@ -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 <canvas>-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}]",

View File

@ -100,6 +100,12 @@
"type": "bool",
"value": true
},
{
"name": "notificationDisplayTime",
"title": "notification display time",
"type": "integer",
"value": 30
},
{
"name": "ignoreList",
"title": "Ignore list",