From 7de72b41e449babc6bfd422afa13db0b630ab5ea Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 14 Jul 2013 13:01:45 -0400 Subject: [PATCH] Click on "mark as unread" use an ajax request now --- assets/js/app.js | 31 +++++++++++++++++++++---------- templates/history.php | 10 +++++++++- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 2f50e65..2b34bd3 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -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); diff --git a/templates/history.php b/templates/history.php index cf0b50e..c2d2dfb 100644 --- a/templates/history.php +++ b/templates/history.php @@ -25,13 +25,21 @@

| + | - | | + + + | + |