Update dynamically unread counter in multiple places

This commit is contained in:
Frederic Guillot 2013-06-14 20:37:45 -04:00
parent a48afcbc0d
commit f9146f078a
4 changed files with 36 additions and 14 deletions

View File

@ -171,12 +171,24 @@
{
var item = document.getElementById("item-" + item_id);
if (item) item.parentNode.removeChild(item);
var $unread_span = document.getElementById("unread-count");
var unread_count = parseInt($unread_span.innerHTML, 10) - 1;
$unread_span.innerHTML = unread_count;
document.querySelector("title").innerHTML = "miniflux (" + unread_count + ")";
var container = document.getElementById("page-counter");
if (container) {
counter = parseInt(container.textContent.trim(), 10) - 1;
if (counter == 0) {
window.location = "?action=feeds&nothing_to_read=1";
}
else {
container.textContent = counter + " ";
document.title = "miniflux (" + counter + ")";
document.getElementById("nav-counter").textContent = "(" + counter + ")";
}
}
}
@ -239,7 +251,7 @@
if (! document.getElementById("current-item")) {
document.querySelector("article").id = "current-item";
}
var item = document.getElementById("current-item");
if (item) switch_status(item.getAttribute("data-item-id"));
}

View File

@ -36,7 +36,7 @@ return array(
'About' => 'A propos',
'Miniflux version:' => 'Version de Miniflux :',
'Nothing to read' => 'Rien à lire',
'%d unread items' => '%d éléments non lus',
'unread items' => 'éléments non lus',
'mark all as read' => 'tout marquer comme lu',
'original link' => 'lien original',
'mark as read' => 'marquer comme lu',

View File

@ -18,11 +18,21 @@
<nav>
<a class="logo" href="?">mini<span>flux</span></a>
<ul>
<li <?= isset($menu) && $menu === 'unread' ? 'class="active"' : '' ?>><a href="?action=default"><?= t('unread') ?></a></li>
<li <?= isset($menu) && $menu === 'history' ? 'class="active"' : '' ?>><a href="?action=history"><?= t('history') ?></a></li>
<li <?= isset($menu) && $menu === 'feeds' ? 'class="active"' : '' ?>><a href="?action=feeds"><?= t('subscriptions') ?></a></li>
<li <?= isset($menu) && $menu === 'config' ? 'class="active"' : '' ?>><a href="?action=config"><?= t('preferences') ?></a></li>
<li><a href="?action=logout"><?= t('logout') ?></a></li>
<li <?= isset($menu) && $menu === 'unread' ? 'class="active"' : '' ?>>
<a href="?action=default"><?= t('unread') ?> <span id="nav-counter"><?= isset($nb_items) ? '('.$nb_items.')' : '' ?></span></a>
</li>
<li <?= isset($menu) && $menu === 'history' ? 'class="active"' : '' ?>>
<a href="?action=history"><?= t('history') ?></a>
</li>
<li <?= isset($menu) && $menu === 'feeds' ? 'class="active"' : '' ?>>
<a href="?action=feeds"><?= t('subscriptions') ?></a>
</li>
<li <?= isset($menu) && $menu === 'config' ? 'class="active"' : '' ?>>
<a href="?action=config"><?= t('preferences') ?></a>
</li>
<li>
<a href="?action=logout"><?= t('logout') ?></a>
</li>
</ul>
</nav>
</header>

View File

@ -5,7 +5,7 @@
<?php else: ?>
<div class="page-header">
<h2> <?= t('<span id="unread-count">%d</span> unread items', $nb_items) ?></h2>
<h2><span id="page-counter"><?= isset($nb_items) ? $nb_items.' ' : '' ?></span><?= t('unread items') ?></h2>
<ul>
<li><a href="?action=mark-as-read"><?= t('mark all as read') ?></a></li>
</ul>