summaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Julien-Pierre Avérous <github@sourcemac.com> 2020-02-13 19:22:35 +0200
committerGravatar GitHub <noreply@github.com> 2020-02-13 18:22:35 +0100
commitd30ac40772ec1b4706922afd8acab8448af39a9e (patch)
tree6b7cec8455a542875959a09f7bdcc7a2af285fa1 /p/scripts
parent4ddd1821bb0fc1186937551d59100294b8833727 (diff)
Enhance content path feature (#2778)
- Add a maintenance section to be able to clear cache and force reload a feed. - Add an icon next to path field to show a pop-up with the result of the content path. Co-authored-by: Frans de Jonge <fransdejonge@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> Co-authored-by: Marien Fressinaud <dev@marienfressinaud.fr>
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/extra.js21
-rw-r--r--p/scripts/main.js67
-rw-r--r--p/scripts/preview.js43
3 files changed, 130 insertions, 1 deletions
diff --git a/p/scripts/extra.js b/p/scripts/extra.js
index 1fd8a19de..9ce0e74ce 100644
--- a/p/scripts/extra.js
+++ b/p/scripts/extra.js
@@ -1,8 +1,25 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
"use strict";
-/* globals context, openNotification, xmlHttpRequestJson */
+/* globals context, openNotification, openPopupWithSource, xmlHttpRequestJson */
/* jshint esversion:6, strict:global */
+function fix_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();
+ });
+}
+
//<crypto form (Web login)>
function poormanSalt() { //If crypto.getRandomValues is not available
const base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789/abcdefghijklmnopqrstuvwxyz';
@@ -176,6 +193,7 @@ function init_slider_observers() {
slider.classList.add('active');
closer.classList.add('active');
context.ajax_loading = false;
+ fix_popup_preview_selector();
};
req.send();
return false;
@@ -240,6 +258,7 @@ function init_extra() {
init_select_observers();
init_slider_observers();
init_configuration_alert();
+ fix_popup_preview_selector();
}
if (document.readyState && document.readyState !== 'loading') {
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 9ebc4c247..6b4b0a6b2 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1215,6 +1215,72 @@ function init_notifications() {
}
// </notification>
+// <popup>
+let popup = null,
+ popup_iframe_container = null,
+ popup_iframe = null,
+ popup_txt = null,
+ popup_working = false;
+
+function openPopupWithMessage(msg) {
+ if (popup_working === true) {
+ return false;
+ }
+
+ popup_working = true;
+
+ popup_txt.innerHTML = msg;
+
+ popup_txt.style.display = 'table-row';
+ popup.style.display = 'block';
+}
+
+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_txt.style.display = 'none';
+
+ popup_iframe.src = 'about:blank';
+
+ popup_working = false;
+}
+
+function init_popup() {
+ //Fetch elements.
+ popup = document.getElementById('popup');
+
+ popup_iframe_container = document.getElementById('popup-iframe-container');
+ popup_iframe = document.getElementById('popup-iframe');
+
+ popup_txt = document.getElementById('popup-txt');
+
+ //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();
+ }
+ });
+}
+// </popup>
+
// <notifs html5>
var notifs_html5_permission = 'denied';
@@ -1483,6 +1549,7 @@ function init_beforeDOM() {
function init_afterDOM() {
init_notifications();
+ init_popup();
init_confirm_action();
const stream = document.getElementById('stream');
if (stream) {
diff --git a/p/scripts/preview.js b/p/scripts/preview.js
new file mode 100644
index 000000000..d52657a5a
--- /dev/null
+++ b/p/scripts/preview.js
@@ -0,0 +1,43 @@
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
+"use strict";
+/* jshint esversion:6, strict:global */
+
+let rendered_node = null,
+ rendered_view = null,
+ raw_node = null,
+ raw_view = null;
+
+
+function update_ui() {
+ if (rendered_node.checked && !raw_node.checked) {
+ rendered_view.removeAttribute('hidden');
+ raw_view.setAttribute('hidden', true);
+ } else if (!rendered_node.checked && raw_node.checked) {
+ rendered_view.setAttribute('hidden', true);
+ raw_view.removeAttribute('hidden');
+ }
+}
+
+function init_afterDOM() {
+ rendered_node = document.getElementById('freshrss_rendered');
+ rendered_view = document.getElementById('freshrss_rendered_view');
+
+ raw_node = document.getElementById('freshrss_raw');
+ raw_view = document.getElementById('freshrss_raw_view');
+
+ rendered_node.addEventListener('click', update_ui);
+ raw_node.addEventListener('click', update_ui);
+}
+
+
+if (document.readyState && document.readyState !== 'loading') {
+ init_afterDOM();
+} else {
+ document.addEventListener('DOMContentLoaded', function () {
+ if (window.console) {
+ console.log('FreshRSS waiting for DOMContentLoaded…');
+ }
+ init_afterDOM();
+ }, false);
+}
+// @license-end