فهرست منبع

Number of unread articles as prefix in page title

https://github.com/marienfressinaud/FreshRSS/issues/536
Alexandre Alapetite 11 سال پیش
والد
کامیت
2da4c13263
2فایلهای تغییر یافته به همراه10 افزوده شده و 8 حذف شده
  1. 3 3
      app/Controllers/indexController.php
  2. 7 5
      p/scripts/main.js

+ 3 - 3
app/Controllers/indexController.php

@@ -70,11 +70,11 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 		// mise à jour des titres
 		// mise à jour des titres
 		$this->view->rss_title = $this->view->currentName . ' | ' . Minz_View::title();
 		$this->view->rss_title = $this->view->currentName . ' | ' . Minz_View::title();
 		if ($this->view->nb_not_read > 0) {
 		if ($this->view->nb_not_read > 0) {
-			Minz_View::appendTitle (' (' . formatNumber($this->view->nb_not_read) . ')');
+			Minz_View::prependTitle('(' . formatNumber($this->view->nb_not_read) . ') ');
 		}
 		}
-		Minz_View::prependTitle (
+		Minz_View::prependTitle(
+			($this->nb_not_read_cat > 0 ? '(' . formatNumber($this->nb_not_read_cat) . ') ' : '') .
 			$this->view->currentName .
 			$this->view->currentName .
-			($this->nb_not_read_cat > 0 ? ' (' . formatNumber($this->nb_not_read_cat) . ')' : '') .
 			' · '
 			' · '
 		);
 		);
 
 

+ 7 - 5
p/scripts/main.js

@@ -55,9 +55,11 @@ function numberFormat(nStr) {
 	return x1 + x2;
 	return x1 + x2;
 }
 }
 
 
-function incLabel(p, inc) {
+function incLabel(p, inc, spaceAfter = false) {
 	var i = str2int(p) + inc;
 	var i = str2int(p) + inc;
-	return i > 0 ? ' (' + numberFormat(i) + ')' : '';
+	return i > 0
+		? ((spaceAfter ? '' : ' ') + '(' + numberFormat(i) + ')' + (spaceAfter ? ' ' : ''))
+		: '';
 }
 }
 
 
 function incUnreadsFeed(article, feed_id, nb) {
 function incUnreadsFeed(article, feed_id, nb) {
@@ -96,13 +98,13 @@ function incUnreadsFeed(article, feed_id, nb) {
 
 
 	var isCurrentView = false;
 	var isCurrentView = false;
 	//Update unread: title
 	//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);
 		var $feed = $('#' + feed_id);
 		if (article || ($feed.closest('.active').length > 0 && $feed.siblings('.active').length === 0)) {
 		if (article || ($feed.closest('.active').length > 0 && $feed.siblings('.active').length === 0)) {
 			isCurrentView = true;
 			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 {
 		} else {
-			return p1 + p2 + incLabel(p3, feed_priority > 0 ? nb : 0);
+			return p1 + p2 + incLabel(p3, feed_priority > 0 ? nb : 0, true);
 		}
 		}
 	});
 	});
 	return isCurrentView;
 	return isCurrentView;