diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/CommonDialogs.js | 102 | ||||
-rwxr-xr-x | js/Headlines.js | 65 | ||||
-rw-r--r-- | js/PrefHelpers.js | 25 |
3 files changed, 123 insertions, 69 deletions
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 5a72f705b..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: ` <header>${__("Your Public OPML URL is:")}</header> <section> <div class='panel text-center'> - <a id='pub_opml_url' href="${App.escapeHtml(reply.link)}" target='_blank'>${reply.link}</a> + <a class='generated_url' href="${App.escapeHtml(reply.link)}" target='_blank'>${App.escapeHtml(reply.link)}</a> </div> </section> <footer class='text-center'> - <button dojoType='dijit.form.Button' onclick="return Helpers.OPML.changeKey()"> + <button dojoType='dijit.form.Button' onclick="return App.dialogOf(this).regenOPMLKey()"> ${__('Generate new URL')} </button> <button dojoType='dijit.form.Button' type='submit' class='alt-primary'> @@ -433,31 +429,55 @@ const CommonDialogs = { } }); }, - generatedFeed: function(feed, is_cat, rss_url, feed_title) { + generatedFeed: function(feed, is_cat, search = "") { Notify.progress("Loading, please wait...", true); - xhrJson("backend.php", {op: "pref-feeds", method: "getFeedKey", id: feed, is_cat: is_cat}, (reply) => { + xhrJson("backend.php", {op: "pref-feeds", method: "getsharedurl", id: feed, is_cat: is_cat, search: search}, (reply) => { try { - if (!feed_title && typeof Feeds != "undefined") - feed_title = Feeds.getName(feed, is_cat); - - const secret_url = rss_url + "&key=" + encodeURIComponent(reply.link); - const dialog = new fox.SingleUseDialog({ title: __("Show as feed"), + regenFeedKey: 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 target = this.domNode.querySelector(".generated_url"); + + if (new_link && target) { + target.innerHTML = target.innerHTML.replace(/&key=.*$/, + "&key=" + new_link); + + target.href = target.href.replace(/&key=.*$/, + "&key=" + new_link); + + new Effect.Highlight(target); + + Notify.close(); + + } else { + Notify.error("Could not change feed URL."); + } + }); + } + return false; + }, content: ` - <header>${__("%s can be accessed via the following secret URL:").replace("%s", feed_title)}</header> + <header>${__("%s can be accessed via the following secret URL:").replace("%s", App.escapeHtml(reply.title))}</header> <section> <div class='panel text-center'> - <a id='gen_feed_url' href="${App.escapeHtml(secret_url)}" target='_blank'>${secret_url}</a> + <a class='generated_url' href="${App.escapeHtml(reply.link)}" target='_blank'>${App.escapeHtml(reply.link)}</a> </div> </section> <footer> <button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open("https://tt-rss.org/wiki/GeneratedFeeds")'> <i class='material-icons'>help</i> ${__("More info...")}</button> - <button dojoType='dijit.form.Button' onclick="return CommonDialogs.genUrlChangeKey('${feed}', '${is_cat}')"> + <button dojoType='dijit.form.Button' onclick="return App.dialogOf(this).regenFeedKey('${feed}', '${is_cat}')"> ${__('Generate new URL')} </button> <button dojoType='dijit.form.Button' class='alt-primary' type='submit'> diff --git a/js/Headlines.js b/js/Headlines.js index ea4c81a6a..94541b974 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -566,6 +566,62 @@ const Headlines = { } } }, + renderToolbar: function(headlines) { + + const tb = headlines['toolbar']; + const search_query = Feeds._search_query ? Feeds._search_query.query : ""; + const target = dijit.byId('toolbar-headlines'); + + if (tb && typeof tb == 'object') { + target.attr('innerHTML', + ` + <span class='left'> + <a href="#" title="${__("Show as feed")}" + onclick='CommonDialogs.generatedFeed("${headlines.id}", ${headlines.is_cat}, "${App.escapeHtml(search_query)}")'> + <i class='icon-syndicate material-icons'>rss_feed</i> + </a> + ${tb.site_url ? + `<a class="feed_title" target="_blank" href="${App.escapeHtml(tb.site_url)}" title="${tb.last_updated}">${tb.title}</a>` : + `<span class="feed_title">${tb.title}</span>`} + ${search_query ? + ` + <span class='cancel_search'>(<a href='#' onclick='Feeds.cancelSearch()'>${__("Cancel search")}</a>)</span> + ` : ''} + ${tb.error ? `<i title="${App.escapeHtml(tb.error)}" class='material-icons icon-error'>error</i>` : ''} + <span id='feed_current_unread' style='display: none'></span> + </span> + <span class='right'> + <span id='selected_prompt'></span> + <div dojoType='fox.form.DropDownButton' title='"${__('Select articles')}'> + <span>${__("Select...")}</span> + <div dojoType='dijit.Menu' style='display: none;'> + <div dojoType='dijit.MenuItem' onclick='Headlines.select("all")'>${__('All')}</div> + <div dojoType='dijit.MenuItem' onclick='Headlines.select("unread")'>${__('Unread')}</div> + <div dojoType='dijit.MenuItem' onclick='Headlines.select("invert")'>${__('Invert')}</div> + <div dojoType='dijit.MenuItem' onclick='Headlines.select("none")'>${__('None')}</div> + <div dojoType='dijit.MenuSeparator'></div> + <div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleUnread()'>${__('Toggle unread')}</div> + <div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleMarked()'>${__('Toggle starred')}</div> + <div dojoType='dijit.MenuItem' onclick='Headlines.selectionTogglePublished()'>${__('Toggle published')}</div> + <div dojoType='dijit.MenuSeparator'></div> + <div dojoType='dijit.MenuItem' onclick='Headlines.catchupSelection()'>${__('Mark as read')}</div> + <div dojoType='dijit.MenuItem' onclick='Article.selectionSetScore()'>${__('Set score')}</div> + ${tb.plugin_menu_items} + ${headlines.id === 0 && !headlines.is_cat ? + ` + <div dojoType='dijit.MenuSeparator'></div> + <div dojoType='dijit.MenuItem' class='text-error' onclick='Headlines.deleteSelection()'>${__('Delete permanently')}</div> + ` : ''} + </div> + ${tb.plugin_buttons} + </span> + `); + } else { + target.attr('innerHTML', ''); + } + + dojo.parser.parse(target.domNode); + }, onLoaded: function (transport, offset, append) { const reply = App.handleRpcJson(transport); @@ -613,9 +669,11 @@ const Headlines = { this.headlines = []; this.vgroup_last_feed = undefined; - dojo.html.set($("toolbar-headlines"), + /*dojo.html.set($("toolbar-headlines"), reply['headlines']['toolbar'], - {parseContent: true}); + {parseContent: true});*/ + + Headlines.renderToolbar(reply['headlines']); if (typeof reply['headlines']['content'] == 'string') { $("headlines-frame").innerHTML = reply['headlines']['content']; @@ -646,11 +704,12 @@ const Headlines = { hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + __("Click to open next unread feed.") + "</a>"; + /* if (Feeds._search_query) { $("feed_title").innerHTML += "<span id='cancel_search'>" + " (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" + "</span>"; - } + } */ Headlines.updateCurrentUnread(); diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 7a3d38d02..f7eca59a0 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -291,30 +291,5 @@ const Helpers = { console.log("export"); window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm")); }, - changeKey: 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 e = $('pub_opml_url'); - - if (new_link) { - e.href = new_link; - e.innerHTML = new_link; - - new Effect.Highlight(e); - - Notify.close(); - - } else { - Notify.error("Could not change feed URL."); - } - } - }); - } - return false; - }, } }; |