diff options
author | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2015-07-02 18:56:27 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel+bitbucket@gmail.com> | 2015-07-02 18:56:27 +0200 |
commit | b43010d2da88d91e8934ba7214a823453cbf6031 (patch) | |
tree | 6e8e1fd8d45832a59f8ec37e2009cc68069f2375 /pyaggr3g470r/static/js | |
parent | Display a picto when a feed is disabled due to errors when retrieving. (diff) | |
parent | using conf.DEFAULT_MAX_ERROR in feed template (diff) | |
download | newspipe-b43010d2da88d91e8934ba7214a823453cbf6031.tar.gz newspipe-b43010d2da88d91e8934ba7214a823453cbf6031.tar.bz2 newspipe-b43010d2da88d91e8934ba7214a823453cbf6031.zip |
Merged in jaesivsm/pyaggr3g470r (pull request #14)
Master
Diffstat (limited to 'pyaggr3g470r/static/js')
-rw-r--r-- | pyaggr3g470r/static/js/articles.js | 50 | ||||
-rw-r--r-- | pyaggr3g470r/static/js/feed.js | 22 |
2 files changed, 39 insertions, 33 deletions
diff --git a/pyaggr3g470r/static/js/articles.js b/pyaggr3g470r/static/js/articles.js index bb31f6d8..8bceb1b0 100644 --- a/pyaggr3g470r/static/js/articles.js +++ b/pyaggr3g470r/static/js/articles.js @@ -22,6 +22,16 @@ API_ROOT = '/api/v2.0/' 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); + if (new_value == 0) { + $("#unread-"+feed_id).hide(); + } else { + $("#unread-"+feed_id).show(); + } +} + +function ($) { // Mark an article as read when it is opened in a new table @@ -30,17 +40,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } var filter = $('#filters').attr("data-filter"); if (filter == "unread") { $(this).parent().parent().remove(); - $("#total-unread").text(parseInt($("#total-unread").text()) - 1); - if (parseInt($("#unread-"+feed_id).text()) == 1) { - $("#unread-"+feed_id).remove(); - } else { - $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) - 1); - } + change_unread_counter(feed_id, -1); } }); - - // Mark an article as read or unread. $('.readed').on('click', function() { var article_id = $(this).parent().parent().parent().attr("data-article"); @@ -55,38 +58,25 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } if (filter == "read") { $(this).parent().parent().parent().remove(); $("#total-unread").text(parseInt($("#total-unread").text()) - 1); - $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) + 1); } else { // here, filter == "all" $(this).parent().parent().parent().children("td:nth-child(2)").css( "font-weight", "bold" ); $(this).removeClass('glyphicon-unchecked').addClass('glyphicon-check'); - $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) + 1); } + change_unread_counter(feed_id, 1); } else { - data = JSON.stringify({ - readed: true - }) + data = JSON.stringify({readed: true}) if (filter == "unread") { $(this).parent().parent().parent().remove(); - $("#total-unread").text(parseInt($("#total-unread").text()) - 1); - if (parseInt($("#unread-"+feed_id).text()) == 1) { - $("#unread-"+feed_id).remove(); - } else { - $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) - 1); - } } else { // here, filter == "all" $(this).parent().parent().parent().children("td:nth-child(2)").css( "font-weight", "normal" ); $(this).removeClass('glyphicon-check').addClass('glyphicon-unchecked'); - if (parseInt($("#unread-"+feed_id).text()) == 1) { - $("#unread-"+feed_id).remove(); - } else { - $("#unread-"+feed_id).text(parseInt($("#unread-"+feed_id).text()) - 1); - } } + change_unread_counter(feed_id, -1); } // sends the updates to the server @@ -115,15 +105,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } var data; if ($(this).hasClass("glyphicon-star")) { - data = JSON.stringify({ - like: false - }) - $(this).removeClass('glyphicon-star').addClass('glyphicon-star-empty'); + data = JSON.stringify({like: false}) + $(this).removeClass('glyphicon-star').addClass('glyphicon-star-empty'); } else { - data = JSON.stringify({ - like: true - }) + data = JSON.stringify({like: true}) $(this).removeClass('glyphicon-star-empty').addClass('glyphicon-star'); } @@ -163,8 +149,6 @@ if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } }); }); - - // Delete all duplicate articles (used in the page /duplicates) $('.delete-all').click(function(){ var data = []; diff --git a/pyaggr3g470r/static/js/feed.js b/pyaggr3g470r/static/js/feed.js new file mode 100644 index 00000000..b1e3110e --- /dev/null +++ b/pyaggr3g470r/static/js/feed.js @@ -0,0 +1,22 @@ +$('.container').on('click', '#add-feed-filter-row', function() { + $('#filters-container').append( + '<div class="col-sm-9">' + + ' <input value="-" type="button" class="del-feed-filter-row" />' + + ' <select name="type">' + + ' <option value="simple match" selected>simple match</option>' + + ' <option value="regex">regex</option>' + + ' </select/>' + + ' <input type="text" size="50%" name="pattern" />' + + ' <select name="action_on">' + + ' <option value="match" selected>match</option>' + + ' <option value="no match">no match</option>' + + ' </select/>' + + ' <select name="action">' + + ' <option value="mark as read" selected>mark as read</option>' + + ' <option value="mark as favorite">mark as favorite</option>' + + ' </select/>' + + '</div>'); +}); +$('.container').on('click', '.del-feed-filter-row', function() { + $(this).parent().remove(); +}); |