From bec35200e97adabf4880a92bad40ec5bbe4848d1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 07:29:21 +0300 Subject: [PATCH] fix some eslint-related stuff --- js/App.js | 119 +++++++++++++++++++++----------------------- js/Article.js | 2 +- js/CommonDialogs.js | 2 +- js/CommonFilters.js | 4 +- js/PrefHelpers.js | 2 +- js/PrefUsers.js | 2 +- js/common.js | 5 +- js/tt-rss.js | 2 +- 8 files changed, 68 insertions(+), 70 deletions(-) diff --git a/js/App.js b/js/App.js index f7a9254ba..d61c6ead0 100644 --- a/js/App.js +++ b/js/App.js @@ -1,9 +1,9 @@ 'use strict'; /* eslint-disable new-cap */ -/* global __, Article, Ajax, Headlines, Filters, fox */ -/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */ -/* global CommonDialogs, Plugins, Effect */ +/* global __, Article, Headlines, Filters, fox */ +/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, Feeds, Cookie */ +/* global CommonDialogs, Plugins */ const App = { _initParams: [], @@ -234,7 +234,7 @@ const App = { }, urlParam: function(name) { try { - const results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); + const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href); return decodeURIComponent(results[1].replace(/\+/g, " ")) || 0; } catch (e) { return 0; @@ -439,40 +439,38 @@ const App = { return false; }, parseRuntimeInfo: function(data) { - for (const k in data) { - if (data.hasOwnProperty(k)) { - const v = data[k]; + Object.keys(data).forEach((k) => { + const v = data[k]; - console.log("RI:", k, "=>", v); + console.log("RI:", k, "=>", v); - if (k == "daemon_is_running" && v != 1) { - Notify.error("Update daemon is not running.", true); - return; - } + if (k == "daemon_is_running" && v != 1) { + Notify.error("Update daemon is not running.", true); + return; + } - if (k == "recent_log_events") { - const alert = App.findAll(".log-alert")[0]; + if (k == "recent_log_events") { + const alert = App.findAll(".log-alert")[0]; - if (alert) { - v > 0 ? alert.show() : alert.hide(); - } - } + if (alert) { + v > 0 ? alert.show() : alert.hide(); + } + } - if (k == "daemon_stamp_ok" && v != 1) { - Notify.error("Update daemon is not updating feeds.", true); - return; - } + if (k == "daemon_stamp_ok" && v != 1) { + Notify.error("Update daemon is not updating feeds.", true); + return; + } - if (k == "max_feed_id" || k == "num_feeds") { - if (this.getInitParam(k) != v) { - console.log("feed count changed, need to reload feedlist."); - Feeds.reload(); - } - } + if (k == "max_feed_id" || k == "num_feeds") { + if (this.getInitParam(k) != v) { + console.log("feed count changed, need to reload feedlist."); + Feeds.reload(); + } + } - this.setInitParam(k, v); - } - } + this.setInitParam(k, v); + }); PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data); }, @@ -500,39 +498,36 @@ const App = { if (params) { console.log('reading init-params...'); - for (const k in params) { - if (params.hasOwnProperty(k)) { - switch (k) { - case "label_base_index": - this.LABEL_BASE_INDEX = parseInt(params[k]); - break; - case "cdm_auto_catchup": - if (params[k] == 1) { - const hl = App.byId("headlines-frame"); - if (hl) hl.addClassName("auto_catchup"); - } - break; - case "hotkeys": - // filter mnemonic definitions (used for help panel) from hotkeys map - // i.e. *(191)|Ctrl-/ -> *(191) - { - const tmp = []; - for (const sequence in params[k][1]) { - if (params[k][1].hasOwnProperty(sequence)) { - const filtered = sequence.replace(/\|.*$/, ""); - tmp[filtered] = params[k][1][sequence]; - } - } + Object.keys(params).forEach((k) => { + switch (k) { + case "label_base_index": + this.LABEL_BASE_INDEX = parseInt(params[k]); + break; + case "cdm_auto_catchup": + if (params[k] == 1) { + const hl = App.byId("headlines-frame"); + if (hl) hl.addClassName("auto_catchup"); + } + break; + case "hotkeys": + // filter mnemonic definitions (used for help panel) from hotkeys map + // i.e. *(191)|Ctrl-/ -> *(191) + { + const tmp = []; - params[k][1] = tmp; - } - break; - } + Object.keys(params[k][1]).forEach((sequence) => { + const filtered = sequence.replace(/\|.*$/, ""); + tmp[filtered] = params[k][1][sequence]; + }); - console.log("IP:", k, "=>", params[k]); - this.setInitParam(k, params[k]); - } - } + params[k][1] = tmp; + } + break; + } + + console.log("IP:", k, "=>", params[k]); + this.setInitParam(k, params[k]); + }); // PluginHost might not be available on non-index pages if (typeof PluginHost !== 'undefined') diff --git a/js/Article.js b/js/Article.js index 15c5cac65..b1d14c390 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,7 +1,7 @@ 'use strict' /* eslint-disable no-new */ -/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax, fox */ +/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, fox */ const Article = { _scroll_reset_timeout: false, diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index c62e6893e..6ace91c8c 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -3,7 +3,7 @@ /* eslint-disable new-cap */ /* eslint-disable no-new */ -/* global __, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect, fox */ +/* global __, dojo, dijit, Notify, App, Feeds, xhrPost, xhrJson, Tables, fox */ /* exported CommonDialogs */ const CommonDialogs = { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index d5b751f91..3fa100b9e 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -2,8 +2,8 @@ /* eslint-disable no-new */ -/* global __, App, Article, Lists, Effect, fox */ -/* global xhrPost, dojo, dijit, Notify, $$, Feeds */ +/* global __, App, Article, Lists, fox */ +/* global xhrPost, dojo, dijit, Notify, Feeds */ const Filters = { filterDlgCheckAction: function(sender) { diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index f3c44e30d..d4db15c3b 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,7 +1,7 @@ 'use strict'; /* eslint-disable no-new */ -/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App, fox, Effect */ +/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App, fox */ const Helpers = { AppPasswords: { diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 2e8c9c4a8..64466ef18 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,7 +1,7 @@ 'use strict' /* global __ */ -/* global xhrPost, xhrJson, dojo, dijit, Notify, Tables, App, fox */ +/* global xhrPost, xhrJson, dijit, Notify, Tables, App, fox */ const Users = { reload: function(sort) { diff --git a/js/common.js b/js/common.js index 6dd5713df..a5e1e503a 100755 --- a/js/common.js +++ b/js/common.js @@ -1,6 +1,6 @@ 'use strict'; -/* global dijit, __, App, Ajax */ +/* global dijit, __, App, dojo, __csrf_token */ /* eslint-disable no-new */ function $(id) { @@ -111,6 +111,8 @@ String.prototype.stripTags = function() { /* xhr shorthand helpers */ +// TODO: this should become xhr { Post: ..., Json: ... } + /* exported xhrPost */ function xhrPost(url, params = {}, complete = undefined) { console.log("xhrPost:", params); @@ -144,6 +146,7 @@ function xhrJson(url, params = {}, complete = undefined) { obj = JSON.parse(reply.responseText); } catch (e) { console.error("xhrJson", e, reply); + reject(e); } if (complete != undefined) complete(obj); diff --git a/js/tt-rss.js b/js/tt-rss.js index a00838c43..8d7dd00a6 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,6 +1,6 @@ 'use strict' -/* global require, App, $H */ +/* global require, App, dojo */ /* exported Plugins */ const Plugins = {};