This commit is contained in:
Frederic Guillot 2013-07-17 18:03:35 -04:00
commit 2424688cbd
3 changed files with 38 additions and 1 deletions

View File

@ -27,6 +27,25 @@
request.send();
}
function mark_all_as_read()
{
var $articles = document.getElementsByTagName("article");
var idlist = [];
for (var i=0;i<$articles.length;i++)
{
idlist.push($articles[i].getAttribute("data-item-id"));
}
var request = new XMLHttpRequest();
request.onload = function() {
window.location.href = "?action=unread";
};
request.open("POST", "?action=mark-all-read", true);
request.send(JSON.stringify(idlist));
}
function mark_as_read(item_id)
{
@ -415,6 +434,10 @@
var item_id = e.target.getAttribute("data-item-id");
mark_as_unread(item_id);
break;
case 'mark-all-read':
e.preventDefault();
mark_all_as_read();
break;
case 'original-link':
var item_id = e.target.getAttribute("data-item-id");
mark_as_read(item_id);

View File

@ -332,6 +332,16 @@ Router\get_action('mark-as-read', function() {
Response\redirect('?action=unread');
});
Router\post_action('mark-all-read', function(){
$values = Request\values();
foreach($values as $value) {
$id = Model\decode_item_id($value);
Model\set_item_read($id);
}
Response\json(array('OK'));
});
// Confirmation box to flush history
Router\get_action('confirm-flush-history', function() {

View File

@ -7,7 +7,11 @@
<div class="page-header">
<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>
<li>
<a href="?action=mark-as-read" data-action="mark-all-read">
<?= t('mark all as read') ?>
</a>
</li>
</ul>
</div>