From 4ca54cabc263d638aaf0acb74f08b3793a2b3145 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 10 Jul 2015 14:43:42 +0200 Subject: Minor fixes to the counter. --- pyaggr3g470r/static/js/articles.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyaggr3g470r/static/js/articles.js b/pyaggr3g470r/static/js/articles.js index 8bceb1b0..bdd33926 100644 --- a/pyaggr3g470r/static/js/articles.js +++ b/pyaggr3g470r/static/js/articles.js @@ -25,6 +25,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } function change_unread_counter(feed_id, increment) { var new_value = parseInt($("#unread-"+feed_id).text()) + increment; $("#unread-"+feed_id).text(new_value); + $("#total-unread").text(parseInt($("#total-unread").text()) + increment); if (new_value == 0) { $("#unread-"+feed_id).hide(); } else { @@ -57,7 +58,6 @@ function change_unread_counter(feed_id, increment) { }) if (filter == "read") { $(this).parent().parent().parent().remove(); - $("#total-unread").text(parseInt($("#total-unread").text()) - 1); } else { // here, filter == "all" @@ -133,6 +133,7 @@ function change_unread_counter(feed_id, increment) { // Delete an article $('.delete').on('click', function() { + var feed_id = $(this).parent().parent().parent().attr("data-feed"); var article_id = $(this).parent().parent().parent().attr("data-article"); $(this).parent().parent().parent().remove(); @@ -141,7 +142,7 @@ function change_unread_counter(feed_id, increment) { type: 'DELETE', url: API_ROOT + "article/" + article_id, success: function (result) { - //console.log(result); + change_unread_counter(feed_id, -1); }, error: function(XMLHttpRequest, textStatus, errorThrown){ console.log(XMLHttpRequest.responseText); -- cgit