Click on "mark as unread" use an ajax request now

This commit is contained in:
Frederic Guillot 2013-07-14 13:01:45 -04:00
parent b5a5afba37
commit 7de72b41e4
2 changed files with 30 additions and 11 deletions

View File

@ -34,7 +34,7 @@
request.onload = function() {
find_next_item();
//find_next_item();
remove_item(item_id);
};
@ -46,6 +46,13 @@
function mark_as_unread(item_id)
{
var request = new XMLHttpRequest();
request.onload = function() {
//find_next_item();
remove_item(item_id);
};
request.open("POST", "?action=mark-item-unread&id=" + item_id, true);
request.send();
}
@ -82,20 +89,13 @@
function hide_refresh_icon(feed_id)
{
var container = document.getElementById("loading-feed-" + feed_id);
if (container) {
container.innerHTML = "";
}
if (container) container.innerHTML = "";
}
function refresh_feed(feed_id, callback)
{
if (! feed_id) {
return false;
}
if (! feed_id) return false;
show_refresh_icon(feed_id);
@ -194,6 +194,12 @@
{
var item = document.getElementById("item-" + item_id);
if (! item) {
item = document.getElementById("current-item");
if (item.getAttribute("data-item-id") != item_id) item = false;
}
if (item) {
item.parentNode.removeChild(item);
@ -404,6 +410,11 @@
var item_id = e.target.getAttribute("data-item-id");
mark_as_read(item_id);
break;
case 'mark-unread':
e.preventDefault();
var item_id = e.target.getAttribute("data-item-id");
mark_as_unread(item_id);
break;
case 'original-link':
var item_id = e.target.getAttribute("data-item-id");
mark_as_read(item_id);

View File

@ -25,13 +25,21 @@
</h2>
<p>
<?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> |
<a href="?action=mark-item-unread&amp;id=<?= $item_id ?>&amp;offset=<?= $offset ?>"><?= t('mark as unread') ?></a> |
<?php if (! $item['bookmark']): ?>
<a id="bookmark-<?= $item_id ?>" href="?action=bookmark&amp;value=1&amp;id=<?= $item_id ?>&amp;redirect=history&amp;offset=<?= $offset ?>"><?= t('bookmark') ?></a> |
<?php endif ?>
<a
href="?action=mark-item-unread&amp;id=<?= $item_id ?>&amp;offset=<?= $offset ?>"
data-action="mark-unread"
data-item-id="<?= $item_id ?>"
>
<?= t('mark as unread') ?>
</a> |
<a href="?action=mark-item-removed&amp;id=<?= $item_id ?>&amp;offset=<?= $offset ?>"><?= t('remove') ?></a> |
<a
href="<?= $item['url'] ?>"