Only display 250 notifications for one type

More will be counted but not rendered.

Fixes #234.
This commit is contained in:
kkapsner 2018-08-27 22:09:51 +02:00
parent 9a7d3d4230
commit 40677bd2c6
5 changed files with 46 additions and 22 deletions

View File

@ -29,6 +29,10 @@
"message": "weniger",
"description": ""
},
"pleaseWait": {
"message": "Bitte warten...",
"description": ""
},
"input": {
"message": "Eingabe",

View File

@ -29,6 +29,10 @@
"message": "less",
"description": ""
},
"pleaseWait": {
"message": "Please wait...",
"description": ""
},
"input": {
"message": "input",

View File

@ -13,6 +13,7 @@
const addToContainer = function(){
const container = document.getElementById("prints");
container.querySelector("li").textContent = browser.i18n.getMessage("pleaseWait");
var first = true;
return function addToContainer(domainNotification){
@ -27,6 +28,7 @@
const DomainNotification = function DomainNotification(domain, messageId){
this.domain = domain;
this.messageId = messageId;
this.extraNotifications = 0;
addToContainer(this);
this.update();
};
@ -40,10 +42,23 @@
};
DomainNotification.prototype.addNotification = function addNotification(notification){
this.notifications().push(notification);
this.notificationsNode().appendChild(notification.node());
if (this.notifications().length > 250){
this.addMore();
}
else {
this.notifications().push(notification);
this.notificationsNode().appendChild(notification.node());
}
this.update();
};
DomainNotification.prototype.addMore = function addMore(){
this.notificationsNode().appendChild(document.createTextNode("..."));
this.extraNotifications += 1;
this.addMore = function addMore(){
this.extraNotifications += 1;
};
};
// DOM node creation functions
@ -100,16 +115,16 @@
}).filter(function(url, i, urls){
return urls.indexOf(url) === i;
}).join("\n");
node.querySelectorAll(".url").forEach(function(urlSpan){
urlSpan.title = urls;
node.querySelectorAll(".url").forEach((urlSpan) => {
urlSpan.title = urls + (this.extraNotifications? "\n...": "");
});
node.title = notifications.map(function(notification){
return notification.timestamp + ": " + notification.functionName;
}).join("\n");
}).join("\n") + this.extraNotifications? "\n...": "";
node.querySelectorAll(".count").forEach(function(countSpan){
countSpan.textContent = notifications.length;
node.querySelectorAll(".count").forEach((countSpan) => {
countSpan.textContent = notifications.length + this.extraNotifications;
});
};

View File

@ -1,24 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>CanvasBlocker page action</title>
<head>
<title>CanvasBlocker page action</title>
<link href="pageAction.css" rel="stylesheet" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="globalActions"></div>
</head>
<body>
<div id="globalActions"></div>
<ul id="prints">
<li>...</li>
</ul>
<script src="../lib/require.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/require.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/lists.js"></script>
<script src="../lib/callingStack.js"></script>
<script src="gui.js"></script>
<script src="domainNotification.js"></script>
<script src="notification.js"></script>
<script src="pageAction.js"></script>
</body>
<script src="../lib/lists.js"></script>
<script src="../lib/callingStack.js"></script>
<script src="gui.js"></script>
<script src="domainNotification.js"></script>
<script src="notification.js"></script>
<script src="pageAction.js"></script>
</body>
</html>

View File

@ -1,6 +1,7 @@
Version 0.5.3:
changes:
- removed active support for Firefox < 60
- maximal 250 notifications per domain and type will be rendered
new features:
- display version in options page