aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-29 11:59:45 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-29 11:59:45 +0200
commit2eb4aadf4c1437416327896453fa4ad6ea0fbd40 (patch)
tree1d5194a284bf710f6c7b64be4955eb4d00b259bf
parentMark an article as read or unread via the REST API. (diff)
downloadnewspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.tar.gz
newspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.tar.bz2
newspipe-2eb4aadf4c1437416327896453fa4ad6ea0fbd40.zip
Improved read/unread JS function.
-rw-r--r--pyaggr3g470r/static/js/articles.js17
-rw-r--r--pyaggr3g470r/templates/home.html2
2 files changed, 16 insertions, 3 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");
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index 4f691a50..2a9fac48 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -51,7 +51,7 @@
</div>
<div class="container col-md-9">
<h1>{{ _('Articles') }} ({{ articles.__len__() }})</h1>
- <div>
+ <div id="filters" data-filter="{{ filter_ }}">
{% if filter_ == 'all' %}<b>{% endif %}
<a href="{{ gen_url(filter_='all') }}">{{ _('All') }}</a>
{% if filter_ == 'all' %}</b>{% endif %}
bgstack15