aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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