summaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-07-13 22:36:34 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-07-13 22:36:34 +0200
commit2da4c13263affdd435ed71edaa111f05a57972a4 (patch)
treecf9dee6a2bf708f9ba57e7d87e285dd355c87b60 /p
parent85bae5436c8cd2b3ff1b08c6ea031e6e99f0a0d6 (diff)
Number of unread articles as prefix in page title
https://github.com/marienfressinaud/FreshRSS/issues/536
Diffstat (limited to 'p')
-rw-r--r--p/scripts/main.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 243159ca5..e1e6d49ce 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -55,9 +55,11 @@ function numberFormat(nStr) {
return x1 + x2;
}
-function incLabel(p, inc) {
+function incLabel(p, inc, spaceAfter = false) {
var i = str2int(p) + inc;
- return i > 0 ? ' (' + numberFormat(i) + ')' : '';
+ return i > 0
+ ? ((spaceAfter ? '' : ' ') + '(' + numberFormat(i) + ')' + (spaceAfter ? ' ' : ''))
+ : '';
}
function incUnreadsFeed(article, feed_id, nb) {
@@ -96,13 +98,13 @@ function incUnreadsFeed(article, feed_id, nb) {
var isCurrentView = false;
//Update unread: title
- document.title = document.title.replace(/((?: \([ 0-9]+\))?)( · .*?)((?: \([ 0-9]+\))?)$/, function (m, p1, p2, p3) {
+ document.title = document.title.replace(/^((?:\([ 0-9]+\) )?)(.*? · )((?:\([ 0-9]+\) )?)/, function (m, p1, p2, p3) {
var $feed = $('#' + feed_id);
if (article || ($feed.closest('.active').length > 0 && $feed.siblings('.active').length === 0)) {
isCurrentView = true;
- return incLabel(p1, nb) + p2 + incLabel(p3, feed_priority > 0 ? nb : 0);
+ return incLabel(p1, nb, true) + p2 + incLabel(p3, feed_priority > 0 ? nb : 0, true);
} else {
- return p1 + p2 + incLabel(p3, feed_priority > 0 ? nb : 0);
+ return p1 + p2 + incLabel(p3, feed_priority > 0 ? nb : 0, true);
}
});
return isCurrentView;