Only mark as read items displayed on the page
This commit is contained in:
parent
7de72b41e4
commit
66a27f5866
@ -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);
|
||||
|
10
index.php
10
index.php
@ -331,6 +331,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() {
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user