From 807ea755e0bddb814f5c55bdfa5321ce144fe816 Mon Sep 17 00:00:00 2001 From: maTh Date: Sun, 15 May 2022 21:52:52 +0200 Subject: fix preview (#4291) * fix * Update extra.js * reorga the scripts * Update extra.js * Several fixes https://github.com/FreshRSS/FreshRSS/pull/4291#issuecomment-1125472321 * More fixes * Cleaning * fix pr 4291 * Reorganise some script functions * Remove unused popup-txt And associated function openPopupWithMessage * Fix archiving categories https://github.com/FreshRSS/FreshRSS/pull/4291#issuecomment-1126924602 * Fix stats https://github.com/FreshRSS/FreshRSS/pull/4291#issuecomment-1126983134 * Fix direct subscription E.g. http://localhost/i/?c=subscription&id=735 * Fix subscription add https://github.com/FreshRSS/FreshRSS/pull/4291#issuecomment-1126991621 Co-authored-by: Alexandre Alapetite --- p/scripts/feed.js | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 p/scripts/feed.js (limited to 'p/scripts/feed.js') diff --git a/p/scripts/feed.js b/p/scripts/feed.js new file mode 100644 index 000000000..b206b79d4 --- /dev/null +++ b/p/scripts/feed.js @@ -0,0 +1,153 @@ +// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 +'use strict'; +/* globals init_archiving, init_password_observers, init_slider */ + +// +let popup = null; +let popup_iframe_container = null; +let popup_iframe = null; +let popup_working = false; + +function openPopupWithSource(source) { + if (popup_working === true) { + return false; + } + popup_working = true; + popup_iframe.src = source; + popup_iframe_container.style.display = 'table-row'; + popup.style.display = 'block'; +} + +function closePopup() { + popup.style.display = 'none'; + popup_iframe_container.style.display = 'none'; + popup_iframe.src = 'about:blank'; + popup_working = false; +} + +function init_popup() { + // Fetch elements. + popup = document.getElementById('popup'); + if (popup) { + popup_iframe_container = document.getElementById('popup-iframe-container'); + popup_iframe = document.getElementById('popup-iframe'); + + // Configure close button. + document.getElementById('popup-close').addEventListener('click', function (ev) { + closePopup(); + }); + + // Configure close-on-click. + window.addEventListener('click', function (ev) { + if (ev.target == popup) { + closePopup(); + } + }); + } +} +// + +function init_popup_preview_selector() { + const link = document.getElementById('popup-preview-selector'); + + if (!link) { + return; + } + + link.addEventListener('click', function (ev) { + const selector_entries = document.getElementById('path_entries').value; + const href = link.href.replace('selector-token', encodeURIComponent(selector_entries)); + + openPopupWithSource(href); + + ev.preventDefault(); + }); +} + +/** + * Allow a