aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/static/js/articles.js
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-07-02 18:56:27 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-07-02 18:56:27 +0200
commitb43010d2da88d91e8934ba7214a823453cbf6031 (patch)
tree6e8e1fd8d45832a59f8ec37e2009cc68069f2375 /pyaggr3g470r/static/js/articles.js
parentDisplay a picto when a feed is disabled due to errors when retrieving. (diff)
parentusing conf.DEFAULT_MAX_ERROR in feed template (diff)
downloadnewspipe-b43010d2da88d91e8934ba7214a823453cbf6031.tar.gz
newspipe-b43010d2da88d91e8934ba7214a823453cbf6031.tar.bz2
newspipe-b43010d2da88d91e8934ba7214a823453cbf6031.zip
Merged in jaesivsm/pyaggr3g470r (pull request #14)
Master
Diffstat (limited to 'pyaggr3g470r/static/js/articles.js')
-rw-r--r--pyaggr3g470r/static/js/articles.js50
1 files changed, 17 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 = [];
bgstack15