diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-06-29 11:59:45 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-06-29 11:59:45 +0200 |
commit | 2eb4aadf4c1437416327896453fa4ad6ea0fbd40 (patch) | |
tree | 1d5194a284bf710f6c7b64be4955eb4d00b259bf /pyaggr3g470r/static/js | |
parent | Mark an article as read or unread via the REST API. (diff) | |
download | newspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.tar.gz newspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.tar.bz2 newspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.zip |
Improved read/unread JS function.
Diffstat (limited to 'pyaggr3g470r/static/js')
-rw-r--r-- | pyaggr3g470r/static/js/articles.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/pyaggr3g470r/static/js/articles.js b/pyaggr3g470r/static/js/articles.js index e62ca360..990f293c 100644 --- a/pyaggr3g470r/static/js/articles.js +++ b/pyaggr3g470r/static/js/articles.js @@ -25,19 +25,32 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } // Mark an article as read or unread. $('.readed').on('click', function() { var article_id = $(this).parent().parent().parent().attr("data-article"); + var filter = $('#filters').attr("data-filter"); var data; if ($(this).hasClass("glyphicon-unchecked")) { data = JSON.stringify({ readed: false }) + if (filter == "read") { + $(this).parent().parent().parent().remove(); + } + else { + // here, filter == "all" $(this).removeClass('glyphicon-unchecked').addClass('glyphicon-check'); + } } else { data = JSON.stringify({ readed: true }) - $(this).removeClass('glyphicon-check').addClass('glyphicon-unchecked'); + if (filter == "unread") { + $(this).parent().parent().parent().remove(); + } + else { + // here, filter == "all" + $(this).removeClass('glyphicon-check').addClass('glyphicon-unchecked'); + } } // sends the updates to the server @@ -57,7 +70,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } } }); }); - + // Like or unlike an article $('.like').on('click', function() { var article_id = $(this).parent().parent().parent().attr("data-article"); |