From 6d3619724735cad09bcb24110403d21479d1fd4d Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 14 Oct 2025 22:43:09 +0000 Subject: Remove various Element and Array prototype extensions (and similar). --- js/App.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'js/App.js') diff --git a/js/App.js b/js/App.js index e82e45d0c..b88c08062 100644 --- a/js/App.js +++ b/js/App.js @@ -210,7 +210,7 @@ const App = { if (callback) { link.onload = function() { - document.querySelector("body").removeClassName("css_loading"); + document.body.classList.remove('css_loading'); callback(); }; @@ -221,9 +221,9 @@ const App = { this.nightModeChanged(mql.matches, link); - document.querySelector("head").appendChild(link); + document.head.appendChild(link); } else { - document.querySelector("body").removeClassName("css_loading"); + document.body.classList.remove('css_loading'); if (callback) callback(); } @@ -1238,15 +1238,11 @@ const App = { this.hotkey_actions["goto_prefs"] = () => { App.openPreferences(); }; - this.hotkey_actions["select_article_cursor"] = () => { - const id = Article.getUnderPointer(); - if (id) { - const row = App.byId(`RROW-${id}`); - - if (row) - row.toggleClassName("Selected"); - } - }; + this.hotkey_actions['select_article_cursor'] = () => { + const id = Article.getUnderPointer(); + if (id) + App.byId(`RROW-${id}`)?.classList.toggle('Selected'); + }; this.hotkey_actions["create_label"] = () => { CommonDialogs.addLabel(); }; -- cgit v1.2.3-54-g00ecf From 6bd52b28c201c2afb43397c1413000d47563da0b Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 14 Oct 2025 23:18:13 +0000 Subject: Remove 'App.findAll()', which was essentially an alias of 'document.querySelectorAll()'. --- js/App.js | 5 +---- js/Article.js | 2 +- js/CommonFilters.js | 8 ++------ js/Feeds.js | 12 ++++-------- js/Headlines.js | 40 ++++++++++++++++++++-------------------- js/PrefFilterTree.js | 2 +- js/common.js | 6 ------ plugins/note/note.js | 12 ++++-------- 8 files changed, 33 insertions(+), 54 deletions(-) (limited to 'js/App.js') diff --git a/js/App.js b/js/App.js index b88c08062..05816516e 100644 --- a/js/App.js +++ b/js/App.js @@ -146,9 +146,6 @@ const App = { find: function(query) { return document.querySelector(query) }, - findAll: function(query) { - return document.querySelectorAll(query); - }, dialogOf: function (elem) { // elem could be a Dijit widget @@ -408,7 +405,7 @@ const App = { dojo.destroy(d.domNode); }); - App.findAll("#" + root + " *").forEach(function (i) { + document.querySelectorAll(`#${root} *`).forEach(function (i) { i.parentNode ? i.parentNode.removeChild(i) : true; }); }, diff --git a/js/Article.js b/js/Article.js index a9684c755..4a640ce43 100644 --- a/js/Article.js +++ b/js/Article.js @@ -425,7 +425,7 @@ const Article = { if (id !== Article.getActive()) { console.log("setActive", id, "was", Article.getActive()); - App.findAll("div[id*=RROW][class*=active]").forEach((row) => { + document.querySelectorAll('div[id*=RROW][class*=active]').forEach((row) => { row.classList.remove('active'); if (App.isCombinedMode() && !App.getInitParam("cdm_expanded")) diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 460107c58..8054e4212 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -374,14 +374,10 @@ const Filters = { this.editRule(); }, deleteAction: function () { - App.findAll("#filterDlg_Actions li[class*=Selected]").forEach(function (e) { - e.parentNode.removeChild(e) - }); + document.querySelectorAll('#filterDlg_Actions li[class*=Selected]').forEach(e => e.parentNode.removeChild(e)); }, deleteRule: function () { - App.findAll("#filterDlg_Matches li[class*=Selected]").forEach(function (e) { - e.parentNode.removeChild(e) - }); + document.querySelectorAll('#filterDlg_Matches li[class*=Selected]').forEach(e => e.parentNode.removeChild(e)); }, execute: function () { if (this.validate()) { diff --git a/js/Feeds.js b/js/Feeds.js index 29ae72558..69c2cf986 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -383,8 +383,8 @@ const Feeds = { if (tree) return tree.hideRead(hide, App.getInitParam("hide_read_shows_special"));*/ - App.findAll("body")[0].setAttribute("hide-read-feeds", !!hide); - App.findAll("body")[0].setAttribute("hide-read-shows-special", !!App.getInitParam("hide_read_shows_special")); + document.body.setAttribute('hide-read-feeds', !!hide); + document.body.setAttribute('hide-read-shows-special', !!App.getInitParam('hide_read_shows_special')); }, open: function(params) { const feed = params.feed; @@ -531,12 +531,8 @@ const Feeds = { const str = __("Mark all articles in %s as read?").replace("%s", title); if (App.getInitParam("confirm_feed_catchup") !== 1 || confirm(str)) { - - const rows = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread][data-orig-feed-id='" + id + "']"); - - rows.forEach((row) => { - row.classList.remove('Unread'); - }) + document.querySelectorAll("#headlines-frame > div[id*=RROW][class*=Unread][data-orig-feed-id='" + id + "']") + .forEach(row => row.classList.remove('Unread')); } }, getUnread: function(feed, is_cat) { diff --git a/js/Headlines.js b/js/Headlines.js index 1cc91f04a..2a7831651 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -290,8 +290,8 @@ const Headlines = { }, loadMore: function () { const view_mode = dijit.byId("toolbar-main").getValues().view_mode; - const unread_in_buffer = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread]").length; - const num_all = App.findAll("#headlines-frame > div[id*=RROW]").length; + const unread_in_buffer = document.querySelectorAll('#headlines-frame > div[id*=RROW][class*=Unread]').length; + const num_all = document.querySelectorAll('#headlines-frame > div[id*=RROW]').length; const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); // TODO implement marked & published @@ -320,7 +320,7 @@ const Headlines = { return App.Scrollable.isChildVisible(elem, App.byId("headlines-frame")); }, firstVisible: function () { - const rows = App.findAll("#headlines-frame > div[id*=RROW]"); + const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW]'); for (let i = 0; i < rows.length; i++) { const row = rows[i]; @@ -331,7 +331,7 @@ const Headlines = { } }, unpackVisible: function(container) { - const rows = App.findAll("#headlines-frame > div[id*=RROW][data-content].cdm"); + const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW][data-content].cdm'); for (let i = 0; i < rows.length; i++) { if (App.Scrollable.isChildVisible(rows[i], container)) { @@ -370,7 +370,7 @@ const Headlines = { if (App.getInitParam("cdm_auto_catchup")) { - const rows = App.findAll("#headlines-frame > div[id*=RROW][class*=Unread]"); + const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW][class*=Unread]'); for (let i = 0; i < rows.length; i++) { const row = rows[i]; @@ -413,7 +413,7 @@ const Headlines = { // TODO: wrap headline elements into a knockoutjs model to prevent all this stuff Headlines.setCommonClasses(this.headlines.filter((h) => h.id).length); - App.findAll("#headlines-frame > div[id*=RROW]").forEach((row) => { + document.querySelectorAll('#headlines-frame > div[id*=RROW]').forEach((row) => { const id = parseInt(row.getAttribute('data-article-id')); const hl = this.headlines[id]; @@ -436,16 +436,16 @@ const Headlines = { } }); - App.findAll(".cdm .header-sticky-guard").forEach((e) => { + document.querySelectorAll('.cdm .header-sticky-guard').forEach((e) => { this.sticky_header_observer.observe(e) }); - App.findAll(".cdm .content").forEach((e) => { + document.querySelectorAll('.cdm .content').forEach((e) => { this.sticky_content_observer.observe(e) }); if (App.getInitParam("cdm_expanded")) - App.findAll("#headlines-frame > div[id*=RROW].cdm").forEach((e) => { + document.querySelectorAll('#headlines-frame > div[id*=RROW].cdm').forEach((e) => { this.unpack_observer.observe(e) }); @@ -893,16 +893,16 @@ const Headlines = { } } - App.findAll(".cdm .header-sticky-guard").forEach((e) => { + document.querySelectorAll('.cdm .header-sticky-guard').forEach((e) => { this.sticky_header_observer.observe(e) }); - App.findAll(".cdm .content").forEach((e) => { + document.querySelectorAll('.cdm .content').forEach((e) => { this.sticky_content_observer.observe(e) }); - if (App.getInitParam("cdm_expanded")) - App.findAll("#headlines-frame > div[id*=RROW].cdm").forEach((e) => { + if (App.getInitParam('cdm_expanded')) + document.querySelectorAll('#headlines-frame > div[id*=RROW].cdm').forEach((e) => { this.unpack_observer.observe(e) }); @@ -1176,8 +1176,8 @@ const Headlines = { }); }, getSelected: function () { - const selected = App.findAll("#headlines-frame > div[id*=RROW][class*=Selected]") - .map(child => parseInt(child.getAttribute('data-article-id'))); + const selected = Array.from(document.querySelectorAll('#headlines-frame > div[id*=RROW][class*=Selected]'), + child => parseInt(child.getAttribute('data-article-id'))); const active = Article.getActive(); @@ -1189,7 +1189,7 @@ const Headlines = { getLoaded: function () { const rv = []; - const children = App.findAll("#headlines-frame > div[id*=RROW-]"); + const children = document.querySelectorAll('#headlines-frame > div[id*=RROW-]'); children.forEach(function (child) { if (Element.visible(child)) { @@ -1218,7 +1218,7 @@ const Headlines = { if (start === stop) return [start]; - const rows = App.findAll("#headlines-frame > div[id*=RROW]"); + const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW]'); const results = []; let collecting = false; @@ -1265,7 +1265,7 @@ const Headlines = { console.warn("select: unknown mode", mode); } - App.findAll(query).forEach((row) => { + document.querySelectorAll(query).forEach((row) => { switch (mode) { case 'none': @@ -1359,7 +1359,7 @@ const Headlines = { this.headlines[data.id].tags = data.tags; } - App.findAll(`span[data-tags-for="${data.id}"`).forEach((ctr) => { + document.querySelectorAll(`span[data-tags-for="${data.id}"`).forEach((ctr) => { ctr.innerHTML = Article.renderTags(data.id, data.tags); }); } @@ -1372,7 +1372,7 @@ const Headlines = { this.headlines[row.id].labels = row.labels; } - App.findAll(`span[data-labels-for="${row.id}"]`).forEach((ctr) => { + document.querySelectorAll(`span[data-labels-for="${row.id}"]`).forEach((ctr) => { ctr.innerHTML = Article.renderLabels(row.id, row.labels); }); }); diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 4b077259a..ade44dc0a 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -111,7 +111,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio }); }, hideOrShowFilterRules(hide) { - App.findAll("body")[0].setAttribute("hide-filter-rules", !!hide); + document.body.setAttribute('hide-filter-rules', !!hide); }, toggleRules: function() { const hide = !parseInt(localStorage.getItem("ttrss:hide-filter-rules")); diff --git a/js/common.js b/js/common.js index b981f0141..2d5e63f44 100755 --- a/js/common.js +++ b/js/common.js @@ -22,12 +22,6 @@ function $(id) { return document.getElementById(id); } -/* exported $$ */ -function $$(query) { - console.warn("FIXME: please use App.findAll() or document.querySelectorAll() instead of $$():", query); - return document.querySelectorAll(query); -} - // polyfill for safari https://raw.githubusercontent.com/pladaria/requestidlecallback-polyfill/master/index.js window.requestIdleCallback = window.requestIdleCallback || diff --git a/plugins/note/note.js b/plugins/note/note.js index 00deb0543..98b639358 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -5,7 +5,7 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { Plugins.Note = { set_click_handler: function() { - App.findAll(".article-note[data-note-for]").forEach((note) => { + document.querySelectorAll('.article-note[data-note-for]').forEach((note) => { note.onclick = function() { Plugins.Note.edit(this.getAttribute('data-note-for')); } @@ -23,13 +23,9 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { dialog.hide(); if (reply) { - App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { - elem.querySelector(".body").innerHTML = reply.note; - - if (reply.note) - elem.show(); - else - elem.hide(); + document.querySelectorAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { + elem.querySelector('.body').innerHTML = reply.note; + reply.note ? elem.show() : elem.hide(); }); } }); -- cgit v1.2.3-54-g00ecf From f85559735b794682057e5b8d3854373f4d10dbb9 Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 14 Oct 2025 23:22:00 +0000 Subject: Remove 'App.byId()', which was essentially an alias of 'document.getElementById()'. --- classes/Pref_Prefs.php | 6 +-- classes/Pref_System.php | 2 +- js/App.js | 19 ++++---- js/Article.js | 26 +++++------ js/CommonDialogs.js | 2 +- js/CommonFilters.js | 4 +- js/FeedTree.js | 4 +- js/Feeds.js | 10 ++--- js/Headlines.js | 96 ++++++++++++++++++++-------------------- js/PrefFeedTree.js | 2 +- js/PrefFilterTree.js | 4 +- js/PrefHelpers.js | 8 ++-- js/PrefLabelTree.js | 2 +- js/PrefUsers.js | 2 +- js/common.js | 8 +--- plugins/shorten_expanded/init.js | 2 +- 16 files changed, 94 insertions(+), 103 deletions(-) (limited to 'js/App.js') diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php index df0b62923..54cb4fa4f 100644 --- a/classes/Pref_Prefs.php +++ b/classes/Pref_Prefs.php @@ -345,14 +345,14 @@ class Pref_Prefs extends Handler_Protected { Notify.close(); if (reply.indexOf('ERROR: ') == 0) { - App.byId('pwd_change_infobox').innerHTML = + document.getElementById('pwd_change_infobox').innerHTML = reply.replace('ERROR: ', ''); } else { - App.byId('pwd_change_infobox').innerHTML = + document.getElementById('pwd_change_infobox').innerHTML = reply.replace('ERROR: ', ''); - const warn = App.byId('default_pass_warning'); + const warn = document.getElementById('default_pass_warning'); if (warn) Element.hide(warn); } diff --git a/classes/Pref_System.php b/classes/Pref_System.php index 7946dc293..1839c4a51 100644 --- a/classes/Pref_System.php +++ b/classes/Pref_System.php @@ -209,7 +209,7 @@ class Pref_System extends Handler_Administrative { evt.preventDefault(); if (this.validate()) { xhr.json("backend.php", this.getValues(), (reply) => { - const msg = App.byId("mail-test-result"); + const msg = document.getElementById("mail-test-result"); if (reply.rc) { msg.innerHTML = __("Mail sent."); diff --git a/js/App.js b/js/App.js index 05816516e..efc5d399c 100644 --- a/js/App.js +++ b/js/App.js @@ -140,9 +140,6 @@ const App = { } } }, - byId: function(id) { - return document.getElementById(id); - }, find: function(query) { return document.querySelector(query) }, @@ -190,12 +187,12 @@ const App = { } }, setupNightModeDetection: function(callback) { - if (!App.byId("theme_css")) { + if (!document.getElementById("theme_css")) { const mql = window.matchMedia('(prefers-color-scheme: dark)'); try { mql.addEventListener("change", () => { - this.nightModeChanged(mql.matches, App.byId("theme_auto_css")); + this.nightModeChanged(mql.matches, document.getElementById("theme_auto_css")); }); } catch { console.warn("exception while trying to set MQL event listener"); @@ -295,7 +292,7 @@ const App = { dijit.byId("loading_bar").update({progress: this._loading_progress}); if (this._loading_progress >= 90) { - App.byId("overlay").hide(); + document.getElementById("overlay").hide(); } }, @@ -352,7 +349,7 @@ const App = { if (!this.hotkey_prefix && hotkeys_map[0].indexOf(keychar) !== -1) { this.hotkey_prefix = keychar; - App.byId("cmdline").innerHTML = keychar; + document.getElementById("cmdline").innerHTML = keychar; Element.show("cmdline"); window.clearTimeout(this.hotkey_prefix_timeout); @@ -562,7 +559,7 @@ const App = { break; case "cdm_auto_catchup": { - const headlines = App.byId("headlines-frame"); + const headlines = document.getElementById("headlines-frame"); // we could be in preferences if (headlines) @@ -873,7 +870,7 @@ const App = { .then((reply) => { console.log('update reply', reply); - const icon = App.byId("updates-available"); + const icon = document.getElementById("updates-available"); if (reply.changeset.id || reply.plugins.length > 0) { icon.show(); @@ -933,7 +930,7 @@ const App = { this._widescreen_mode = wide; const article_id = Article.getActive(); - const headlines_frame = App.byId("headlines-frame"); + const headlines_frame = document.getElementById("headlines-frame"); const content_insert = dijit.byId("content-insert"); // TODO: setStyle stuff should probably be handled by CSS @@ -1238,7 +1235,7 @@ const App = { this.hotkey_actions['select_article_cursor'] = () => { const id = Article.getUnderPointer(); if (id) - App.byId(`RROW-${id}`)?.classList.toggle('Selected'); + document.getElementById(`RROW-${id}`)?.classList.toggle('Selected'); }; this.hotkey_actions["create_label"] = () => { CommonDialogs.addLabel(); diff --git a/js/Article.js b/js/Article.js index 4a640ce43..f662abaf2 100644 --- a/js/Article.js +++ b/js/Article.js @@ -36,7 +36,7 @@ const Article = { if (!isNaN(parseInt(score))) { ids.forEach((id) => { - const row = App.byId(`RROW-${id}`); + const row = document.getElementById(`RROW-${id}`); if (row) { row.setAttribute("data-score", score); @@ -88,7 +88,7 @@ const Article = { w.location = url; }, cdmToggleGridSpan: function(id) { - const row = App.byId(`RROW-${id}`); + const row = document.getElementById(`RROW-${id}`); if (row) { row.classList.toggle('grid-span-row'); @@ -98,7 +98,7 @@ const Article = { } }, cdmUnsetActive: function (event) { - const row = App.byId(`RROW-${Article.getActive()}`); + const row = document.getElementById(`RROW-${Article.getActive()}`); if (row) { row.classList.remove('active'); @@ -258,7 +258,7 @@ const Article = { container.innerHTML += " "; // in expandable mode, save content for later, so that we can pack unfocused rows back - if (App.isCombinedMode() && App.byId('main').classList.contains('expandable')) + if (App.isCombinedMode() && document.getElementById('main').classList.contains('expandable')) row.setAttribute("data-content-original", row.getAttribute("data-content")); row.setAttribute("data-is-packed", "0"); @@ -325,7 +325,7 @@ const Article = { return false; }, autocompleteInject: function(elem, targetId) { - const target = App.byId(targetId); + const target = document.getElementById(targetId); if (!target) return; @@ -388,15 +388,15 @@ const Article = { xhr.json("backend.php", {op: "Article", method: "printArticleTags", id: id}, (reply) => { - dijit.getEnclosingWidget(App.byId("tags_str")) + dijit.getEnclosingWidget(document.getElementById("tags_str")) .attr('value', reply.tags.join(", ")) .attr('disabled', false); - App.byId('tags_str').onkeyup = (e) => { + document.getElementById('tags_str').onkeyup = (e) => { const last_tag = e.target.value.split(',').pop().trim(); xhr.json("backend.php", {op: 'Article', method: 'completeTags', search: last_tag}, (data) => { - App.byId("tags_choices").innerHTML = `${data.map((tag) => + document.getElementById("tags_choices").innerHTML = `${data.map((tag) => `${tag}` ) .join(', ')}` }); @@ -410,8 +410,8 @@ const Article = { cdmMoveToId: function (id, params = {}) { const force_to_top = params.force_to_top || false; - const ctr = App.byId("headlines-frame"); - const row = App.byId(`RROW-${id}`); + const ctr = document.getElementById("headlines-frame"); + const row = document.getElementById(`RROW-${id}`); if (ctr && row) { const grid_gap = parseInt(window.getComputedStyle(ctr).gridGap) || 0; @@ -432,7 +432,7 @@ const Article = { Article.pack(row); }); - const row = App.byId(`RROW-${id}`); + const row = document.getElementById(`RROW-${id}`); if (row) { Article.unpack(row); @@ -449,10 +449,10 @@ const Article = { return row ? parseInt(row.getAttribute('data-article-id')) : 0; }, scrollByPages: function (page_offset) { - App.Scrollable.scrollByPages(App.byId("content-insert"), page_offset); + App.Scrollable.scrollByPages(document.getElementById("content-insert"), page_offset); }, scroll: function (offset) { - App.Scrollable.scroll(App.byId("content-insert"), offset); + App.Scrollable.scroll(document.getElementById("content-insert"), offset); }, mouseIn: function (id) { this.post_under_pointer = id; diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 16c1f5f46..bf70902b7 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -116,7 +116,7 @@ const CommonDialogs = { `, show_error: function (msg, additional_info) { - const elem = App.byId("fadd_error_message"); + const elem = document.getElementById("fadd_error_message"); elem.innerHTML = `${msg}${additional_info ? `

${__('Additional information')}

${additional_info}` : ''}`; diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 8054e4212..a7f84ab09 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -166,7 +166,7 @@ const Filters = { title: ruleStr ? __("Edit rule") : __("Add rule"), execute: function () { if (this.validate()) { - dialog.insertRule(App.byId("filterDlg_Matches"), replaceNode); + dialog.insertRule(document.getElementById("filterDlg_Matches"), replaceNode); this.hide(); } }, @@ -262,7 +262,7 @@ const Filters = { }, execute: function () { if (this.validate()) { - dialog.insertAction(App.byId("filterDlg_Actions"), replaceNode); + dialog.insertAction(document.getElementById("filterDlg_Actions"), replaceNode); this.hide(); } }, diff --git a/js/FeedTree.js b/js/FeedTree.js index 4e6bac8a6..06ebceff2 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -309,7 +309,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co // focus headlines to route key events there setTimeout(() => { - App.byId("headlines-frame").focus(); + document.getElementById("headlines-frame").focus(); if (treeNode) { const node = treeNode.rowNode; @@ -318,7 +318,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co if (node && tree) { // scroll tree to selection if needed if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) { - App.byId("feedTree").scrollTop = node.offsetTop; + document.getElementById("feedTree").scrollTop = node.offsetTop; } } } diff --git a/js/Feeds.js b/js/Feeds.js index 69c2cf986..1328b704a 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -227,7 +227,7 @@ const Feeds = { dojo.disconnect(tmph); }); - App.byId("feeds-holder").appendChild(tree.domNode); + document.getElementById("feeds-holder").appendChild(tree.domNode); const tmph2 = dojo.connect(tree, 'onLoad', function () { dojo.disconnect(tmph2); @@ -247,13 +247,13 @@ const Feeds = { } }, onHide: function() { - App.byId("feeds-holder_splitter").hide(); + document.getElementById("feeds-holder_splitter").hide(); dijit.byId("main").resize(); Headlines.updateCurrentUnread(); }, onShow: function() { - App.byId("feeds-holder_splitter").show(); + document.getElementById("feeds-holder_splitter").show(); dijit.byId("main").resize(); Headlines.updateCurrentUnread(); @@ -261,7 +261,7 @@ const Feeds = { init: function() { console.log("in feedlist init"); - this._feeds_holder_observer.observe(App.byId("feeds-holder")); + this._feeds_holder_observer.observe(document.getElementById("feeds-holder")); App.setLoadingProgress(50); @@ -350,7 +350,7 @@ const Feeds = { this._active_feed_id = id; this._active_feed_is_cat = is_cat; - const container = App.byId("headlines-frame"); + const container = document.getElementById("headlines-frame"); // TODO @deprecated: these two should be removed (replaced with data- attributes below) container.setAttribute("feed-id", id); diff --git a/js/Headlines.js b/js/Headlines.js index 2a7831651..da4587a34 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -239,7 +239,7 @@ const Headlines = { Headlines.select('none'); - const scroll_position_A = App.byId(`RROW-${id}`).offsetTop - App.byId("headlines-frame").scrollTop; + const scroll_position_A = document.getElementById(`RROW-${id}`).offsetTop - document.getElementById("headlines-frame").scrollTop; Article.setActive(id); @@ -250,10 +250,10 @@ const Headlines = { Headlines.toggleUnread(id, 0); } else { - const scroll_position_B = App.byId(`RROW-${id}`).offsetTop - App.byId("headlines-frame").scrollTop; + const scroll_position_B = document.getElementById(`RROW-${id}`).offsetTop - document.getElementById("headlines-frame").scrollTop; // this would only work if there's enough space - App.byId("headlines-frame").scrollTop -= scroll_position_A-scroll_position_B; + document.getElementById("headlines-frame").scrollTop -= scroll_position_A-scroll_position_B; if (this.default_move_on_expand) Article.cdmMoveToId(id); @@ -280,7 +280,7 @@ const Headlines = { return false; }, initScrollHandler: function () { - App.byId("headlines-frame").onscroll = (event) => { + document.getElementById("headlines-frame").onscroll = (event) => { clearTimeout(this._headlines_scroll_timeout); this._headlines_scroll_timeout = window.setTimeout(function () { //console.log('done scrolling', event); @@ -317,7 +317,7 @@ const Headlines = { Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true}); }, isChildVisible: function (elem) { - return App.Scrollable.isChildVisible(elem, App.byId("headlines-frame")); + return App.Scrollable.isChildVisible(elem, document.getElementById("headlines-frame")); }, firstVisible: function () { const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW]'); @@ -343,8 +343,8 @@ const Headlines = { scrollHandler: function (/*event*/) { try { if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) { - const hsp = App.byId("headlines-spacer"); - const container = App.byId("headlines-frame"); + const hsp = document.getElementById("headlines-spacer"); + const container = document.getElementById("headlines-frame"); if (hsp && hsp.previousSibling) { const last_row = hsp.previousSibling; @@ -361,7 +361,7 @@ const Headlines = { } if (App.isCombinedMode() && App.getInitParam("cdm_expanded")) { - const container = App.byId("headlines-frame") + const container = document.getElementById("headlines-frame") /* don't do anything until there was some scrolling */ if (container.scrollTop > 0) @@ -375,7 +375,7 @@ const Headlines = { for (let i = 0; i < rows.length; i++) { const row = rows[i]; - if (App.byId("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) { + if (document.getElementById("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) { row.classList.remove('Unread'); } else { break; @@ -393,7 +393,7 @@ const Headlines = { return this.headlines[id]; }, setCommonClasses: function (headlines_count) { - const container = App.byId("headlines-frame"); + const container = document.getElementById("headlines-frame"); container.classList.remove('cdm', 'normal'); @@ -404,10 +404,10 @@ const Headlines = { container.setAttribute("data-is-cdm-expanded", App.getInitParam("cdm_expanded")); // for floating title because it's placed outside of headlines-frame - App.byId('main').classList.remove('expandable', 'expanded'); + document.getElementById('main').classList.remove('expandable', 'expanded'); if (App.isCombinedMode()) - App.byId('main').classList.add(App.getInitParam('cdm_expanded') ? 'expanded' : 'expandable'); + document.getElementById('main').classList.add(App.getInitParam('cdm_expanded') ? 'expanded' : 'expandable'); }, renderAgain: function () { // TODO: wrap headline elements into a knockoutjs model to prevent all this stuff @@ -476,7 +476,7 @@ const Headlines = { const tmp = document.createElement("div"); tmp.innerHTML = vgrhdr; - App.byId("headlines-frame").appendChild(tmp.firstChild); + document.getElementById("headlines-frame").appendChild(tmp.firstChild); this.vgroup_last_feed = hl.feed_id; } @@ -609,11 +609,11 @@ const Headlines = { return tmp.firstChild; }, updateCurrentUnread: function () { - if (App.byId("feed_current_unread")) { + if (document.getElementById("feed_current_unread")) { const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); if (feed_unread > 0 && !Element.visible("feeds-holder")) { - App.byId("feed_current_unread").innerText = feed_unread; + document.getElementById("feed_current_unread").innerText = feed_unread; Element.show("feed_current_unread"); } else { Element.hide("feed_current_unread"); @@ -762,18 +762,18 @@ const Headlines = { Headlines.setCommonClasses(headlines_count); /** TODO: remove @deprecated */ - App.byId("headlines-frame").setAttribute("is-vfeed", + document.getElementById("headlines-frame").setAttribute("is-vfeed", reply['headlines']['is_vfeed'] ? 1 : 0); - App.byId("headlines-frame").setAttribute("data-is-vfeed", + document.getElementById("headlines-frame").setAttribute("data-is-vfeed", reply['headlines']['is_vfeed'] ? "true" : "false"); Article.setActive(0); try { - App.byId('headlines-frame').classList.remove('smooth-scroll'); - App.byId('headlines-frame').scrollTop = 0; - App.byId('headlines-frame').classList.add('smooth-scroll'); + document.getElementById('headlines-frame').classList.remove('smooth-scroll'); + document.getElementById('headlines-frame').scrollTop = 0; + document.getElementById('headlines-frame').classList.add('smooth-scroll'); } catch (e) { console.warn(e); } @@ -781,27 +781,27 @@ const Headlines = { this.headlines = []; this.vgroup_last_feed = undefined; - /*dojo.html.set(App.byId("toolbar-headlines"), + /*dojo.html.set(document.getElementById("toolbar-headlines"), reply['headlines']['toolbar'], {parseContent: true});*/ Headlines.renderToolbar(reply['headlines']); if (typeof reply['headlines']['content'] === 'string') { - App.byId("headlines-frame").innerHTML = reply['headlines']['content']; + document.getElementById("headlines-frame").innerHTML = reply['headlines']['content']; } else { - App.byId("headlines-frame").innerHTML = ''; + document.getElementById("headlines-frame").innerHTML = ''; for (let i = 0; i < reply['headlines']['content'].length; i++) { const hl = reply['headlines']['content'][i]; - App.byId("headlines-frame").appendChild(this.render(reply['headlines'], hl)); + document.getElementById("headlines-frame").appendChild(this.render(reply['headlines'], hl)); this.headlines[parseInt(hl.id)] = hl; } } - let hsp = App.byId("headlines-spacer"); + let hsp = document.getElementById("headlines-spacer"); if (!hsp) { hsp = document.createElement("div"); @@ -821,7 +821,7 @@ const Headlines = { /* if (Feeds._search_query) { - App.byId("feed_title").innerHTML += "" + + document.getElementById("feed_title").innerHTML += "" + " (" + __("Cancel search") + ")" + ""; } */ @@ -831,7 +831,7 @@ const Headlines = { } else if (headlines_count > 0 && feed_id === Feeds.getActive() && is_cat === Feeds.activeIsCat()) { const c = dijit.byId("headlines-frame"); - let hsp = App.byId("headlines-spacer"); + let hsp = document.getElementById("headlines-spacer"); if (hsp) c.domNode.removeChild(hsp); @@ -839,13 +839,13 @@ const Headlines = { let headlines_appended = 0; if (typeof reply['headlines']['content'] === 'string') { - App.byId("headlines-frame").innerHTML = reply['headlines']['content']; + document.getElementById("headlines-frame").innerHTML = reply['headlines']['content']; } else { for (let i = 0; i < reply['headlines']['content'].length; i++) { const hl = reply['headlines']['content'][i]; if (!this.headlines[parseInt(hl.id)]) { - App.byId("headlines-frame").appendChild(this.render(reply['headlines'], hl)); + document.getElementById("headlines-frame").appendChild(this.render(reply['headlines'], hl)); this.headlines[parseInt(hl.id)] = hl; ++headlines_appended; @@ -880,7 +880,7 @@ const Headlines = { console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed); - const hsp = App.byId("headlines-spacer"); + const hsp = document.getElementById("headlines-spacer"); if (hsp) { if (first_id_changed) { @@ -948,7 +948,7 @@ const Headlines = { } ids.forEach((id) => { - const row = App.byId(`RROW-${id}`); + const row = document.getElementById(`RROW-${id}`); if (row) { switch (cmode) { @@ -987,11 +987,11 @@ const Headlines = { ids.forEach(id => this.togglePub(id)); }, toggleMark: function (id) { - App.byId(`RROW-${id}`)?.classList.toggle('marked'); + document.getElementById(`RROW-${id}`)?.classList.toggle('marked'); }, togglePub: function (id) { - App.byId(`RROW-${id}`)?.classList.toggle('published'); + document.getElementById(`RROW-${id}`)?.classList.toggle('published'); }, move: function (mode, params = {}) { const no_expand = params.no_expand || false; @@ -1002,7 +1002,7 @@ const Headlines = { let next_id = false; let current_id = Article.getActive(); - if (!Headlines.isChildVisible(App.byId(`RROW-${current_id}`))) { + if (!Headlines.isChildVisible(document.getElementById(`RROW-${current_id}`))) { console.log('active article is obscured, resetting to first visible...'); current_id = Headlines.firstVisible(); prev_id = current_id; @@ -1041,15 +1041,15 @@ const Headlines = { } } else if (App.isCombinedMode()) { // try to show hsp if no next article exists, in case there's useful information like first_id_changed etc - const row = App.byId(`RROW-${current_id}`); - const ctr = App.byId("headlines-frame"); + const row = document.getElementById(`RROW-${current_id}`); + const ctr = document.getElementById("headlines-frame"); if (row) { const next = row.nextSibling; // hsp has half-screen height in auto catchup mode therefore we use its first child (normally A element) if (next && Element.visible(next) && next.id === "headlines-spacer" && next.firstChild) { - const offset = App.byId("headlines-spacer").offsetTop - App.byId("headlines-frame").offsetHeight + next.firstChild.offsetHeight; + const offset = document.getElementById("headlines-spacer").offsetTop - document.getElementById("headlines-frame").offsetHeight + next.firstChild.offsetHeight; // don't jump back either if (ctr.scrollTop < offset) @@ -1061,8 +1061,8 @@ const Headlines = { if (prev_id || current_id) { if (App.isCombinedMode()) { window.requestAnimationFrame(() => { - const row = App.byId(`RROW-${current_id}`); - const ctr = App.byId("headlines-frame"); + const row = document.getElementById(`RROW-${current_id}`); + const ctr = document.getElementById("headlines-frame"); const delta_px = Math.round(row.offsetTop) - Math.round(ctr.scrollTop); console.log('moving back, delta_px', delta_px); @@ -1083,7 +1083,7 @@ const Headlines = { }, updateSelectedPrompt: function () { const count = Headlines.getSelected().length; - const elem = App.byId("selected_prompt"); + const elem = document.getElementById("selected_prompt"); if (elem) { elem.innerHTML = ngettext("%d article selected", @@ -1093,7 +1093,7 @@ const Headlines = { } }, toggleUnread: function (id, cmode) { - const row = App.byId(`RROW-${id}`); + const row = document.getElementById(`RROW-${id}`); if (row) { if (typeof cmode === "undefined") cmode = 2; @@ -1316,7 +1316,7 @@ const Headlines = { if (!below) { for (let i = 0; i < visible_ids.length; i++) { if (visible_ids[i] !== id) { - const e = App.byId(`RROW-${visible_ids[i]}`); + const e = document.getElementById(`RROW-${visible_ids[i]}`); if (e && e.classList.contains('Unread')) { ids_to_mark.push(visible_ids[i]); @@ -1328,7 +1328,7 @@ const Headlines = { } else { for (let i = visible_ids.length - 1; i >= 0; i--) { if (visible_ids[i] !== id) { - const e = App.byId(`RROW-${visible_ids[i]}`); + const e = document.getElementById(`RROW-${visible_ids[i]}`); if (e && e.classList.contains('Unread')) { ids_to_mark.push(visible_ids[i]); @@ -1347,7 +1347,7 @@ const Headlines = { if (App.getInitParam("confirm_feed_catchup") !== 1 || confirm(msg)) { for (let i = 0; i < ids_to_mark.length; i++) { - const e = App.byId(`RROW-${ids_to_mark[i]}`); + const e = document.getElementById(`RROW-${ids_to_mark[i]}`); e.classList.remove('Unread'); } } @@ -1379,8 +1379,8 @@ const Headlines = { } }, scrollToArticleId: function (id) { - const container = App.byId("headlines-frame"); - const row = App.byId(`RROW-${id}`); + const container = document.getElementById("headlines-frame"); + const row = document.getElementById(`RROW-${id}`); if (!container || !row) return; @@ -1525,10 +1525,10 @@ const Headlines = { } }, scrollByPages: function (page_offset) { - App.Scrollable.scrollByPages(App.byId("headlines-frame"), page_offset); + App.Scrollable.scrollByPages(document.getElementById("headlines-frame"), page_offset); }, scroll: function (offset) { - App.Scrollable.scroll(App.byId("headlines-frame"), offset); + App.Scrollable.scroll(document.getElementById("headlines-frame"), offset); }, initHeadlinesMenu: function () { if (!dijit.byId("headlinesMenu")) { diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 5bb8830eb..6c0329c61 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -144,7 +144,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b return (!item || this.model.store.getValue(item, 'type') === 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, reload: function() { - const searchElem = App.byId("feed_search"); + const searchElem = document.getElementById("feed_search"); const search = (searchElem) ? searchElem.value : ""; xhr.post("backend.php", { op: "Pref_Feeds", search: search }, (reply) => { diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index ade44dc0a..cf5d975f4 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,4 +1,4 @@ -/* global __, define, lib, xhr, App, Notify, Filters */ +/* global __, define, lib, xhr, Notify, Filters */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { @@ -101,7 +101,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return rv; }, reload: function() { - const user_search = App.byId("filter_search"); + const user_search = document.getElementById("filter_search"); let search = ""; if (user_search) { search = user_search.value; } diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index cf3f03bf2..f931630c8 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -8,7 +8,7 @@ const Helpers = { return Tables.getSelected("app-password-list"); }, updateContent: function(data) { - App.byId("app_passwords_holder").innerHTML = data; + document.getElementById("app_passwords_holder").innerHTML = data; dojo.parser.parse("app_passwords_holder"); }, removeSelected: function() { @@ -264,7 +264,7 @@ const Helpers = { apply: function() { xhr.post("backend.php", this.attr('value'), () => { Element.show("css_edit_apply_msg"); - App.byId("user_css_style").innerText = this.attr('value'); + document.getElementById("user_css_style").innerText = this.attr('value'); }); }, execute: function () { @@ -784,7 +784,7 @@ const Helpers = { }, OPML: { import: function() { - const opml_file = App.byId("opml_file"); + const opml_file = document.getElementById("opml_file"); if (opml_file.value.length === 0) { alert(__("Please choose an OPML file first.")); @@ -826,7 +826,7 @@ const Helpers = { dialog.show(); }; - xhr.send(new FormData(App.byId("opml_import_form"))); + xhr.send(new FormData(document.getElementById("opml_import_form"))); return false; } diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index a4540deec..f5d71020f 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -82,7 +82,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f color = bg; } - const e = App.byId(`icon-label-${id}`); + const e = document.getElementById(`icon-label-${id}`); if (e) { if (bg) e.style.color = bg; diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 73e48b52f..aa6907ded 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -5,7 +5,7 @@ const Users = { reload: function(sort) { return new Promise((resolve, reject) => { - const user_search = App.byId("user_search"); + const user_search = document.getElementById("user_search"); const search = user_search ? user_search.value : ""; xhr.post("backend.php", { op: "Pref_Users", sort: sort, search: search }, (reply) => { diff --git a/js/common.js b/js/common.js index 2d5e63f44..0d70332aa 100755 --- a/js/common.js +++ b/js/common.js @@ -16,12 +16,6 @@ function ngettext(msg1, msg2, n) { return __((parseInt(n) > 1) ? msg2 : msg1); } -/* exported $ */ -function $(id) { - console.warn("FIXME: please use App.byId() or document.getElementById() instead of $():", id); - return document.getElementById(id); -} - // polyfill for safari https://raw.githubusercontent.com/pladaria/requestidlecallback-polyfill/master/index.js window.requestIdleCallback = window.requestIdleCallback || @@ -364,7 +358,7 @@ const Notify = { kind = kind || this.KIND_GENERIC; keep = keep || false; - const notify = App.byId("notify"); + const notify = document.getElementById("notify"); window.clearTimeout(this.timeout); diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index deb3b6393..b541b750e 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -52,7 +52,7 @@ Plugins.Shorten_Expanded = { this.observer.observe(row); }, expand: function(id) { - const row = App.byId(id); + const row = document.getElementById(id); if (row) { const link = row.querySelector('.expand-prompt'); -- cgit v1.2.3-54-g00ecf From 3ff3c605b4405dcd66c6ae978566664633a2f68e Mon Sep 17 00:00:00 2001 From: supahgreg Date: Tue, 14 Oct 2025 23:26:19 +0000 Subject: Remove 'App.find()', which was essentially an alias of 'document.querySelector()'. --- js/App.js | 7 ++----- js/Feeds.js | 4 ++-- js/PrefHelpers.js | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'js/App.js') diff --git a/js/App.js b/js/App.js index efc5d399c..5befe1fe8 100644 --- a/js/App.js +++ b/js/App.js @@ -140,9 +140,6 @@ const App = { } } }, - find: function(query) { - return document.querySelector(query) - }, dialogOf: function (elem) { // elem could be a Dijit widget @@ -461,7 +458,7 @@ const App = { }, handleRpcJson: function(reply) { - const netalert = App.find(".net-alert"); + const netalert = document.querySelector('.net-alert'); if (reply) { const error = reply['error']; @@ -518,7 +515,7 @@ const App = { } if (k === "recent_log_events") { - const alert = App.find(".log-alert"); + const alert = document.querySelector('.log-alert'); if (alert) { v > 0 ? alert.show() : alert.hide(); diff --git a/js/Feeds.js b/js/Feeds.js index 1328b704a..af7a6cc54 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -143,8 +143,8 @@ const Feeds = { }, onViewModeChanged: function() { // TODO: is this still needed? - App.find("body").setAttribute("view-mode", - dijit.byId("toolbar-main").getValues().view_mode); + document.body.setAttribute('view-mode', + dijit.byId('toolbar-main').getValues().view_mode); return Feeds.reloadCurrent(''); }, diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index f931630c8..0d8702bae 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -728,7 +728,7 @@ const Helpers = { dialog.plugins_to_update.push(p.plugin); const update_button = dijit.getEnclosingWidget( - App.find(`*[data-update-btn-for-plugin="${p.plugin}"]`)); + document.querySelector(`*[data-update-btn-for-plugin="${p.plugin}"]`)); if (update_button) update_button.domNode.show(); -- cgit v1.2.3-54-g00ecf