diff --git a/classes/feeds.php b/classes/feeds.php index d9bcbbd04..eb0bdac63 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -722,7 +722,7 @@ class Feeds extends Handler_Protected { if ($num_errors > 0) { $reply['content'] .= "
"; - $reply['content'] .= "" . + $reply['content'] .= "" . __('Some feeds have update errors (click for details)') . ""; } $reply['content'] .= "

"; @@ -913,7 +913,7 @@ class Feeds extends Handler_Protected { if ($num_errors > 0) { $reply['headlines']['content'] .= "
"; - $reply['headlines']['content'] .= "". + $reply['headlines']['content'] .= "". __('Some feeds have update errors (click for details)').""; } $reply['headlines']['content'] .= "

"; @@ -1014,7 +1014,7 @@ class Feeds extends Handler_Protected { "; if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) { - print ""; + print ""; } print " diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 23e9baee9..c061243ee 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1149,7 +1149,7 @@ class Pref_Feeds extends Handler_Protected { if ($num_errors > 0) { $error_button = ""; } @@ -1190,7 +1190,7 @@ class Pref_Feeds extends Handler_Protected { print "
". "" . __('Feeds').""; print "
"; - print "
".__('Subscribe to feed')."
"; print "
".__('Edit selected feeds')."
"; diff --git a/js/feedlist.js b/js/feedlist.js index ddef1a586..f2f5e60ba 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -190,7 +190,7 @@ const Feeds = { try { Feeds.init(); - setLoadingProgress(25); + Utils.setLoadingProgress(25); } catch (e) { exception_error(e); } @@ -204,7 +204,7 @@ const Feeds = { init: function() { console.log("in feedlist init"); - setLoadingProgress(50); + Utils.setLoadingProgress(50); document.onkeydown = App.hotkeyHandler; setInterval(hotkeyPrefixTimeout, 3 * 1000); @@ -602,5 +602,35 @@ const Feeds = { if (nuf) return tree.model.store.getValue(nuf, 'bare_id'); - } + }, + search: function() { + const query = "backend.php?op=feeds&method=search¶m=" + + param_escape(Feeds.getActiveFeedId() + ":" + Feeds.activeFeedIsCat()); + + if (dijit.byId("searchDlg")) + dijit.byId("searchDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "searchDlg", + title: __("Search"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Feeds._search_query = this.attr('value'); + this.hide(); + Feeds.viewCurrentFeed(); + } + }, + href: query + }); + + dialog.show(); + }, + updateRandomFeed: function() { + console.log("in update_random_feed"); + + xhrPost("backend.php", {op: "rpc", method: "updateRandomFeed"}, (transport) => { + Utils.handleRpcJson(transport, true); + }); + }, }; diff --git a/js/functions.js b/js/functions.js index f2463dda3..0bddbbf0e 100755 --- a/js/functions.js +++ b/js/functions.js @@ -65,6 +65,70 @@ const Utils = { get_seq: function() { return this._rpc_seq; }, + setLoadingProgress: function(p) { + loading_progress += p; + + if (dijit.byId("loading_bar")) + dijit.byId("loading_bar").update({progress: loading_progress}); + + if (loading_progress >= 90) + Element.hide("overlay"); + + }, + keyeventToAction: function(e) { + + const hotkeys_map = getInitParam("hotkeys"); + const keycode = e.which; + const keychar = String.fromCharCode(keycode).toLowerCase(); + + if (keycode == 27) { // escape and drop prefix + hotkey_prefix = false; + } + + if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl + + if (!hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) { + + const date = new Date(); + const ts = Math.round(date.getTime() / 1000); + + hotkey_prefix = keychar; + hotkey_prefix_pressed = ts; + + $("cmdline").innerHTML = keychar; + Element.show("cmdline"); + + e.stopPropagation(); + + return false; + } + + Element.hide("cmdline"); + + let hotkey_name = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; + + // ensure ^*char notation + if (e.shiftKey) hotkey_name = "*" + hotkey_name; + if (e.ctrlKey) hotkey_name = "^" + hotkey_name; + if (e.altKey) hotkey_name = "+" + hotkey_name; + if (e.metaKey) hotkey_name = "%" + hotkey_name; + + const hotkey_full = hotkey_prefix ? hotkey_prefix + " " + hotkey_name : hotkey_name; + hotkey_prefix = false; + + let action_name = false; + + for (const sequence in hotkeys_map[1]) { + if (sequence == hotkey_full) { + action_name = hotkeys_map[1][sequence]; + break; + } + } + + console.log('keyeventToAction', hotkey_full, '=>', action_name); + + return action_name; + }, cleanupMemory: function(root) { const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode); @@ -311,6 +375,281 @@ const Utils = { } }; +const CommonDialogs = { + quickAddFeed: function() { + const query = "backend.php?op=feeds&method=quickAddFeed"; + + // overlapping widgets + if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); + if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "feedAddDlg", + title: __("Subscribe to Feed"), + style: "width: 600px", + show_error: function (msg) { + const elem = $("fadd_error_message"); + + elem.innerHTML = msg; + + if (!Element.visible(elem)) + new Effect.Appear(elem); + + }, + execute: function () { + if (this.validate()) { + console.log(dojo.objectToQuery(this.attr('value'))); + + const feed_url = this.attr('value').feed; + + Element.show("feed_add_spinner"); + Element.hide("fadd_error_message"); + + xhrPost("backend.php", this.attr('value'), (transport) => { + try { + + try { + var reply = JSON.parse(transport.responseText); + } catch (e) { + Element.hide("feed_add_spinner"); + alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); + console.log('quickAddFeed, backend returned:' + transport.responseText); + return; + } + + const rc = reply['result']; + + notify(''); + Element.hide("feed_add_spinner"); + + console.log(rc); + + switch (parseInt(rc['code'])) { + case 1: + dialog.hide(); + notify_info(__("Subscribed to %s").replace("%s", feed_url)); + + Feeds.reload(); + break; + case 2: + dialog.show_error(__("Specified URL seems to be invalid.")); + break; + case 3: + dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); + break; + case 4: + const feeds = rc['feeds']; + + Element.show("fadd_multiple_notify"); + + const select = dijit.byId("feedDlg_feedContainerSelect"); + + while (select.getOptions().length > 0) + select.removeOption(0); + + select.addOption({value: '', label: __("Expand to select feed")}); + + let count = 0; + for (const feedUrl in feeds) { + select.addOption({value: feedUrl, label: feeds[feedUrl]}); + count++; + } + + Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); + + break; + case 5: + dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); + break; + case 6: + dialog.show_error(__("XML validation failed: %s").replace("%s", rc['message'])); + break; + case 0: + dialog.show_error(__("You are already subscribed to this feed.")); + break; + } + + } catch (e) { + console.error(transport.responseText); + exception_error(e); + } + }); + } + }, + href: query + }); + + dialog.show(); + }, + showFeedsWithErrors: function() { + const query = {op: "pref-feeds", method: "feedsWithErrors"}; + + if (dijit.byId("errorFeedsDlg")) + dijit.byId("errorFeedsDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "errorFeedsDlg", + title: __("Feeds with update errors"), + style: "width: 600px", + getSelectedFeeds: function () { + return getSelectedTableRowIds("prefErrorFeedList"); + }, + removeSelected: function () { + const sel_rows = this.getSelectedFeeds(); + + if (sel_rows.length > 0) { + if (confirm(__("Remove selected feeds?"))) { + notify_progress("Removing selected feeds...", true); + + const query = { + op: "pref-feeds", method: "remove", + ids: sel_rows.toString() + }; + + xhrPost("backend.php", query, () => { + notify(''); + dialog.hide(); + Feeds.reload(); + }); + } + + } else { + alert(__("No feeds are selected.")); + } + }, + execute: function () { + if (this.validate()) { + // + } + }, + href: "backend.php?" + dojo.objectToQuery(query) + }); + + dialog.show(); + }, + feedBrowser: function() { + const query = {op: "feeds", method: "feedBrowser"}; + + if (dijit.byId("feedAddDlg")) + dijit.byId("feedAddDlg").hide(); + + if (dijit.byId("feedBrowserDlg")) + dijit.byId("feedBrowserDlg").destroyRecursive(); + + // noinspection JSUnusedGlobalSymbols + const dialog = new dijit.Dialog({ + id: "feedBrowserDlg", + title: __("More Feeds"), + style: "width: 600px", + getSelectedFeedIds: function () { + const list = $$("#browseFeedList li[id*=FBROW]"); + const selected = []; + + list.each(function (child) { + const id = child.id.replace("FBROW-", ""); + + if (child.hasClassName('Selected')) { + selected.push(id); + } + }); + + return selected; + }, + getSelectedFeeds: function () { + const list = $$("#browseFeedList li.Selected"); + const selected = []; + + list.each(function (child) { + const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML; + const url = child.getElementsBySelector("a.fb_feedUrl")[0].href; + + selected.push([title, url]); + + }); + + return selected; + }, + + subscribe: function () { + const mode = this.attr('value').mode; + let selected = []; + + if (mode == "1") + selected = this.getSelectedFeeds(); + else + selected = this.getSelectedFeedIds(); + + if (selected.length > 0) { + dijit.byId("feedBrowserDlg").hide(); + + notify_progress("Loading, please wait...", true); + + const query = { + op: "rpc", method: "massSubscribe", + payload: JSON.stringify(selected), mode: mode + }; + + xhrPost("backend.php", query, () => { + notify(''); + Feeds.reload(); + }); + + } else { + alert(__("No feeds are selected.")); + } + + }, + update: function () { + Element.show('feed_browser_spinner'); + + xhrPost("backend.php", dialog.attr("value"), (transport) => { + notify(''); + + Element.hide('feed_browser_spinner'); + + const reply = JSON.parse(transport.responseText); + const mode = reply['mode']; + + if ($("browseFeedList") && reply['content']) { + $("browseFeedList").innerHTML = reply['content']; + } + + dojo.parser.parse("browseFeedList"); + + if (mode == 2) { + Element.show(dijit.byId('feed_archive_remove').domNode); + } else { + Element.hide(dijit.byId('feed_archive_remove').domNode); + } + }); + }, + removeFromArchive: function () { + const selected = this.getSelectedFeedIds(); + + if (selected.length > 0) { + if (confirm(__("Remove selected feeds from the archive? Feeds with stored articles will not be removed."))) { + Element.show('feed_browser_spinner'); + + const query = {op: "rpc", method: "remarchive", ids: selected.toString()}; + + xhrPost("backend.php", query, () => { + dialog.update(); + }); + } + } + }, + execute: function () { + if (this.validate()) { + this.subscribe(); + } + }, + href: "backend.php?" + dojo.objectToQuery(query) + }); + + dialog.show(); + } +}; + function report_error(message, filename, lineno, colno, error) { exception_error(error, null, filename, lineno); } @@ -665,17 +1004,6 @@ function explainError(code) { return Utils.displayDlg(__("Error explained"), "explainError", code); } -function setLoadingProgress(p) { - loading_progress += p; - - if (dijit.byId("loading_bar")) - dijit.byId("loading_bar").update({progress: loading_progress}); - - if (loading_progress >= 90) - Element.hide("overlay"); - -} - function strip_tags(s) { return s.replace(/<\/?[^>]+(>|$)/g, ""); } @@ -772,113 +1100,6 @@ function addLabel(select, callback) { } -function quickAddFeed() { - const query = "backend.php?op=feeds&method=quickAddFeed"; - - // overlapping widgets - if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); - if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "feedAddDlg", - title: __("Subscribe to Feed"), - style: "width: 600px", - show_error: function(msg) { - const elem = $("fadd_error_message"); - - elem.innerHTML = msg; - - if (!Element.visible(elem)) - new Effect.Appear(elem); - - }, - execute: function() { - if (this.validate()) { - console.log(dojo.objectToQuery(this.attr('value'))); - - const feed_url = this.attr('value').feed; - - Element.show("feed_add_spinner"); - Element.hide("fadd_error_message"); - - xhrPost("backend.php", this.attr('value'), (transport) => { - try { - - try { - var reply = JSON.parse(transport.responseText); - } catch (e) { - Element.hide("feed_add_spinner"); - alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); - console.log('quickAddFeed, backend returned:' + transport.responseText); - return; - } - - const rc = reply['result']; - - notify(''); - Element.hide("feed_add_spinner"); - - console.log(rc); - - switch (parseInt(rc['code'])) { - case 1: - dialog.hide(); - notify_info(__("Subscribed to %s").replace("%s", feed_url)); - - Feeds.reload(); - break; - case 2: - dialog.show_error(__("Specified URL seems to be invalid.")); - break; - case 3: - dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); - break; - case 4: - const feeds = rc['feeds']; - - Element.show("fadd_multiple_notify"); - - const select = dijit.byId("feedDlg_feedContainerSelect"); - - while (select.getOptions().length > 0) - select.removeOption(0); - - select.addOption({value: '', label: __("Expand to select feed")}); - - let count = 0; - for (const feedUrl in feeds) { - select.addOption({value: feedUrl, label: feeds[feedUrl]}); - count++; - } - - Effect.Appear('feedDlg_feedsContainer', {duration : 0.5}); - - break; - case 5: - dialog.show_error(__("Couldn't download the specified URL: %s"). - replace("%s", rc['message'])); - break; - case 6: - dialog.show_error(__("XML validation failed: %s"). - replace("%s", rc['message'])); - break; - case 0: - dialog.show_error(__("You are already subscribed to this feed.")); - break; - } - - } catch (e) { - console.error(transport.responseText); - exception_error(e); - } - }); - } - }, - href: query}); - - dialog.show(); -} - function createNewRuleElement(parentNode, replaceNode) { const form = document.forms["filter_new_rule_form"]; const query = { op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form) }; @@ -1382,172 +1603,6 @@ function editFeed(feed) { dialog.show(); } -function feedBrowser() { - const query = { op: "feeds", method: "feedBrowser" }; - - if (dijit.byId("feedAddDlg")) - dijit.byId("feedAddDlg").hide(); - - if (dijit.byId("feedBrowserDlg")) - dijit.byId("feedBrowserDlg").destroyRecursive(); - - // noinspection JSUnusedGlobalSymbols - const dialog = new dijit.Dialog({ - id: "feedBrowserDlg", - title: __("More Feeds"), - style: "width: 600px", - getSelectedFeedIds: function () { - const list = $$("#browseFeedList li[id*=FBROW]"); - const selected = []; - - list.each(function (child) { - const id = child.id.replace("FBROW-", ""); - - if (child.hasClassName('Selected')) { - selected.push(id); - } - }); - - return selected; - }, - getSelectedFeeds: function () { - const list = $$("#browseFeedList li.Selected"); - const selected = []; - - list.each(function (child) { - const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML; - const url = child.getElementsBySelector("a.fb_feedUrl")[0].href; - - selected.push([title, url]); - - }); - - return selected; - }, - - subscribe: function () { - const mode = this.attr('value').mode; - let selected = []; - - if (mode == "1") - selected = this.getSelectedFeeds(); - else - selected = this.getSelectedFeedIds(); - - if (selected.length > 0) { - dijit.byId("feedBrowserDlg").hide(); - - notify_progress("Loading, please wait...", true); - - const query = { op: "rpc", method: "massSubscribe", - payload: JSON.stringify(selected), mode: mode }; - - xhrPost("backend.php", query, () => { - notify(''); - Feeds.reload(); - }); - - } else { - alert(__("No feeds are selected.")); - } - - }, - update: function () { - Element.show('feed_browser_spinner'); - - xhrPost("backend.php", dialog.attr("value"), (transport) => { - notify(''); - - Element.hide('feed_browser_spinner'); - - const reply = JSON.parse(transport.responseText); - const mode = reply['mode']; - - if ($("browseFeedList") && reply['content']) { - $("browseFeedList").innerHTML = reply['content']; - } - - dojo.parser.parse("browseFeedList"); - - if (mode == 2) { - Element.show(dijit.byId('feed_archive_remove').domNode); - } else { - Element.hide(dijit.byId('feed_archive_remove').domNode); - } - }); - }, - removeFromArchive: function () { - const selected = this.getSelectedFeedIds(); - - if (selected.length > 0) { - if (confirm(__("Remove selected feeds from the archive? Feeds with stored articles will not be removed."))) { - Element.show('feed_browser_spinner'); - - const query = { op: "rpc", method: "remarchive", ids: selected.toString() }; - - xhrPost("backend.php", query, () => { - dialog.update(); - }); - } - } - }, - execute: function () { - if (this.validate()) { - this.subscribe(); - } - }, - href: "backend.php?" + dojo.objectToQuery(query) - }); - - dialog.show(); -} - -// noinspection JSUnusedGlobalSymbols -function showFeedsWithErrors() { - const query = { op: "pref-feeds", method: "feedsWithErrors" }; - - if (dijit.byId("errorFeedsDlg")) - dijit.byId("errorFeedsDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "errorFeedsDlg", - title: __("Feeds with update errors"), - style: "width: 600px", - getSelectedFeeds: function() { - return getSelectedTableRowIds("prefErrorFeedList"); - }, - removeSelected: function() { - const sel_rows = this.getSelectedFeeds(); - - if (sel_rows.length > 0) { - if (confirm(__("Remove selected feeds?"))) { - notify_progress("Removing selected feeds...", true); - - const query = { op: "pref-feeds", method: "remove", - ids: sel_rows.toString() }; - - xhrPost("backend.php", query, () => { - notify(''); - dialog.hide(); - Feeds.reload(); - }); - } - - } else { - alert(__("No feeds are selected.")); - } - }, - execute: function() { - if (this.validate()) { - // - } - }, - href: "backend.php?" + dojo.objectToQuery(query) - }); - - dialog.show(); -} - function get_timestamp() { const date = new Date(); return Math.round(date.getTime() / 1000); @@ -1602,58 +1657,3 @@ function popupOpenArticle(id) { w.opener = null; w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + getInitParam("csrf_token"); } - -function keyeventToAction(e) { - - const hotkeys_map = getInitParam("hotkeys"); - const keycode = e.which; - const keychar = String.fromCharCode(keycode).toLowerCase(); - - if (keycode == 27) { // escape and drop prefix - hotkey_prefix = false; - } - - if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl - - if (!hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) { - - const date = new Date(); - const ts = Math.round(date.getTime() / 1000); - - hotkey_prefix = keychar; - hotkey_prefix_pressed = ts; - - $("cmdline").innerHTML = keychar; - Element.show("cmdline"); - - e.stopPropagation(); - - return false; - } - - Element.hide("cmdline"); - - let hotkey_name = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; - - // ensure ^*char notation - if (e.shiftKey) hotkey_name = "*" + hotkey_name; - if (e.ctrlKey) hotkey_name = "^" + hotkey_name; - if (e.altKey) hotkey_name = "+" + hotkey_name; - if (e.metaKey) hotkey_name = "%" + hotkey_name; - - const hotkey_full = hotkey_prefix ? hotkey_prefix + " " + hotkey_name : hotkey_name; - hotkey_prefix = false; - - let action_name = false; - - for (const sequence in hotkeys_map[1]) { - if (sequence == hotkey_full) { - action_name = hotkeys_map[1][sequence]; - break; - } - } - - console.log('keyeventToAction', hotkey_full, '=>', action_name); - - return action_name; -} \ No newline at end of file diff --git a/js/prefs.js b/js/prefs.js index 15007d014..e83e69bd5 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -49,7 +49,7 @@ const App = { try { parser.parse(); - setLoadingProgress(50); + Utils.setLoadingProgress(50); const clientTzOffset = new Date().getTimezoneOffset() * 60; const params = {op: "rpc", method: "sanityCheck", clientTzOffset: clientTzOffset}; @@ -66,7 +66,7 @@ const App = { }, initSecondStage: function() { document.onkeydown = this.hotkeyHandler; - setLoadingProgress(50); + Utils.setLoadingProgress(50); notify(""); let tab = getURLParam('tab'); @@ -91,12 +91,12 @@ const App = { hotkeyHandler: function (event) { if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; - const action_name = keyeventToAction(event); + const action_name = Utils.keyeventToAction(event); if (action_name) { switch (action_name) { case "feed_subscribe": - quickAddFeed(); + CommonDialogs.quickAddFeed(); return false; case "create_label": addLabel(); diff --git a/js/tt-rss.js b/js/tt-rss.js index e48e4ece9..4c37102e6 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,10 +1,10 @@ /* global dijit, __ */ -let _widescreen_mode = false; let hotkey_actions = {}; const App = { global_unread: -1, + _widescreen_mode: false, init: function() { window.onerror = function (message, filename, lineno, colno, error) { @@ -56,7 +56,7 @@ const App = { if (!App.genericSanityCheck()) return false; - setLoadingProgress(30); + Utils.setLoadingProgress(30); init_hotkey_actions(); const a = document.createElement('audio'); @@ -132,21 +132,21 @@ const App = { Feeds.setActiveFeedId(hash_feed_id, hash_feed_is_cat); } - setLoadingProgress(50); + Utils.setLoadingProgress(50); ArticleCache.clear(); - _widescreen_mode = getInitParam("widescreen"); - this.switchPanelMode(_widescreen_mode); + this._widescreen_mode = getInitParam("widescreen"); + this.switchPanelMode(this._widescreen_mode); Headlines.initScrollHandler(); - console.log("second stage ok"); - if (getInitParam("simple_update")) { console.log("scheduling simple feed updater..."); - window.setTimeout(update_random_feed, 30 * 1000); + window.setInterval(Feeds.updateRandomFeed, 30 * 1000); } + + console.log("second stage ok"); }, genericSanityCheck: function() { setCookie("ttrss_test", "TEST"); @@ -176,7 +176,7 @@ const App = { hotkeyHandler(event) { if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; - const action_name = keyeventToAction(event); + const action_name = Utils.keyeventToAction(event); if (action_name) { const action_func = hotkey_actions[action_name]; @@ -235,29 +235,6 @@ const App = { }, }; -function search() { - const query = "backend.php?op=feeds&method=search¶m=" + - param_escape(Feeds.getActiveFeedId() + ":" + Feeds.activeFeedIsCat()); - - if (dijit.byId("searchDlg")) - dijit.byId("searchDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "searchDlg", - title: __("Search"), - style: "width: 600px", - execute: function() { - if (this.validate()) { - Feeds._search_query = this.attr('value'); - this.hide(); - Feeds.viewCurrentFeed(); - } - }, - href: query}); - - dialog.show(); -} - function init_hotkey_actions() { hotkey_actions["next_feed"] = function () { const rv = dijit.byId("feedTree").getNextFeed( @@ -290,7 +267,7 @@ function init_hotkey_actions() { moveToPost('prev', true, true); }; hotkey_actions["search_dialog"] = function () { - search(); + Feeds.search(); }; hotkey_actions["toggle_mark"] = function () { selectionToggleMarked(); @@ -361,14 +338,13 @@ function init_hotkey_actions() { hotkey_actions["feed_refresh"] = function () { if (Feeds.getActiveFeedId() != undefined) { Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat()}); - return; } }; hotkey_actions["feed_unhide_read"] = function () { Feeds.toggleDispRead(); }; hotkey_actions["feed_subscribe"] = function () { - quickAddFeed(); + CommonDialogs.quickAddFeed(); }; hotkey_actions["feed_debug_update"] = function () { if (!Feeds.activeFeedIsCat() && parseInt(Feeds.getActiveFeedId()) > 0) { @@ -392,7 +368,6 @@ function init_hotkey_actions() { hotkey_actions["feed_catchup"] = function () { if (Feeds.getActiveFeedId() != undefined) { Feeds.catchupCurrentFeed(); - return; } }; hotkey_actions["feed_reverse"] = function () { @@ -467,13 +442,13 @@ function init_hotkey_actions() { }; hotkey_actions["toggle_widescreen"] = function () { if (!App.isCombinedMode()) { - _widescreen_mode = !_widescreen_mode; + App._widescreen_mode = !App._widescreen_mode; // reset stored sizes because geometry changed setCookie("ttrss_ci_width", 0); setCookie("ttrss_ci_height", 0); - App.switchPanelMode(_widescreen_mode); + App.switchPanelMode(App._widescreen_mode); } else { alert(__("Widescreen is not available in combined mode.")); } @@ -518,10 +493,10 @@ function quickMenuGo(opid) { Utils.displayDlg(__("Tag cloud"), "printTagCloud"); break; case "qmcSearch": - search(); + Feeds.search(); break; case "qmcAddFeed": - quickAddFeed(); + CommonDialogs.quickAddFeed(); break; case "qmcDigest": window.location.href = "backend.php?op=digest"; @@ -561,13 +536,13 @@ function quickMenuGo(opid) { break; case "qmcToggleWidescreen": if (!App.isCombinedMode()) { - _widescreen_mode = !_widescreen_mode; + App._widescreen_mode = !App._widescreen_mode; // reset stored sizes because geometry changed setCookie("ttrss_ci_width", 0); setCookie("ttrss_ci_height", 0); - App.switchPanelMode(_widescreen_mode); + App.switchPanelMode(App._widescreen_mode); } else { alert(__("Widescreen is not available in combined mode.")); } @@ -584,15 +559,6 @@ function inPreferences() { return false; } -function update_random_feed() { - console.log("in update_random_feed"); - - xhrPost("backend.php", { op: "rpc", method: "updateRandomFeed" }, (transport) => { - Utils.handleRpcJson(transport, true); - window.setTimeout(update_random_feed, 30*1000); - }); -} - function hash_get(key) { const kv = window.location.hash.substring(1).toQueryParams(); return kv[key]; diff --git a/tests/functional/BasicTest.php b/tests/functional/BasicTest.php index dc44a67e1..c5bc70b4e 100644 --- a/tests/functional/BasicTest.php +++ b/tests/functional/BasicTest.php @@ -30,7 +30,7 @@ class BasicTest extends PHPUnit_Extensions_Selenium2TestCase { $this->execute(["script" => "dijit.byId('filterEditDlg').hide();", "args" => []]); - $this->execute(["script" => "quickAddFeed()", "args" => []]); + $this->execute(["script" => "CommonDialog.quickAddFeed()", "args" => []]); $this->byCssSelector("#feedAddDlg")->displayed(); $this->execute(["script" => "dijit.byId('feedAddDlg').hide();", "args" => []]);