From 8a776f146182bc6870702cfeb87041e3af66b24b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 7 Sep 2016 14:35:51 +0200 Subject: Prevent a target _blank attacks with window.opener https://mathiasbynens.github.io/rel-noopener/ noopener is implied by noreferrer https://html.spec.whatwg.org/multipage/semantics.html#link-type-noreferrer The API for window.open() does not seem stable yet https://bugzilla.mozilla.org/show_bug.cgi?id=1267339 --- p/scripts/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 8980fe2f6..74631451a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -752,7 +752,7 @@ function init_stream(divStream) { }); divStream.on('click', '.flux .content a', function () { - $(this).attr('target', '_blank'); + $(this).attr('target', '_blank').attr('rel', 'noreferrer'); }); if (context.auto_mark_site) { -- cgit v1.2.3 From 7adcc0d29d54461222d57924d5d2875d639ca698 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 6 Oct 2016 19:07:54 +0200 Subject: FreshRSS custom event 'freshrss:load-more' https://github.com/FreshRSS/FreshRSS/issues/1278 --- p/scripts/main.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 74631451a..2ebd09bcb 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1021,6 +1021,9 @@ function focus_search() { $('#search').focus(); } +var freshrssLoadMoreEvent = document.createEvent('Event'); +freshrssLoadMoreEvent.initEvent('freshrss:load-more', true, true); + function init_load_more(box) { box_load_more = box; @@ -1030,6 +1033,8 @@ function init_load_more(box) { }); } + document.body.dispatchEvent(freshrssLoadMoreEvent); + var $next_link = $("#load_more"); if (!$next_link.length) { // no more article to load -- cgit v1.2.3 From 6bc37cef47b41821055fc9e2c1ecb0ffbcc5d0d3 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 8 Oct 2016 21:45:47 +0200 Subject: W3C resource-priorities have been abandonned https://github.com/FreshRSS/FreshRSS/issues/1222 --- app/Models/Feed.php | 2 +- lib/lib_rss.php | 7 +++---- p/scripts/main.js | 6 ------ 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'p/scripts/main.js') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f435620c8..21c1ef93d 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -309,7 +309,7 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = '1'; $mime = strtolower($enclosure->get_type()); if (strpos($mime, 'image/') === 0) { - $content .= '

'; + $content .= '

'; } elseif (strpos($mime, 'audio/') === 0) { $content .= '

💾

'; } elseif (strpos($mime, 'video/') === 0) { diff --git a/lib/lib_rss.php b/lib/lib_rss.php index a4cd8e782..b18512484 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -182,10 +182,9 @@ function customSimplePie() { 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless', 'sizes', 'srcset'))); $simplePie->add_attributes(array( - 'img' => array('lazyload' => '', 'postpone' => ''), //http://www.w3.org/TR/resource-priorities/ - 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), - 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), - 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), + 'audio' => array('preload' => 'none'), + 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), + 'video' => array('preload' => 'none'), )); $simplePie->set_url_replacements(array( 'a' => 'href', diff --git a/p/scripts/main.js b/p/scripts/main.js index 2ebd09bcb..3c0a36629 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1027,12 +1027,6 @@ freshrssLoadMoreEvent.initEvent('freshrss:load-more', true, true); function init_load_more(box) { box_load_more = box; - if (!context.does_lazyload) { - $('img[postpone], audio[postpone], iframe[postpone], video[postpone]').each(function () { - this.removeAttribute('postpone'); - }); - } - document.body.dispatchEvent(freshrssLoadMoreEvent); var $next_link = $("#load_more"); -- cgit v1.2.3 From 189692e6adea2acb098bae5bc9ce75844080d040 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 10 Oct 2016 21:57:33 +0200 Subject: Fix bug share https://github.com/FreshRSS/FreshRSS/issues/1289 Was using deprecated non-standard parameter in string.replace() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Firefox-specific_notes --- p/scripts/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 3c0a36629..d42704f7a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1153,10 +1153,10 @@ function init_share_observers() { $('.share.add').on('click', function(e) { var opt = $(this).siblings('select').find(':selected'); var row = $(this).parents('form').data(opt.data('form')); - row = row.replace('##label##', opt.html().trim(), 'g'); - row = row.replace('##type##', opt.val(), 'g'); - row = row.replace('##help##', opt.data('help'), 'g'); - row = row.replace('##key##', shares, 'g'); + row = row.replace(/##label##/g, opt.html().trim()); + row = row.replace(/##type##/g, opt.val()); + row = row.replace(/##help##/g, opt.data('help')); + row = row.replace(/##key##/g, shares); $(this).parents('.form-group').before(row); shares++; -- cgit v1.2.3 From b4298f498f8afb5c5ac0bfa65bb628cf47561a21 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:33:42 +0200 Subject: Scroll as read https://github.com/FreshRSS/FreshRSS/issues/1258 --- p/scripts/main.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index d42704f7a..b2bd994ad 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -116,21 +116,18 @@ function incUnreadsFeed(article, feed_id, nb) { var pending_entries = {}; function mark_read(active, only_not_read) { - if (active.length === 0 || + if (active.length === 0 || active.attr('id') == '' || (only_not_read === true && !active.hasClass("not_read"))) { return false; } - var url = active.find("a.read").attr("href"); - if (url === undefined) { - return false; - } - if (pending_entries[active.attr('id')]) { return false; } pending_entries[active.attr('id')] = true; + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + $.ajax({ type: 'POST', url: url, @@ -150,10 +147,11 @@ function mark_read(active, only_not_read) { } $r.find('.icon').replaceWith(data.icon); - var feed_url = active.find(".website>a").attr("href"), - feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); - - incUnreadsFeed(active, feed_id, inc); + var feed_url = active.find(".website>a").attr("href"); + if (feed_url) { + var feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); + incUnreadsFeed(active, feed_id, inc); + } faviconNbUnread(); delete pending_entries[active.attr('id')]; @@ -451,14 +449,9 @@ function auto_share(key) { } function inMarkViewport(flux, box_to_follow) { - var top = flux.offset().top; - var height = flux.height(), - begin = top + 3 * height / 4, - bot = Math.min(begin + 75, top + height), - windowTop = box_to_follow.scrollTop(), - windowBot = windowTop + box_to_follow.height() / 2; - - return (windowBot >= begin && bot >= windowBot); + var bottom = flux.offset().top + flux.height(), + windowTop = box_to_follow.scrollTop(); + return bottom < windowTop + 40; } function init_posts() { @@ -470,7 +463,7 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if ($(this).children(".flux_content").is(':visible') && inMarkViewport($(this), box_to_follow)) { + if (inMarkViewport($(this), box_to_follow)) { mark_read($(this), true); } }); -- cgit v1.2.3 From f766f34775c7162058b929b397ac7fd20dc885b2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:38:25 +0200 Subject: Scroll as read minor variable --- p/scripts/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index b2bd994ad..75d194906 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -463,8 +463,9 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if (inMarkViewport($(this), box_to_follow)) { - mark_read($(this), true); + var $this = $(this); + if (inMarkViewport($this, box_to_follow)) { + mark_read($this, true); } }); }); -- cgit v1.2.3 From 626d9cbccbd0a52c7ece4ffeaab9bd09f62a3761 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 14 Oct 2016 09:20:11 +0200 Subject: Scroll as read: mark as unread bug --- p/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 75d194906..b3531e884 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -126,7 +126,8 @@ function mark_read(active, only_not_read) { } pending_entries[active.attr('id')] = true; - var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, '') + + (active.hasClass('not_read') ? '' : '&is_read=0'); $.ajax({ type: 'POST', -- cgit v1.2.3 From ce14841cc05e500819c0cdb2c594be8b44e91e2d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 12:31:13 +0200 Subject: Scroll as read for Global view + throttle event https://github.com/FreshRSS/FreshRSS/issues/1317 https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index b3531e884..400abf947 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -449,26 +449,22 @@ function auto_share(key) { } } -function inMarkViewport(flux, box_to_follow) { - var bottom = flux.offset().top + flux.height(), - windowTop = box_to_follow.scrollTop(); - return bottom < windowTop + 40; -} - function init_posts() { - var box_to_follow = $(window); - if (context.current_view === 'global') { - box_to_follow = $("#panel"); - } + var box_to_follow = context.current_view === 'global' ? $("#panel") : $(window); if (context.auto_mark_scroll) { + var lastScroll = 0; //Throttle box_to_follow.scroll(function () { - $('.not_read:visible').each(function () { - var $this = $(this); - if (inMarkViewport($this, box_to_follow)) { - mark_read($this, true); - } - }); + if (lastScroll + 500 < Date.now()) { + lastScroll = Date.now(); + $('.not_read:visible').each(function () { + var $this = $(this), + minTop = (context.current_view === 'global') ? box_to_follow.offset().top : box_to_follow.scrollTop(); + if ($this.offset().top + $this.height() < minTop + 40) { + mark_read($this, true); + } + }); + } }); } -- cgit v1.2.3 From eb88fee64bccfacbb8b1f5d84ba833d3a8286aa0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 15:10:21 +0200 Subject: Scroll performance Fewer events, and ensure an event is fired after the end of the scroll. https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 400abf947..47d651d5b 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -449,21 +449,31 @@ function auto_share(key) { } } +function scrollAsRead(box_to_follow) { + var minTop = 40 + (context.current_view === 'global' ? box_to_follow.offset().top : box_to_follow.scrollTop()); + $('.not_read:visible').each(function () { + var $this = $(this); + if ($this.offset().top + $this.height() < minTop) { + mark_read($this, true); + } + }); +} + function init_posts() { var box_to_follow = context.current_view === 'global' ? $("#panel") : $(window); if (context.auto_mark_scroll) { - var lastScroll = 0; //Throttle + var lastScroll = 0, //Throttle + timerId = 0; box_to_follow.scroll(function () { + window.clearTimeout(timerId); if (lastScroll + 500 < Date.now()) { lastScroll = Date.now(); - $('.not_read:visible').each(function () { - var $this = $(this), - minTop = (context.current_view === 'global') ? box_to_follow.offset().top : box_to_follow.scrollTop(); - if ($this.offset().top + $this.height() < minTop + 40) { - mark_read($this, true); - } - }); + scrollAsRead(box_to_follow); + } else { + timerId = window.setTimeout(function() { + scrollAsRead(box_to_follow); + }, 500); } }); } -- cgit v1.2.3 From 3f78bad3970113f14b80db19808e2c58af8fb19e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 15:53:08 +0200 Subject: Scroll as read: keep unread function https://github.com/FreshRSS/FreshRSS/pull/1309 --- p/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 47d651d5b..138a223de 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -144,6 +144,7 @@ function mark_read(active, only_not_read) { inc--; } else if (only_not_read !== true || active.hasClass("not_read")) { active.addClass("not_read"); + active.addClass("keep_unread"); inc++; } $r.find('.icon').replaceWith(data.icon); @@ -451,7 +452,7 @@ function auto_share(key) { function scrollAsRead(box_to_follow) { var minTop = 40 + (context.current_view === 'global' ? box_to_follow.offset().top : box_to_follow.scrollTop()); - $('.not_read:visible').each(function () { + $('.not_read:not(.keep_unread):visible').each(function () { var $this = $(this); if ($this.offset().top + $this.height() < minTop) { mark_read($this, true); -- cgit v1.2.3 From 6cd38d73d0b41ea7cd4da1fe611d761d7d442f2b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 16 Oct 2016 16:10:58 +0200 Subject: mark_read optimisation --- p/scripts/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'p/scripts/main.js') diff --git a/p/scripts/main.js b/p/scripts/main.js index 138a223de..51323a969 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -116,8 +116,8 @@ function incUnreadsFeed(article, feed_id, nb) { var pending_entries = {}; function mark_read(active, only_not_read) { - if (active.length === 0 || active.attr('id') == '' || - (only_not_read === true && !active.hasClass("not_read"))) { + if ((active.length === 0) || (!active.attr('id')) || + (only_not_read && !active.hasClass("not_read"))) { return false; } @@ -142,7 +142,7 @@ function mark_read(active, only_not_read) { if (active.hasClass("not_read")) { active.removeClass("not_read"); inc--; - } else if (only_not_read !== true || active.hasClass("not_read")) { + } else { active.addClass("not_read"); active.addClass("keep_unread"); inc++; -- cgit v1.2.3 From 00f446d1557165cba90d0d3ec17404d3fdce84cd Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 29 Oct 2016 13:11:37 +0200 Subject: Disable "mark all as read" before confirmation script is loaded https://github.com/FreshRSS/FreshRSS/issues/1342 --- CHANGELOG.md | 1 + app/layout/aside_feed.phtml | 2 +- app/layout/nav_menu.phtml | 2 +- app/views/helpers/pagination.phtml | 2 +- p/scripts/main.js | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) (limited to 'p/scripts/main.js') diff --git a/CHANGELOG.md b/CHANGELOG.md index acec03f39..6873530f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * Fix some messages during installation [#1339](https://github.com/FreshRSS/FreshRSS/pull/1339) * UI * Fix CSS line-height bug with `` in dates (English, Russian, Turkish) [#1340](https://github.com/FreshRSS/FreshRSS/pull/1340) + * Disable *Mark all as read* before confirmation script is loaded [#1342](https://github.com/FreshRSS/FreshRSS/issues/1342) * Download icon 💾 for podcasts [#1236](https://github.com/FreshRSS/FreshRSS/issues/1236) * SimplePie * Fix auto-discovery of RSS feeds in Web pages served as `text/xml` [#1264](https://github.com/FreshRSS/FreshRSS/issues/1264) diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 94c281b7f..3e1ee44dd 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -85,7 +85,7 @@
  • - reading_confirm ? 'confirm' : ''; ?> + reading_confirm ? 'confirm" disabled="disabled' : ''; ?>