From 3c584376ca24e4bc5220c8dac4f1e238a245e7fe Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 07:59:11 +0300 Subject: [PATCH] shared opml and feed dialogs: remove unique target element id, move associated methods into dialog --- js/CommonDialogs.js | 91 +++++++++++++++++++++++++++++---------------- js/PrefHelpers.js | 25 ------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index e6b1822c2..60c3e2a84 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -369,35 +369,6 @@ const CommonDialogs = { dialog.show(); }, - genUrlChangeKey: function(feed, is_cat) { - if (confirm(__("Generate new syndication address for this feed?"))) { - - Notify.progress("Trying to change address...", true); - - const query = {op: "pref-feeds", method: "regenFeedKey", id: feed, is_cat: is_cat}; - - xhrJson("backend.php", query, (reply) => { - const new_link = reply.link; - const e = $('gen_feed_url'); - - if (new_link) { - e.innerHTML = e.innerHTML.replace(/&key=.*$/, - "&key=" + new_link); - - e.href = e.href.replace(/&key=.*$/, - "&key=" + new_link); - - new Effect.Highlight(e); - - Notify.close(); - - } else { - Notify.error("Could not change feed URL."); - } - }); - } - return false; - }, publishedOPML: function() { Notify.progress("Loading, please wait...", true); @@ -406,15 +377,40 @@ const CommonDialogs = { try { const dialog = new fox.SingleUseDialog({ title: __("Public OPML URL"), + regenOPMLKey: function() { + if (confirm(__("Replace current OPML publishing address with a new one?"))) { + Notify.progress("Trying to change address...", true); + + xhrJson("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => { + if (reply) { + const new_link = reply.link; + const target = this.domNode.querySelector('.generated_url'); + + if (new_link && target) { + target.href = new_link; + target.innerHTML = new_link; + + new Effect.Highlight(target); + + Notify.close(); + + } else { + Notify.error("Could not change feed URL."); + } + } + }); + } + return false; + }, content: `
${__("Your Public OPML URL is:")}