diff --git a/classes/feeds.php b/classes/feeds.php index 90797270e..7e48efd6c 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -632,7 +632,7 @@ class Feeds extends Handler_Protected { $tmp_content .= ""; // cdmIntermediate - $tmp_content .= "
"; + $tmp_content .= "
"; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { $tmp_content .= $p->hook_article_left_button($line); diff --git a/js/functions.js b/js/functions.js index 9028482f8..d46d22c0b 100755 --- a/js/functions.js +++ b/js/functions.js @@ -1,3 +1,5 @@ +/* global dijit, __ */ + var loading_progress = 0; var sanity_check_done = false; var init_params = {}; @@ -459,12 +461,7 @@ function loading_set_progress(p) { } function remove_splash() { - - if (Element.visible("overlay")) { - console.log("about to remove splash, OMG!"); - Element.hide("overlay"); - console.log("removed splash!"); - } + Element.hide("overlay"); } function strip_tags(s) { @@ -850,9 +847,9 @@ function editFilterTest(query) { const result = JSON.parse(transport.responseText); if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) { - test_dlg.results += result.size(); + test_dlg.results += result.length; - console.log("got results:" + result.size()); + console.log("got results:" + result.length); $("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...") .replace("%f", test_dlg.results) @@ -860,7 +857,7 @@ function editFilterTest(query) { console.log(offset + " " + test_dlg.max_offset); - for (let i = 0; i < result.size(); i++) { + for (let i = 0; i < result.length; i++) { const tmp = new Element("table"); tmp.innerHTML = result[i]; dojo.parser.parse(tmp); @@ -1291,7 +1288,7 @@ function feedBrowser() { style: "width: 600px", getSelectedFeedIds: function () { const list = $$("#browseFeedList li[id*=FBROW]"); - const selected = new Array(); + const selected = []; list.each(function (child) { const id = child.id.replace("FBROW-", ""); @@ -1305,7 +1302,7 @@ function feedBrowser() { }, getSelectedFeeds: function () { const list = $$("#browseFeedList li.Selected"); - const selected = new Array(); + const selected = []; list.each(function (child) { const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML; diff --git a/js/prefs.js b/js/prefs.js index cfc2d6c52..792ad6b3d 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -1,4 +1,6 @@ -let init_params = new Array(); +/* global dijit, __ */ + +let init_params = []; let hotkey_prefix = false; let hotkey_prefix_pressed = false; diff --git a/js/tt-rss.js b/js/tt-rss.js index b2b6da3c0..654d125fb 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,3 +1,5 @@ +/* global dijit, __ */ + let global_unread = -1; let hotkey_prefix = false; let hotkey_prefix_pressed = false; @@ -79,14 +81,6 @@ function updateFeedList() { id: "feedTree", }, "feedTree"); - /* var menu = new dijit.Menu({id: 'feedMenu'}); - - menu.addChild(new dijit.MenuItem({ - label: "Simple menu item" - })); - - // menu.bindDomNode(tree.domNode); */ - var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) { console.log(dijit.getEnclosingWidget(event.target)); dojo.disconnect(tmph); @@ -603,8 +597,6 @@ function init_second_stage() { dijit.getEnclosingWidget(toolbar.order_by).attr('value', getInitParam("default_view_order_by")); - const feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; - const hash_feed_id = hash_get('f'); const hash_feed_is_cat = hash_get('c') == "1"; @@ -829,7 +821,7 @@ function rescoreCurrentFeed() { new Ajax.Request("backend.php", { parameters: query, - onComplete: function(transport) { + onComplete: function() { viewCurrentFeed(); } }); } @@ -839,24 +831,15 @@ function hotkey_handler(e) { if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; - let keycode = false; - - const cmdline = $('cmdline'); + let keycode = e.which; - if (window.event) { - keycode = window.event.keyCode; - } else if (e) { - keycode = e.which; - } - - if (keycode == 27) { // escape + if (keycode == 27) { // escape and drop prefix hotkey_prefix = false; } - if (keycode == 16) return; // ignore lone shift - if (keycode == 17) return; // ignore lone ctrl + if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl - var hotkeys = getInitParam("hotkeys"); + const hotkeys = getInitParam("hotkeys"); const keychar = String.fromCharCode(keycode).toLowerCase(); if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) { @@ -867,8 +850,8 @@ function hotkey_handler(e) { hotkey_prefix = keychar; hotkey_prefix_pressed = ts; - cmdline.innerHTML = keychar; - Element.show(cmdline); + $("cmdline").innerHTML = keychar; + Element.show("cmdline"); e.stopPropagation(); @@ -876,7 +859,7 @@ function hotkey_handler(e) { return true; } - Element.hide(cmdline); + Element.hide("cmdline"); let hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; @@ -890,7 +873,6 @@ function hotkey_handler(e) { hotkey_prefix = false; let hotkey_action = false; - var hotkeys = getInitParam("hotkeys"); for (const sequence in hotkeys[1]) { if (sequence == hotkey) { @@ -958,22 +940,18 @@ function handle_rpc_json(transport, scheduled_call) { const seq = reply['seq']; - if (seq) { - if (get_seq() != seq) { - console.log("[handle_rpc_json] sequence mismatch: " + seq + - " (want: " + get_seq() + ")"); - return true; - } + if (get_seq() != seq) { + console.log("[handle_rpc_json] sequence mismatch: " + seq + + " (want: " + get_seq() + ")"); + return true; } const message = reply['message']; - if (message) { - if (message == "UPDATE_COUNTERS") { - console.log("need to refresh counters..."); - setInitParam("last_article_id", -1); - request_counters(true); - } + if (message == "UPDATE_COUNTERS") { + console.log("need to refresh counters..."); + setInitParam("last_article_id", -1); + request_counters(true); } const counters = reply['counters']; @@ -988,7 +966,8 @@ function handle_rpc_json(transport, scheduled_call) { if (netalert) netalert.hide(); - } else if (netalert) + } else + if (netalert) netalert.show(); else notify_error("Communication problem with server."); diff --git a/js/viewfeed.js b/js/viewfeed.js index e23c357ff..916ff7dfc 100755 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -1,3 +1,5 @@ +/* global dijit, __ */ + let _active_article_id = 0; let vgroup_last_feed = false; @@ -607,7 +609,7 @@ function toggleSelected(id, force_on) { } function updateSelectedPrompt() { - const count = getSelectedArticleIds2().size(); + const count = getSelectedArticleIds2().length; const elem = $("selected_prompt"); if (elem) { @@ -1148,7 +1150,7 @@ function headlines_scroll_handler(e) { const rows = $$("#headlines-frame > div[id*=RROW]"); for (let i = 0; i < rows.length; i++) { - var child = rows[i]; + const child = rows[i]; if ($("headlines-frame").scrollTop <= child.offsetTop && child.offsetTop - $("headlines-frame").scrollTop < 100 && @@ -1193,8 +1195,7 @@ function headlines_scroll_handler(e) { $$("#headlines-frame > div[id*=RROW][class*=Unread]").each( function(child) { - if (child.hasClassName("Unread") && $("headlines-frame").scrollTop > - (child.offsetTop + child.offsetHeight/2)) { + if ($("headlines-frame").scrollTop > (child.offsetTop + child.offsetHeight/2)) { const id = child.getAttribute("data-article-id") @@ -1207,7 +1208,7 @@ function headlines_scroll_handler(e) { }); if (_infscroll_disable) { - var child = $$("#headlines-frame div[id*=RROW]").last(); + const child = $$("#headlines-frame div[id*=RROW]").last(); if (child && $("headlines-frame").scrollTop > (child.offsetTop + child.offsetHeight - 50)) { @@ -1281,7 +1282,7 @@ function catchupRelativeToArticle(below, id) { const visible_ids = getLoadedArticleIds(); - const ids_to_mark = new Array(); + const ids_to_mark = []; if (!below) { for (var i = 0; i < visible_ids.length; i++) { @@ -1391,7 +1392,7 @@ function cdmExpandArticle(id, noexpand) { const old_offset = row.offsetTop; if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) { - var collapse = oldrow.select("span[class='collapseBtn']")[0]; + let collapse = oldrow.select("span[class='collapseBtn']")[0]; Element.hide(elem); Element.show("CEXC-" + getActiveArticleId()); @@ -1404,7 +1405,7 @@ function cdmExpandArticle(id, noexpand) { elem = $("CICD-" + id); - var collapse = row.select("span[class='collapseBtn']")[0]; + let collapse = row.select("span[class='collapseBtn']")[0]; const cencw = $("CENCW-" + id); @@ -1480,15 +1481,15 @@ function cdmClicked(event, id, in_body) { return cdmExpandArticle(id); } else { - var elem = $("RROW-" + getActiveArticleId()); + let elem = $("RROW-" + getActiveArticleId()); if (elem) elem.removeClassName("active"); selectArticles("none"); toggleSelected(id); - var elem = $("RROW-" + id); - var article_is_unread = elem.hasClassName("Unread"); + elem = $("RROW-" + id); + const article_is_unread = elem.hasClassName("Unread"); elem.removeClassName("Unread"); elem.addClassName("active"); @@ -1517,8 +1518,8 @@ function cdmClicked(event, id, in_body) { toggleSelected(id, true); - var elem = $("RROW-" + id); - var article_is_unread = elem.hasClassName("Unread"); + let elem = $("RROW-" + id); + const article_is_unread = elem.hasClassName("Unread"); if (article_is_unread) { decrementFeedCounter(getActiveFeedId(), activeFeedIsCat()); @@ -1674,12 +1675,12 @@ function headlinesMenuCommon(menu) { menu.addChild(new dijit.MenuItem({ label: __("Toggle unread"), - onClick: function (event) { + onClick: function () { let ids = getSelectedArticleIds2(); // cast to string const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionToggleUnread(undefined, false, true, ids); } @@ -1687,11 +1688,11 @@ function headlinesMenuCommon(menu) { menu.addChild(new dijit.MenuItem({ label: __("Toggle starred"), - onClick: function (event) { + onClick: function () { let ids = getSelectedArticleIds2(); // cast to string const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionToggleMarked(undefined, false, true, ids); } @@ -1699,11 +1700,11 @@ function headlinesMenuCommon(menu) { menu.addChild(new dijit.MenuItem({ label: __("Toggle published"), - onClick: function (event) { + onClick: function () { let ids = getSelectedArticleIds2(); // cast to string const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionTogglePublished(undefined, false, true, ids); } @@ -1713,14 +1714,14 @@ function headlinesMenuCommon(menu) { menu.addChild(new dijit.MenuItem({ label: __("Mark above as read"), - onClick: function (event) { + onClick: function () { catchupRelativeToArticle(0, this.getParent().currentTarget.getAttribute("data-article-id")); } })); menu.addChild(new dijit.MenuItem({ label: __("Mark below as read"), - onClick: function (event) { + onClick: function () { catchupRelativeToArticle(1, this.getParent().currentTarget.getAttribute("data-article-id")); } })); @@ -1742,13 +1743,13 @@ function headlinesMenuCommon(menu) { labelAddMenu.addChild(new dijit.MenuItem({ label: name, labelId: bare_id, - onClick: function (event) { + onClick: function () { let ids = getSelectedArticleIds2(); // cast to string const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionAssignLabel(this.labelId, ids); } @@ -1757,12 +1758,12 @@ function headlinesMenuCommon(menu) { labelDelMenu.addChild(new dijit.MenuItem({ label: name, labelId: bare_id, - onClick: function (event) { + onClick: function () { let ids = getSelectedArticleIds2(); // cast to string const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionRemoveLabel(this.labelId, ids); } @@ -1786,7 +1787,7 @@ function headlinesMenuCommon(menu) { function initHeadlinesMenu() { if (!dijit.byId("headlinesMenu")) { - var menu = new dijit.Menu({ + const menu = new dijit.Menu({ id: "headlinesMenu", targetNodeIds: ["headlines-frame"], selector: ".hlMenuAttach" @@ -1801,7 +1802,7 @@ function initHeadlinesMenu() { if (!dijit.byId("headlinesFeedTitleMenu")) { - var menu = new dijit.Menu({ + const menu = new dijit.Menu({ id: "headlinesFeedTitleMenu", targetNodeIds: ["headlines-frame"], selector: "div.cdmFeedTitle" @@ -1819,7 +1820,7 @@ function initHeadlinesMenu() { menu.addChild(new dijit.MenuItem({ label: __("Mark group as read"), - onClick: function (event) { + onClick: function () { selectArticles("none"); selectArticles("all", "#headlines-frame > div[id*=RROW]" + @@ -1831,14 +1832,14 @@ function initHeadlinesMenu() { menu.addChild(new dijit.MenuItem({ label: __("Mark feed as read"), - onClick: function (event) { + onClick: function () { catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id")); } })); menu.addChild(new dijit.MenuItem({ label: __("Edit feed"), - onClick: function (event) { + onClick: function () { editFeed(this.getParent().currentTarget.getAttribute("data-feed-id")); } })); @@ -1883,7 +1884,7 @@ function setSelectionScore() { if (ids.length > 0) { console.log(ids); - var score = prompt(__("Please enter new score for selected articles:"), score); + const score = prompt(__("Please enter new score for selected articles:")); if (score != undefined) { const query = "op=article&method=setScore&id=" + param_escape(ids.toString()) + @@ -2051,7 +2052,3 @@ function catchupCurrentBatchIfNeeded() { } } } - -function cdmFooterClick(event) { - event.stopPropagation(); -}