From 48c2453f011b4cd7641d472144dea396d5a3b9fe Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 22 Mar 2020 14:15:51 +0100 Subject: Removed some inline scripts. --- newspipe/static/js/articles.js | 34 +++++++++++++++++++--------------- newspipe/static/js/feed.js | 24 ++++++++++++++++++++++++ newspipe/templates/home.html | 12 ++++++------ 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/newspipe/static/js/articles.js b/newspipe/static/js/articles.js index 1aeed787..7e2a477d 100644 --- a/newspipe/static/js/articles.js +++ b/newspipe/static/js/articles.js @@ -139,21 +139,25 @@ function change_unread_counter(feed_id, increment) { // Delete an article $('.delete').on('click', function() { - var feed_id = $(this).parent().parent().parent().attr("data-feed"); - var article_id = $(this).parent().parent().parent().attr("data-article"); - $(this).parent().parent().parent().remove(); - - // sends the updates to the server - $.ajax({ - type: 'DELETE', - url: API_ROOT + "article/" + article_id, - success: function (result) { - change_unread_counter(feed_id, -1); - }, - error: function(XMLHttpRequest, textStatus, errorThrown){ - console.log(XMLHttpRequest.responseText); - } - }); + var r = confirm('You are going to delete this article.'); + + if (r == true) { + var feed_id = $(this).parent().parent().parent().attr("data-feed"); + var article_id = $(this).parent().parent().parent().attr("data-article"); + $(this).parent().parent().parent().remove(); + + // sends the updates to the server + $.ajax({ + type: 'DELETE', + url: API_ROOT + "article/" + article_id, + success: function (result) { + change_unread_counter(feed_id, -1); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + console.log(XMLHttpRequest.responseText); + } + }); + } }); diff --git a/newspipe/static/js/feed.js b/newspipe/static/js/feed.js index ceef58fc..ab024496 100644 --- a/newspipe/static/js/feed.js +++ b/newspipe/static/js/feed.js @@ -20,3 +20,27 @@ $('.container').on('click', '#add-feed-filter-row', function() { $('.container').on('click', '.del-feed-filter-row', function() { $(this).parent().remove(); }); + + +// Delete a feed +$('.delete-feed').on('click', function() { + var r = confirm('You are going to delete this feed.'); + + if (r == true) { + var feed_id = $(this).parent().parent().parent().attr("data-feed"); + $(this).parent().parent().parent().remove(); + $('.feed-menu[data-feed='+feed_id+']').remove(); + + // sends the updates to the server + $.ajax({ + type: 'DELETE', + url: API_ROOT + "feed/" + feed_id, + success: function (result) { + // change_unread_counter(feed_id, -1); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + console.log(XMLHttpRequest.responseText); + } + }); + } +}); diff --git a/newspipe/templates/home.html b/newspipe/templates/home.html index 03d71cfb..c7340f63 100644 --- a/newspipe/templates/home.html +++ b/newspipe/templates/home.html @@ -27,7 +27,7 @@ {% for fid, nbunread in unread|dictsort(by='value')|reverse %} - - {% endfor %} {% for fid, feed in feeds.items() if not fid in unread %} - - {% endfor %} -- cgit