From 40677bd2c612e8221a11510cf173f006554ac7de Mon Sep 17 00:00:00 2001 From: kkapsner Date: Mon, 27 Aug 2018 22:09:51 +0200 Subject: [PATCH] Only display 250 notifications for one type More will be counted but not rendered. Fixes #234. --- _locales/de/messages.json | 4 ++++ _locales/en/messages.json | 4 ++++ pageAction/domainNotification.js | 29 ++++++++++++++++++++++------- pageAction/pageAction.html | 30 +++++++++++++++--------------- releaseNotes.txt | 1 + 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/_locales/de/messages.json b/_locales/de/messages.json index f6faf88..f0f24c2 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -29,6 +29,10 @@ "message": "weniger", "description": "" }, + "pleaseWait": { + "message": "Bitte warten...", + "description": "" + }, "input": { "message": "Eingabe", diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 2c457ae..8d69b56 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -29,6 +29,10 @@ "message": "less", "description": "" }, + "pleaseWait": { + "message": "Please wait...", + "description": "" + }, "input": { "message": "input", diff --git a/pageAction/domainNotification.js b/pageAction/domainNotification.js index 148391b..53a6ffd 100644 --- a/pageAction/domainNotification.js +++ b/pageAction/domainNotification.js @@ -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; }); }; diff --git a/pageAction/pageAction.html b/pageAction/pageAction.html index 193df77..e46edd7 100644 --- a/pageAction/pageAction.html +++ b/pageAction/pageAction.html @@ -1,24 +1,24 @@ - - CanvasBlocker page action + + CanvasBlocker page action - - -
+ + +
- - - + + + - - - - - - - + + + + + + + diff --git a/releaseNotes.txt b/releaseNotes.txt index 0b3eed2..ad9895c 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -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