From 39182a76e4070d3b92af10bf609fef8151bce6e4 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Oct 2025 21:02:39 +0000 Subject: Address ESLint rule 'eqeqeq'. https://eslint.org/docs/latest/rules/eqeqeq --- js/FeedTree.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'js/FeedTree.js') diff --git a/js/FeedTree.js b/js/FeedTree.js index 683205579..cd7e1f311 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -26,7 +26,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co // var oreo = cookie(this.cookieName); let oreo = localStorage.getItem(this.cookieName); // migrate old data if nothing in localStorage - if (oreo == null || oreo === '') { + if (oreo === null || oreo === '') { oreo = cookie(this.cookieName); cookie(this.cookieName, null, { expires: -1 }); } @@ -50,7 +50,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co let iconNode; if (iconName) { - if (iconName.indexOf("/") == -1) { + if (iconName.indexOf("/") === -1) { iconNode = dojo.create("i", { className: "material-icons icon icon-" + iconName, innerHTML: iconName }); } else { iconNode = dojo.create('img', { className: 'icon' }); @@ -156,7 +156,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co domConstruct.place(tnode.loadingNode, tnode.expandoNode, 'only'); } - if (id.match("CAT:") && bare_id == -1) { + if (id.match("CAT:") && bare_id === -1) { const menu = new dijit.Menu(); menu.row_id = bare_id; @@ -205,7 +205,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co } }, getTooltip: function (item) { - return [item.updated, item.error].filter((x) => x && x != "").join(" - "); + return [item.updated, item.error].filter((x) => x && x !== "").join(" - "); }, getIconClass: function (item, opened) { // eslint-disable-next-line no-nested-ternary @@ -217,21 +217,21 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co getRowClass: function (item/*, opened */) { let rc = "dijitTreeRow dijitTreeRowFlex"; - const is_cat = String(item.id).indexOf('CAT:') != -1; + const is_cat = String(item.id).indexOf('CAT:') !== -1; if (is_cat) rc += " Is_Cat"; else rc += " Is_Feed"; - if (!is_cat && item.error != '') rc += " Error"; + if (!is_cat && item.error !== '') rc += " Error"; if (item.unread > 0) rc += " Unread"; if (item.auxcounter > 0) rc += " Has_Aux"; if (item.markedcounter > 0) rc += " Has_Marked"; if (item.publishedcounter > 0) rc += " Has_Published"; if (item.updates_disabled > 0) rc += " UpdatesDisabled"; - if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == Feeds.FEED_ARCHIVED && !is_cat) rc += " Special"; - if (item.bare_id == Feeds.CATEGORY_SPECIAL && is_cat) rc += " AlwaysVisible"; + if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id === Feeds.FEED_ARCHIVED && !is_cat) rc += " Special"; + if (item.bare_id === Feeds.CATEGORY_SPECIAL && is_cat) rc += " AlwaysVisible"; if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label"; return rc; @@ -266,7 +266,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfTopLevelItems; for (let i = 0; i < items.length; i++) { - if (String(items[i].id) == test_id) { + if (String(items[i].id) === test_id) { this.expandParentNodes(feed, is_cat, parents); } else { this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []); @@ -276,13 +276,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co parents.push(root); for (let i = 0; i < root.items.length; i++) { - if (String(root.items[i].id) == test_id) { + if (String(root.items[i].id) === test_id) { this.expandParentNodes(feed, is_cat, parents); } else { this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0)); } } - } else if (String(root.id) == test_id) { + } else if (String(root.id) === test_id) { this.expandParentNodes(feed, is_cat, parents.slice(0)); } } catch (e) { @@ -423,7 +423,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfAllItems; const start = items.indexOf(treeItem); - if (start != -1) { + if (start !== -1) { let item = this._nextTreeItemFromIndex(start, unread_only); // let's try again from the top @@ -469,7 +469,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfAllItems; const start = items.indexOf(treeItem); - if (start != -1) { + if (start !== -1) { let item = this._prevTreeItemFromIndex(start, unread_only); // wrap from the bottom -- cgit v1.2.3-54-g00ecf From 360c552da41b08d92c8d5e0d01968ffe1e8e6323 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Oct 2025 21:48:10 +0000 Subject: Address rule 'no-redeclare' for 'dojo' and 'dijit' (defined as globals in 'eslint.config.js'). Also take care of 2 'no-prototype-builtins' and a 'no-useless-escape'. * https://eslint.org/docs/latest/rules/no-redeclare * https://eslint.org/docs/latest/rules/no-prototype-builtins * https://eslint.org/docs/latest/rules/no-useless-escape --- js/App.js | 2 +- js/Article.js | 2 +- js/CommonDialogs.js | 2 +- js/CommonFilters.js | 2 +- js/FeedStoreModel.js | 2 +- js/FeedTree.js | 2 +- js/Feeds.js | 2 +- js/Headlines.js | 2 +- js/PrefFeedStore.js | 2 +- js/PrefFeedTree.js | 2 +- js/PrefFilterStore.js | 2 +- js/PrefFilterTree.js | 2 +- js/PrefHelpers.js | 2 +- js/PrefLabelTree.js | 2 +- js/PrefUsers.js | 2 +- js/SingleUseDialog.js | 2 +- js/Toolbar.js | 2 +- js/common.js | 2 +- js/form/ComboButton.js | 2 +- js/form/DropDownButton.js | 2 +- js/tt-rss.js | 2 +- plugins/af_psql_trgm/init.js | 2 +- plugins/share/share.js | 2 +- plugins/shorten_expanded/init.js | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) (limited to 'js/FeedTree.js') diff --git a/js/App.js b/js/App.js index 97323a9bc..80fbabe82 100644 --- a/js/App.js +++ b/js/App.js @@ -423,7 +423,7 @@ const App = { '/': '/', }; - return p.replace(/[&<>"'\/]/g, m => map[m]); + return p.replace(/[&<>"'/]/g, m => map[m]); }, unescapeHtml: function(p) { if (typeof p !== 'string' || p.indexOf('&') === -1) diff --git a/js/Article.js b/js/Article.js index b38cb50c6..1f4cf931e 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,7 +1,7 @@ 'use strict' /* eslint-disable no-new */ -/* global __, ngettext, App, Headlines, xhr, dojo, dijit, PluginHost, Notify, fox */ +/* global __, ngettext, App, Headlines, xhr, PluginHost, Notify, fox */ const Article = { _scroll_reset_timeout: false, diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 9c6d1338b..43c22b5f6 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, xhr, Tables, fox */ +/* global __, Notify, App, Feeds, xhr, Tables, fox */ /* exported CommonDialogs */ const CommonDialogs = { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index e27d3c40c..3e68168fe 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -3,7 +3,7 @@ /* eslint-disable no-new */ /* global __, App, Article, Lists, fox */ -/* global xhr, dojo, dijit, Notify, Feeds */ +/* global xhr, Notify, Feeds */ /* exported Filters */ const Filters = { diff --git a/js/FeedStoreModel.js b/js/FeedStoreModel.js index fa8f730d6..ef43357d0 100644 --- a/js/FeedStoreModel.js +++ b/js/FeedStoreModel.js @@ -1,4 +1,4 @@ -/* global define, dijit */ +/* global define */ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) { diff --git a/js/FeedTree.js b/js/FeedTree.js index cd7e1f311..09288845c 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, dojo, dijit, define, App, Feeds, CommonDialogs */ +/* global __, define, App, Feeds, CommonDialogs */ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) { diff --git a/js/Feeds.js b/js/Feeds.js index 825f6f8ef..38e87b384 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, App, Headlines, xhr, dojo, dijit, fox, PluginHost, Notify, fox */ +/* global __, App, Headlines, xhr, fox, PluginHost, Notify, fox */ const Feeds = { FEED_ARCHIVED: 0, diff --git a/js/Headlines.js b/js/Headlines.js index 1547781c4..1a59ffda0 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -1,7 +1,7 @@ 'use strict'; /* global __, ngettext, Article, App */ -/* global dojo, dijit, PluginHost, Notify, xhr, Feeds */ +/* global PluginHost, Notify, xhr, Feeds */ /* global CommonDialogs */ const Headlines = { diff --git a/js/PrefFeedStore.js b/js/PrefFeedStore.js index 348cbd995..d03169acb 100644 --- a/js/PrefFeedStore.js +++ b/js/PrefFeedStore.js @@ -1,4 +1,4 @@ -/* global define, dojo */ +/* global define */ define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 7a7c5b551..92e748903 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhr, fox, App */ +/* global __, lib, define, CommonDialogs, Notify, Tables, xhr, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"], function (declare, domConstruct, checkBoxTree, array, cookie) { diff --git a/js/PrefFilterStore.js b/js/PrefFilterStore.js index f1192374a..f4cb8d0dd 100644 --- a/js/PrefFilterStore.js +++ b/js/PrefFilterStore.js @@ -1,4 +1,4 @@ -/* global define, dojo */ +/* global define */ define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 9a9728c08..64984b107 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, define, lib, dijit, dojo, xhr, App, Notify, Filters */ +/* global __, define, lib, xhr, App, Notify, Filters */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index b0b0d9c97..38fa7e243 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,7 +1,7 @@ 'use strict'; /* eslint-disable no-new */ -/* global __, dijit, dojo, Tables, Notify, xhr, App, fox */ +/* global __, Tables, Notify, xhr, App, fox */ const Helpers = { AppPasswords: { diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index c73a3ac46..1859906ee 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global __, define, lib, dijit, dojo, xhr, Notify, fox, App */ +/* global __, define, lib, xhr, Notify, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 362e62662..73e48b52f 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, xhr, dijit, Notify, Tables, App, fox */ +/* global __, xhr, Notify, Tables, App, fox */ const Users = { reload: function(sort) { diff --git a/js/SingleUseDialog.js b/js/SingleUseDialog.js index 2de6f83ff..b38b3f969 100644 --- a/js/SingleUseDialog.js +++ b/js/SingleUseDialog.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global dijit, define */ +/* global define */ define(["dojo/_base/declare", "dijit/Dialog"], function (declare) { return declare("fox.SingleUseDialog", dijit.Dialog, { create: function(params) { diff --git a/js/Toolbar.js b/js/Toolbar.js index d4993e713..b7c2a0898 100755 --- a/js/Toolbar.js +++ b/js/Toolbar.js @@ -1,4 +1,4 @@ -/* global dijit, define */ +/* global define */ define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) { return declare("fox.Toolbar", dijit.Toolbar, { diff --git a/js/common.js b/js/common.js index cdc6cd6cc..bccd0dcbb 100755 --- a/js/common.js +++ b/js/common.js @@ -1,6 +1,6 @@ 'use strict'; -/* global dijit, App, dojo, __csrf_token */ +/* global App, __csrf_token */ /* eslint-disable no-new */ /* exported __ */ diff --git a/js/form/ComboButton.js b/js/form/ComboButton.js index 2ad4bf123..4c97809e4 100755 --- a/js/form/ComboButton.js +++ b/js/form/ComboButton.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global dijit, define */ +/* global define */ define(["dojo/_base/declare", "dijit/form/ComboButton"], function (declare) { return declare("fox.form.ComboButton", dijit.form.ComboButton, { startup: function() { diff --git a/js/form/DropDownButton.js b/js/form/DropDownButton.js index d5ea39726..357d5de91 100755 --- a/js/form/DropDownButton.js +++ b/js/form/DropDownButton.js @@ -1,5 +1,5 @@ /* eslint-disable prefer-rest-params */ -/* global dijit, define */ +/* global define */ define(["dojo/_base/declare", "dijit/form/DropDownButton"], function (declare) { return declare("fox.form.DropDownButton", dijit.form.DropDownButton, { startup: function() { diff --git a/js/tt-rss.js b/js/tt-rss.js index 8e0401d80..2af9d32ff 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,6 +1,6 @@ 'use strict' -/* global require, App, dojo */ +/* global require, App */ /* exported Plugins */ const Plugins = {}; diff --git a/plugins/af_psql_trgm/init.js b/plugins/af_psql_trgm/init.js index f3662a389..e57f11564 100644 --- a/plugins/af_psql_trgm/init.js +++ b/plugins/af_psql_trgm/init.js @@ -1,4 +1,4 @@ -/* global dijit, dojo, Plugins, xhr, __ */ +/* global Plugins, xhr, __ */ Plugins.Psql_Trgm = { showRelated: function (id) { diff --git a/plugins/share/share.js b/plugins/share/share.js index 1be9db682..f27e06678 100644 --- a/plugins/share/share.js +++ b/plugins/share/share.js @@ -1,4 +1,4 @@ -/* global dojo, Plugins, App, Notify, fox, xhr, __ */ +/* global Plugins, App, Notify, fox, xhr, __ */ Plugins.Share = { shareArticle: function(id) { diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index bc3e35ff6..a89fe8e92 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -1,4 +1,4 @@ -/* global Plugins, __, require, PluginHost, App, dojo */ +/* global Plugins, __, require, PluginHost, App */ Plugins.Shorten_Expanded = { threshold: 1.5, // of window height -- cgit v1.2.3-54-g00ecf From 7211d3468456bc770f227432e98be13bf7d7d42a Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Oct 2025 22:20:13 +0000 Subject: Add a workaround+note for a FeedTree feed item's 'error' being '[]'. The backend is sending 'error' as a string (or undefined for cats). --- js/FeedTree.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/FeedTree.js') diff --git a/js/FeedTree.js b/js/FeedTree.js index 09288845c..86a396068 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -224,7 +224,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co else rc += " Is_Feed"; - if (!is_cat && item.error !== '') rc += " Error"; + // TODO: item.error is `[""]` for feeds. Need to look into what's happening on the frontend to cause that-- the backend sends a string. + // For now, just adding a check for `[""]`. + if (!is_cat && item.error !== '' && !(Array.isArray(item.error) && item.error.length === 1 && item.error[0] === '')) rc += ' Error'; if (item.unread > 0) rc += " Unread"; if (item.auxcounter > 0) rc += " Has_Aux"; if (item.markedcounter > 0) rc += " Has_Marked"; -- cgit v1.2.3-54-g00ecf From cde120b3d730dfb56fa59759bb9a7369584f551c Mon Sep 17 00:00:00 2001 From: supahgreg Date: Sun, 12 Oct 2025 22:26:51 +0000 Subject: Clean up unnecessary eslint-disable directives (per ESLint). --- js/App.js | 1 - js/Article.js | 1 - js/CommonDialogs.js | 3 --- js/CommonFilters.js | 2 -- js/FeedTree.js | 2 -- js/Headlines.js | 2 -- js/PrefFeedTree.js | 2 -- js/PrefFilterTree.js | 2 -- js/PrefHelpers.js | 1 - js/PrefLabelTree.js | 2 -- js/SingleUseDialog.js | 1 - js/common.js | 1 - js/form/ComboButton.js | 1 - js/form/DropDownButton.js | 1 - js/form/Select.js | 1 - js/form/ValidationTextArea.js | 2 -- 16 files changed, 25 deletions(-) (limited to 'js/FeedTree.js') diff --git a/js/App.js b/js/App.js index 80fbabe82..0adf291c2 100644 --- a/js/App.js +++ b/js/App.js @@ -1,6 +1,5 @@ 'use strict'; -/* eslint-disable new-cap */ /* global __, Article, Headlines, Filters, fox */ /* global xhr, PluginHost, Notify, Feeds, Cookie */ /* global CommonDialogs, Plugins */ diff --git a/js/Article.js b/js/Article.js index 1f4cf931e..f7672033c 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,6 +1,5 @@ 'use strict' -/* eslint-disable no-new */ /* global __, ngettext, App, Headlines, xhr, PluginHost, Notify, fox */ const Article = { diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 43c22b5f6..16c1f5f46 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,8 +1,5 @@ 'use strict' -/* eslint-disable new-cap */ -/* eslint-disable no-new */ - /* global __, Notify, App, Feeds, xhr, Tables, fox */ /* exported CommonDialogs */ diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 3e68168fe..54df70266 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -1,7 +1,5 @@ 'use strict' -/* eslint-disable no-new */ - /* global __, App, Article, Lists, fox */ /* global xhr, Notify, Feeds */ diff --git a/js/FeedTree.js b/js/FeedTree.js index 86a396068..f0041640d 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global __, define, App, Feeds, CommonDialogs */ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) { @@ -208,7 +207,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co return [item.updated, item.error].filter((x) => x && x !== "").join(" - "); }, getIconClass: function (item, opened) { - // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, getLabelClass: function (item/* , opened */) { diff --git a/js/Headlines.js b/js/Headlines.js index 1a59ffda0..1725998bc 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -228,7 +228,6 @@ const Headlines = { } else if (event.ctrlKey) { Headlines.select('invert', id); } else { - // eslint-disable-next-line no-lonely-if if (App.isCombinedMode()) { if (event.altKey && !in_body) { @@ -268,7 +267,6 @@ const Headlines = { return in_body; } else { - // eslint-disable-next-line no-lonely-if if (event.altKey) { Article.openInNewWindow(id); Headlines.toggleUnread(id, 0); diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 92e748903..142060488 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global __, lib, define, CommonDialogs, Notify, Tables, xhr, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"], @@ -143,7 +142,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b return rc; }, getIconClass: function (item, opened) { - // eslint-disable-next-line no-nested-ternary return (!item || this.model.store.getValue(item, 'type') === 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, reload: function() { diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 64984b107..1f20da581 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global __, define, lib, xhr, App, Notify, Filters */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { @@ -71,7 +70,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return label; }, getIconClass: function (item, opened) { - // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, getRowClass: function (item, opened) { diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 38fa7e243..fbe1d37f5 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,6 +1,5 @@ 'use strict'; -/* eslint-disable no-new */ /* global __, Tables, Notify, xhr, App, fox */ const Helpers = { diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 1859906ee..a4540deec 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global __, define, lib, xhr, Notify, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { @@ -40,7 +39,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return tnode; }, getIconClass: function (item, opened) { - // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, getSelectedLabels: function() { diff --git a/js/SingleUseDialog.js b/js/SingleUseDialog.js index b38b3f969..a207c0c44 100644 --- a/js/SingleUseDialog.js +++ b/js/SingleUseDialog.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global define */ define(["dojo/_base/declare", "dijit/Dialog"], function (declare) { return declare("fox.SingleUseDialog", dijit.Dialog, { diff --git a/js/common.js b/js/common.js index bccd0dcbb..3e8a66e5b 100755 --- a/js/common.js +++ b/js/common.js @@ -1,7 +1,6 @@ 'use strict'; /* global App, __csrf_token */ -/* eslint-disable no-new */ /* exported __ */ function __(msg) { diff --git a/js/form/ComboButton.js b/js/form/ComboButton.js index 4c97809e4..98386eead 100755 --- a/js/form/ComboButton.js +++ b/js/form/ComboButton.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global define */ define(["dojo/_base/declare", "dijit/form/ComboButton"], function (declare) { return declare("fox.form.ComboButton", dijit.form.ComboButton, { diff --git a/js/form/DropDownButton.js b/js/form/DropDownButton.js index 357d5de91..60d8e86ef 100755 --- a/js/form/DropDownButton.js +++ b/js/form/DropDownButton.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global define */ define(["dojo/_base/declare", "dijit/form/DropDownButton"], function (declare) { return declare("fox.form.DropDownButton", dijit.form.DropDownButton, { diff --git a/js/form/Select.js b/js/form/Select.js index 2259fd762..bc352e612 100755 --- a/js/form/Select.js +++ b/js/form/Select.js @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ /* global define */ // FIXME: there probably is a better, more dojo-like notation for custom data- properties define(["dojo/_base/declare", diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js index c53260f40..ced4f8fe7 100644 --- a/js/form/ValidationTextArea.js +++ b/js/form/ValidationTextArea.js @@ -1,5 +1,4 @@ // https://stackoverflow.com/questions/19317258/how-to-use-dijit-textarea-validation-dojo-1-9 -/* eslint-disable no-new */ /* global define */ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"], @@ -10,7 +9,6 @@ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "d this.constraints = {}; this.baseClass += ' dijitValidationTextArea'; }, - // eslint-disable-next-line no-template-curly-in-string templateString: "", validator: function(value, constraints) { //console.log(this, value, constraints); -- cgit v1.2.3-54-g00ecf From 7d6d32144177ce8c516092a114435988864ff6fa Mon Sep 17 00:00:00 2001 From: supahgreg Date: Mon, 13 Oct 2025 02:54:36 +0000 Subject: Address remaining ESLint 'no-undef' and 'no-unused-vars' occurrences. * https://eslint.org/docs/latest/rules/no-undef * https://eslint.org/docs/latest/rules/no-unused-vars --- js/App.js | 5 +++-- js/Article.js | 4 ++-- js/FeedTree.js | 6 +++--- js/Feeds.js | 8 ++++---- js/Headlines.js | 6 +++--- js/PrefFeedTree.js | 3 +-- js/PrefFilterTree.js | 2 +- js/form/Select.js | 2 +- js/form/ValidationMultiSelect.js | 4 ++-- js/form/ValidationTextArea.js | 4 ++-- js/utility.js | 3 ++- plugins/hotkeys_force_top/init.js | 2 ++ plugins/share/share_prefs.js | 2 +- plugins/toggle_sidebar/init.js | 2 ++ 14 files changed, 29 insertions(+), 24 deletions(-) (limited to 'js/FeedTree.js') diff --git a/js/App.js b/js/App.js index 0adf291c2..571e3373f 100644 --- a/js/App.js +++ b/js/App.js @@ -196,7 +196,7 @@ const App = { mql.addEventListener("change", () => { this.nightModeChanged(mql.matches, App.byId("theme_auto_css")); }); - } catch (e) { + } catch { console.warn("exception while trying to set MQL event listener"); } @@ -276,7 +276,7 @@ const App = { try { const results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href); return decodeURIComponent(results[1].replace(/\+/g, " ")) || 0; - } catch (e) { + } catch { return 0; } }, @@ -701,6 +701,7 @@ const App = { this.is_prefs = is_prefs; window.onerror = this.Error.onWindowError; + /* global __default_dark_theme, __default_light_theme */ this.setInitParam("csrf_token", __csrf_token); this.setInitParam("default_light_theme", __default_light_theme); this.setInitParam("default_dark_theme", __default_dark_theme); diff --git a/js/Article.js b/js/Article.js index f7672033c..88c1cb0e0 100644 --- a/js/Article.js +++ b/js/Article.js @@ -220,7 +220,7 @@ const Article = { try { c.domNode.scrollTop = 0; - } catch (e) { + } catch { } c.attr('content', article); @@ -230,7 +230,7 @@ const Article = { try { c.focus(); - } catch (e) { + } catch { } }, formatComments: function(hl) { diff --git a/js/FeedTree.js b/js/FeedTree.js index f0041640d..970efe335 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -209,10 +209,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co getIconClass: function (item, opened) { return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, - getLabelClass: function (item/* , opened */) { + getLabelClass: function (item /*, opened */) { return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; }, - getRowClass: function (item/*, opened */) { + getRowClass: function (item /*, opened */) { let rc = "dijitTreeRow dijitTreeRowFlex"; const is_cat = String(item.id).indexOf('CAT:') !== -1; @@ -490,7 +490,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co _itemsByIdentity["FEED:" + feed])[0]. getParent().item.bare_id[0]; - } catch (e) { + } catch { return false; } }, diff --git a/js/Feeds.js b/js/Feeds.js index bfe901737..f99d86943 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -544,7 +544,7 @@ const Feeds = { if (tree && tree.model) return tree.model.getFeedUnread(feed, is_cat); - } catch (e) { + } catch { // } @@ -557,7 +557,7 @@ const Feeds = { if (tree && tree.model) return tree.getFeedCategory(feed); - } catch (e) { + } catch { // } @@ -584,7 +584,7 @@ const Feeds = { if (tree && tree.model) return tree.model.setFeedValue(feed, is_cat, key, value); - } catch (e) { + } catch { // } }, @@ -595,7 +595,7 @@ const Feeds = { if (tree && tree.model) return tree.model.getFeedValue(feed, is_cat, key); - } catch (e) { + } catch { // } return ''; diff --git a/js/Headlines.js b/js/Headlines.js index 1725998bc..c27b214dc 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -16,7 +16,7 @@ const Headlines = { default_move_on_expand: true, line_scroll_offset: 120, /* px */ sticky_header_observer: new IntersectionObserver( - (entries, observer) => { + (entries) => { entries.forEach((entry) => { const header = entry.target.closest('.cdm').querySelector(".header"); @@ -32,7 +32,7 @@ const Headlines = { {threshold: [0, 1], root: document.querySelector("#headlines-frame")} ), sticky_content_observer: new IntersectionObserver( - (entries, observer) => { + (entries) => { entries.forEach((entry) => { const header = entry.target.closest('.cdm').querySelector(".header"); @@ -44,7 +44,7 @@ const Headlines = { {threshold: [0, 1], root: document.querySelector("#headlines-frame")} ), unpack_observer: new IntersectionObserver( - (entries, observer) => { + (entries) => { entries.forEach((entry) => { if (entry.intersectionRatio > 0) Article.unpack(entry.target); diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 142060488..4e9cb58a5 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -132,8 +132,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b this.inherited(arguments); this.tree.model.store.save(); }, - // eslint-disable-next-line no-unused-vars - getRowClass: function (item, opened) { + getRowClass: function (item /*, opened */) { let rc = (!item.error || item.error === '') ? "dijitTreeRow" : "dijitTreeRow Error"; diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 1f20da581..4b077259a 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -72,7 +72,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio getIconClass: function (item, opened) { return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, - getRowClass: function (item, opened) { + getRowClass: function (item /*, opened */) { const enabled = this.model.store.getValue(item, 'enabled'); return enabled ? "dijitTreeRow" : "dijitTreeRow filterDisabled"; diff --git a/js/form/Select.js b/js/form/Select.js index bc352e612..c44674e2a 100755 --- a/js/form/Select.js +++ b/js/form/Select.js @@ -24,7 +24,7 @@ define(["dojo/_base/declare", onItemClick: function(/*item, menu*/) { // }, - _setValueAttr: function(/*anything*/ newValue, /*Boolean?*/ priorityChange){ + _setValueAttr: function(/*anything*/ newValue, /*Boolean? priorityChange */){ if (this.attr('data-prevent-value-change') === 'true' && newValue !== '') return; diff --git a/js/form/ValidationMultiSelect.js b/js/form/ValidationMultiSelect.js index a0199c9c6..5a7918271 100644 --- a/js/form/ValidationMultiSelect.js +++ b/js/form/ValidationMultiSelect.js @@ -6,11 +6,11 @@ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/MultiSelect", ], function(declare, lang, MultiSelect) { return declare('fox.form.ValidationMultiSelect', [MultiSelect], { - constructor: function(params){ + constructor: function(/* params */) { this.constraints = {}; this.baseClass += ' dijitValidationMultiSelect'; }, - validate: function(/*Boolean*/ isFocused){ + validate: function(/*Boolean isFocused */) { if (this.required && this.attr('value').length === 0) return false; diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js index ced4f8fe7..a71a490c1 100644 --- a/js/form/ValidationTextArea.js +++ b/js/form/ValidationTextArea.js @@ -5,7 +5,7 @@ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "d function(declare, lang, SimpleTextarea, ValidationTextBox) { return declare('fox.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], { - constructor: function(params){ + constructor: function(/* params */) { this.constraints = {}; this.baseClass += ' dijitValidationTextArea'; }, @@ -19,7 +19,7 @@ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "d if (this.validregexp) { try { new RegExp("/" + value + "/"); - } catch (e) { + } catch { return false; } } diff --git a/js/utility.js b/js/utility.js index e5de5f300..0a9b59454 100644 --- a/js/utility.js +++ b/js/utility.js @@ -7,6 +7,7 @@ window.addEventListener("load", function() { apply_night_mode: function (is_night, link) { console.log("night mode changed to", is_night); + /* global __default_dark_theme, __default_light_theme */ const light_theme = typeof __default_light_theme !== 'undefined' ? __default_light_theme : 'themes/light.css'; const dark_theme = typeof __default_dark_theme !== 'undefined' ? __default_dark_theme : 'themes/night.css'; @@ -35,7 +36,7 @@ window.addEventListener("load", function() { mql.addEventListener("change", () => { UtilityJS.apply_night_mode(mql.matches, link); }); - } catch (e) { + } catch { console.warn("exception while trying to set MQL event listener"); } diff --git a/plugins/hotkeys_force_top/init.js b/plugins/hotkeys_force_top/init.js index 8d6280fc9..242d14ecf 100644 --- a/plugins/hotkeys_force_top/init.js +++ b/plugins/hotkeys_force_top/init.js @@ -1,3 +1,5 @@ +/* global Headlines, require */ + require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { ready(function () { Headlines.default_force_to_top = true; diff --git a/plugins/share/share_prefs.js b/plugins/share/share_prefs.js index d974af618..e2151065f 100644 --- a/plugins/share/share_prefs.js +++ b/plugins/share/share_prefs.js @@ -1,4 +1,4 @@ -/* global Plugins, Notify, xhr, App */ +/* global __, Plugins, Notify, xhr, App */ Plugins.Share = { clearKeys: function() { diff --git a/plugins/toggle_sidebar/init.js b/plugins/toggle_sidebar/init.js index 9efb06193..6ac74d3c3 100644 --- a/plugins/toggle_sidebar/init.js +++ b/plugins/toggle_sidebar/init.js @@ -1,3 +1,5 @@ +/* global Plugins, Feeds */ + Plugins.Toggle_Sidebar = { toggle: function() { Feeds.toggle(); -- cgit v1.2.3-54-g00ecf From 362e2dc28c9d28bc7644df6694b4de78a116da37 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 14 Oct 2025 03:29:37 +0000 Subject: Fix some more issues related to ESLint 'eqeqeq' changes. --- js/Article.js | 8 ++------ js/FeedTree.js | 4 +++- js/Feeds.js | 4 +++- js/Headlines.js | 55 +++++++++++++++++++++++++++---------------------------- 4 files changed, 35 insertions(+), 36 deletions(-) (limited to 'js/FeedTree.js') diff --git a/js/Article.js b/js/Article.js index 88c1cb0e0..67de59aea 100644 --- a/js/Article.js +++ b/js/Article.js @@ -445,17 +445,13 @@ const Article = { row.removeClassName("Unread"); row.addClassName("active"); - PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, row.getAttribute("data-article-id")); + PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, parseInt(row.getAttribute('data-article-id'))); } } }, getActive: function () { const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]"); - - if (row) - return row.getAttribute("data-article-id"); - else - return 0; + return row ? parseInt(row.getAttribute('data-article-id')) : 0; }, scrollByPages: function (page_offset) { App.Scrollable.scrollByPages(App.byId("content-insert"), page_offset); diff --git a/js/FeedTree.js b/js/FeedTree.js index 970efe335..01755e7b4 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -204,7 +204,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co } }, getTooltip: function (item) { - return [item.updated, item.error].filter((x) => x && x !== "").join(" - "); + // TODO: item.error is `[""]` for feeds. Need to look into what's happening on the frontend to cause that-- the backend sends a string. + // For now, just adding a check for `[""]`. + return [item.updated, item.error].filter((x) => x && x !== '' && !(Array.isArray(x) && x.length === 1 && x[0] === '')).join(' - '); }, getIconClass: function (item, opened) { return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; diff --git a/js/Feeds.js b/js/Feeds.js index f99d86943..790b64dd4 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -334,7 +334,9 @@ const Feeds = { setActive: function(id, is_cat) { console.log('setActive', id, is_cat); - id = parseInt(id); + // id might be a tag string, so check if we have something int-ish + if (Number.isInteger(Number(id))) + id = parseInt(id); window.requestIdleCallback(() => { App.Hash.set({ diff --git a/js/Headlines.js b/js/Headlines.js index c27b214dc..9ce575a84 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -59,7 +59,7 @@ const Headlines = { if (m.type === 'attributes' && ['class', 'data-score'].indexOf(m.attributeName) !== -1) { const row = m.target; - const id = row.getAttribute("data-article-id"); + const id = parseInt(row.getAttribute('data-article-id')); if (Headlines.headlines[id]) { const hl = Headlines.headlines[id]; @@ -326,7 +326,7 @@ const Headlines = { const row = rows[i]; if (this.isChildVisible(row)) { - return row.getAttribute("data-article-id"); + return parseInt(row.getAttribute('data-article-id')); } } }, @@ -350,7 +350,8 @@ const Headlines = { const last_row = hsp.previousSibling; // invoke lazy load if last article in buffer is nearly visible OR is active - if (Article.getActive() === last_row.getAttribute("data-article-id") || last_row.offsetTop - 250 <= container.scrollTop + container.offsetHeight) { + if (Article.getActive() === parseInt(last_row.getAttribute('data-article-id')) + || last_row.offsetTop - 250 <= container.scrollTop + container.offsetHeight) { hsp.innerHTML = ` ${__("Loading, please wait...")}`; Headlines.loadMore(); @@ -415,7 +416,7 @@ const Headlines = { Headlines.setCommonClasses(this.headlines.filter((h) => h.id).length); App.findAll("#headlines-frame > div[id*=RROW]").forEach((row) => { - const id = row.getAttribute("data-article-id"); + const id = parseInt(row.getAttribute('data-article-id')); const hl = this.headlines[id]; if (hl) { @@ -1189,7 +1190,7 @@ const Headlines = { App.findAll("#headlines-frame > div[id*=RROW][class*=Selected]").forEach( function (child) { - rv.push(child.getAttribute("data-article-id")); + rv.push(parseInt(child.getAttribute('data-article-id'))); }); // consider active article a honorary member of selected articles @@ -1205,7 +1206,7 @@ const Headlines = { children.forEach(function (child) { if (Element.visible(child)) { - rv.push(child.getAttribute("data-article-id")); + rv.push(parseInt(child.getAttribute('data-article-id'))); } }); @@ -1236,7 +1237,7 @@ const Headlines = { for (let i = 0; i < rows.length; i++) { const row = rows[i]; - const id = row.getAttribute('data-article-id'); + const id = parseInt(row.getAttribute('data-article-id')); if (id === start || id === stop) { if (!collecting) { @@ -1415,14 +1416,16 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Open original article"), onClick: function (/* event */) { - Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); + const id = parseInt(this.getParent().currentTarget.getAttribute('data-article-id')); + Article.openInNewWindow(id); } })); menu.addChild(new dijit.MenuItem({ label: __("Display article URL"), onClick: function (/* event */) { - Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id")); + const id = parseInt(this.getParent().currentTarget.getAttribute('data-article-id')); + Article.displayUrl(id); } })); @@ -1431,11 +1434,10 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Toggle unread"), onClick: function () { + const id = parseInt(this.getParent().currentTarget.getAttribute('data-article-id')); let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length !== 0 && ids.indexOf(id) !== -1 ? ids : [id]; + ids = ids.includes(id) ? ids : [id]; Headlines.selectionToggleUnread({ids: ids, no_error: 1}); } @@ -1444,10 +1446,10 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Toggle starred"), onClick: function () { + const id = parseInt(this.getParent().currentTarget.getAttribute('data-article-id')); + let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length !== 0 && ids.indexOf(id) !== -1 ? ids : [id]; + ids = ids.includes(id) ? ids : [id]; Headlines.selectionToggleMarked(ids); } @@ -1456,10 +1458,10 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Toggle published"), onClick: function () { + const id = parseInt(this.getParent().currentTarget.getAttribute('data-article-id')); + let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length !== 0 && ids.indexOf(id) !== -1 ? ids : [id]; + ids = ids.includes(id) ? ids : [id]; Headlines.selectionTogglePublished(ids); } @@ -1470,14 +1472,14 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Mark above as read"), onClick: function () { - Headlines.catchupRelativeTo(0, this.getParent().currentTarget.getAttribute("data-article-id")); + Headlines.catchupRelativeTo(0, parseInt(this.getParent().currentTarget.getAttribute('data-article-id'))); } })); menu.addChild(new dijit.MenuItem({ label: __("Mark below as read"), onClick: function () { - Headlines.catchupRelativeTo(1, this.getParent().currentTarget.getAttribute("data-article-id")); + Headlines.catchupRelativeTo(1, parseInt(this.getParent().currentTarget.getAttribute('data-article-id'))); } })); @@ -1499,12 +1501,10 @@ const Headlines = { label: name, labelId: bare_id, onClick: function () { + const id = parseInt(this.ownerMenu.currentTarget.getAttribute('data-article-id')); let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - - ids = ids.length !== 0 && ids.indexOf(id) !== -1 ? ids : [id]; + ids = ids.includes(id) ? ids : [id]; Headlines.selectionAssignLabel(this.labelId, ids); } @@ -1514,11 +1514,10 @@ const Headlines = { label: name, labelId: bare_id, onClick: function () { - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; + const id = parseInt(this.ownerMenu.currentTarget.getAttribute('data-article-id')); - ids = ids.length !== 0 && ids.indexOf(id) !== -1 ? ids : [id]; + let ids = Headlines.getSelected(); + ids = ids.includes(id) ? ids : [id]; Headlines.selectionRemoveLabel(this.labelId, ids); } -- cgit v1.2.3-54-g00ecf