aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-22 14:15:51 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-03-22 14:15:51 +0100
commit48c2453f011b4cd7641d472144dea396d5a3b9fe (patch)
tree844cb2317ba93dae7447805a51b96e68d51b0f41
parentAdded a way to manage Content Security Policy via the configuration file. (diff)
downloadnewspipe-48c2453f011b4cd7641d472144dea396d5a3b9fe.tar.gz
newspipe-48c2453f011b4cd7641d472144dea396d5a3b9fe.tar.bz2
newspipe-48c2453f011b4cd7641d472144dea396d5a3b9fe.zip
Removed some inline scripts.
-rw-r--r--newspipe/static/js/articles.js34
-rw-r--r--newspipe/static/js/feed.js24
-rw-r--r--newspipe/templates/home.html12
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 @@
<a href="{{ url_for('article.mark_as', new_value='read') }}"><i class="fa fa-check-square-o" aria-hidden="true" title="{{ _('Mark all as read') }}"></i></a>
</span></li>
{% for fid, nbunread in unread|dictsort(by='value')|reverse %}
- <li class="nav-item feed-menu"><a class="nav-link" href="{{ gen_url(feed=fid) }}">
+ <li class="nav-item feed-menu" data-feed="{{ fid }}"><a class="nav-link" href="{{ gen_url(feed=fid) }}">
{% if feed_id == fid %}<b>{% endif %}
{% if in_error.get(fid, 0) > 0 %}
<span style="background-color: {{ "red" if in_error[fid] > 2 else "orange" }} ;" class="badge pull-right" title="Some errors occured while trying to retrieve that feed.">{{ in_error[fid] }}</span>
@@ -37,17 +37,17 @@
{{ feeds[fid].title | safe | truncate(25, True) }}
{% if feed_id == fid %}</b>{% endif %}
</a></li>
- <li class="nav-item feed-commands"><span class="nav-link">
+ <li class="nav-item feed-commands" data-feed="{{ fid }}"><span class="nav-link">
<a href="/feed/{{ fid }}"><i class="fa fa-info" aria-hidden="true" title="{{ _('Details') }}"></i></a>
<a href="{{ url_for('feed.form', feed_id=fid) }}"><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ _('Edit this feed') }}"></i></a>
<a href="{{ url_for('article.mark_as', new_value='unread', feed_id=fid) }}"><i class="fa fa-square-o" aria-hidden="true" title="{{ _('Mark this feed as unread') }}"></i></a>
<a href="{{ url_for('article.mark_as', new_value='read', feed_id=fid) }}"><i class="fa fa-check-square-o" aria-hidden="true" title="{{ _('Mark this feed as read') }}"></i></a>
- <a href="{{ url_for('feed.delete', feed_id=fid) }}"><i class="fa fa-times" aria-hidden="true" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
+ <a href="#"><i class="fa fa-times delete-feed" aria-hidden="true" title="{{ _('Delete this feed') }}"></i></a>
</span></li>
{% endfor %}
{% for fid, feed in feeds.items() if not fid in unread %}
- <li class="nav-item feed-menu"><a class="nav-link" href="{{ gen_url(feed=fid) }}">
+ <li class="nav-item feed-menu" data-feed="{{ fid }}"><a class="nav-link" href="{{ gen_url(feed=fid) }}">
{% if in_error.get(fid, 0) > 0 %}
<span style="background-color: {{ "red" if in_error[fid] > 2 else "orange" }} ;" class="badge pull-right" title="Some errors occured while trying to retrieve that feed.">{{ in_error[fid] }}</span>
{% endif %}
@@ -56,12 +56,12 @@
{{ feed.title | safe | truncate(25, True) }}
{% if feed_id == fid %}</b>{% endif %}
</a></li>
- <li class="nav-item feed-commands"><span class="nav-link">
+ <li class="nav-item feed-commands" data-feed="{{ fid }}"><span class="nav-link">
<a href="/feed/{{ fid }}"><i class="fa fa-info" aria-hidden="true" title="{{ _('Details') }}"></i></a>
<a href="{{ url_for('feed.form', feed_id=fid) }}"><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ _('Edit this feed') }}"></i></a>
<a href="{{ url_for('article.mark_as', new_value='unread', feed_id=fid) }}"><i class="fa fa-square-o" aria-hidden="true" title="{{ _('Mark this feed as unread') }}"></i></a>
<a href="{{ url_for('article.mark_as', new_value='read', feed_id=fid) }}"><i class="fa fa-check-square-o" aria-hidden="true" title="{{ _('Mark this feed as read') }}"></i></a>
- <a href="{{ url_for('feed.delete', feed_id=fid) }}"><i class="fa fa-times" aria-hidden="true" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
+ <a href="#"><i class="fa fa-times delete-feed" aria-hidden="true" title="{{ _('Delete this feed') }}"></i></a>
</span></li>
{% endfor %}
</ul>
bgstack15