|
|
@@ -110,6 +110,28 @@ function init_select_show(parent) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function init_json_feed_detection(parent) {
|
|
|
+ const url = parent.querySelector('#url_rss');
|
|
|
+ const kind = parent.querySelector('#feed_kind');
|
|
|
+ if (!url || !kind) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const jsonKind = kind.querySelector('option[data-json-feed="1"]');
|
|
|
+ const details = kind.closest('details');
|
|
|
+ const detect = () => {
|
|
|
+ if (kind.value === kind.options[0]?.value && jsonKind && /(?:\b|_)json(?:\b|_)/i.test(url.value)) {
|
|
|
+ kind.value = jsonKind.value;
|
|
|
+ kind.dispatchEvent(new Event('change', { bubbles: true }));
|
|
|
+ if (details) {
|
|
|
+ details.open = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ url.addEventListener('input', detect);
|
|
|
+ detect();
|
|
|
+}
|
|
|
+
|
|
|
/** Automatically validate XPath textarea fields */
|
|
|
function init_valid_xpath(parent) {
|
|
|
const listener = (textarea) => {
|
|
|
@@ -157,6 +179,7 @@ function init_feed_afterDOM() {
|
|
|
init_popup();
|
|
|
init_popup_preview_selector();
|
|
|
init_select_show(document.body);
|
|
|
+ init_json_feed_detection(document.body);
|
|
|
init_disable_elements_on_update(document.body);
|
|
|
init_password_observers(document.body);
|
|
|
init_valid_xpath(document.body);
|