Remove 'App.byId()', which was essentially an alias of 'document.getElementById()'.

This commit is contained in:
supahgreg 2025-10-14 23:22:00 +00:00
parent 6bd52b28c2
commit f85559735b
No known key found for this signature in database
16 changed files with 94 additions and 103 deletions

View File

@ -345,14 +345,14 @@ class Pref_Prefs extends Handler_Protected {
Notify.close(); Notify.close();
if (reply.indexOf('ERROR: ') == 0) { if (reply.indexOf('ERROR: ') == 0) {
App.byId('pwd_change_infobox').innerHTML = document.getElementById('pwd_change_infobox').innerHTML =
reply.replace('ERROR: ', ''); reply.replace('ERROR: ', '');
} else { } else {
App.byId('pwd_change_infobox').innerHTML = document.getElementById('pwd_change_infobox').innerHTML =
reply.replace('ERROR: ', ''); reply.replace('ERROR: ', '');
const warn = App.byId('default_pass_warning'); const warn = document.getElementById('default_pass_warning');
if (warn) Element.hide(warn); if (warn) Element.hide(warn);
} }

View File

@ -209,7 +209,7 @@ class Pref_System extends Handler_Administrative {
evt.preventDefault(); evt.preventDefault();
if (this.validate()) { if (this.validate()) {
xhr.json("backend.php", this.getValues(), (reply) => { xhr.json("backend.php", this.getValues(), (reply) => {
const msg = App.byId("mail-test-result"); const msg = document.getElementById("mail-test-result");
if (reply.rc) { if (reply.rc) {
msg.innerHTML = __("Mail sent."); msg.innerHTML = __("Mail sent.");

View File

@ -140,9 +140,6 @@ const App = {
} }
} }
}, },
byId: function(id) {
return document.getElementById(id);
},
find: function(query) { find: function(query) {
return document.querySelector(query) return document.querySelector(query)
}, },
@ -190,12 +187,12 @@ const App = {
} }
}, },
setupNightModeDetection: function(callback) { setupNightModeDetection: function(callback) {
if (!App.byId("theme_css")) { if (!document.getElementById("theme_css")) {
const mql = window.matchMedia('(prefers-color-scheme: dark)'); const mql = window.matchMedia('(prefers-color-scheme: dark)');
try { try {
mql.addEventListener("change", () => { mql.addEventListener("change", () => {
this.nightModeChanged(mql.matches, App.byId("theme_auto_css")); this.nightModeChanged(mql.matches, document.getElementById("theme_auto_css"));
}); });
} catch { } catch {
console.warn("exception while trying to set MQL event listener"); 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}); dijit.byId("loading_bar").update({progress: this._loading_progress});
if (this._loading_progress >= 90) { 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) { if (!this.hotkey_prefix && hotkeys_map[0].indexOf(keychar) !== -1) {
this.hotkey_prefix = keychar; this.hotkey_prefix = keychar;
App.byId("cmdline").innerHTML = keychar; document.getElementById("cmdline").innerHTML = keychar;
Element.show("cmdline"); Element.show("cmdline");
window.clearTimeout(this.hotkey_prefix_timeout); window.clearTimeout(this.hotkey_prefix_timeout);
@ -562,7 +559,7 @@ const App = {
break; break;
case "cdm_auto_catchup": case "cdm_auto_catchup":
{ {
const headlines = App.byId("headlines-frame"); const headlines = document.getElementById("headlines-frame");
// we could be in preferences // we could be in preferences
if (headlines) if (headlines)
@ -873,7 +870,7 @@ const App = {
.then((reply) => { .then((reply) => {
console.log('update reply', 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) { if (reply.changeset.id || reply.plugins.length > 0) {
icon.show(); icon.show();
@ -933,7 +930,7 @@ const App = {
this._widescreen_mode = wide; this._widescreen_mode = wide;
const article_id = Article.getActive(); 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"); const content_insert = dijit.byId("content-insert");
// TODO: setStyle stuff should probably be handled by CSS // TODO: setStyle stuff should probably be handled by CSS
@ -1238,7 +1235,7 @@ const App = {
this.hotkey_actions['select_article_cursor'] = () => { this.hotkey_actions['select_article_cursor'] = () => {
const id = Article.getUnderPointer(); const id = Article.getUnderPointer();
if (id) if (id)
App.byId(`RROW-${id}`)?.classList.toggle('Selected'); document.getElementById(`RROW-${id}`)?.classList.toggle('Selected');
}; };
this.hotkey_actions["create_label"] = () => { this.hotkey_actions["create_label"] = () => {
CommonDialogs.addLabel(); CommonDialogs.addLabel();

View File

@ -36,7 +36,7 @@ const Article = {
if (!isNaN(parseInt(score))) { if (!isNaN(parseInt(score))) {
ids.forEach((id) => { ids.forEach((id) => {
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (row) { if (row) {
row.setAttribute("data-score", score); row.setAttribute("data-score", score);
@ -88,7 +88,7 @@ const Article = {
w.location = url; w.location = url;
}, },
cdmToggleGridSpan: function(id) { cdmToggleGridSpan: function(id) {
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (row) { if (row) {
row.classList.toggle('grid-span-row'); row.classList.toggle('grid-span-row');
@ -98,7 +98,7 @@ const Article = {
} }
}, },
cdmUnsetActive: function (event) { cdmUnsetActive: function (event) {
const row = App.byId(`RROW-${Article.getActive()}`); const row = document.getElementById(`RROW-${Article.getActive()}`);
if (row) { if (row) {
row.classList.remove('active'); row.classList.remove('active');
@ -258,7 +258,7 @@ const Article = {
container.innerHTML += " "; container.innerHTML += " ";
// in expandable mode, save content for later, so that we can pack unfocused rows back // 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-content-original", row.getAttribute("data-content"));
row.setAttribute("data-is-packed", "0"); row.setAttribute("data-is-packed", "0");
@ -325,7 +325,7 @@ const Article = {
return false; return false;
}, },
autocompleteInject: function(elem, targetId) { autocompleteInject: function(elem, targetId) {
const target = App.byId(targetId); const target = document.getElementById(targetId);
if (!target) if (!target)
return; return;
@ -388,15 +388,15 @@ const Article = {
xhr.json("backend.php", {op: "Article", method: "printArticleTags", id: id}, (reply) => { 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('value', reply.tags.join(", "))
.attr('disabled', false); .attr('disabled', false);
App.byId('tags_str').onkeyup = (e) => { document.getElementById('tags_str').onkeyup = (e) => {
const last_tag = e.target.value.split(',').pop().trim(); const last_tag = e.target.value.split(',').pop().trim();
xhr.json("backend.php", {op: 'Article', method: 'completeTags', search: last_tag}, (data) => { 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) =>
`<a href="#" onclick="Article.autocompleteInject(this, 'tags_str')">${tag}</a>` ) `<a href="#" onclick="Article.autocompleteInject(this, 'tags_str')">${tag}</a>` )
.join(', ')}` .join(', ')}`
}); });
@ -410,8 +410,8 @@ const Article = {
cdmMoveToId: function (id, params = {}) { cdmMoveToId: function (id, params = {}) {
const force_to_top = params.force_to_top || false; const force_to_top = params.force_to_top || false;
const ctr = App.byId("headlines-frame"); const ctr = document.getElementById("headlines-frame");
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (ctr && row) { if (ctr && row) {
const grid_gap = parseInt(window.getComputedStyle(ctr).gridGap) || 0; const grid_gap = parseInt(window.getComputedStyle(ctr).gridGap) || 0;
@ -432,7 +432,7 @@ const Article = {
Article.pack(row); Article.pack(row);
}); });
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (row) { if (row) {
Article.unpack(row); Article.unpack(row);
@ -449,10 +449,10 @@ const Article = {
return row ? parseInt(row.getAttribute('data-article-id')) : 0; return row ? parseInt(row.getAttribute('data-article-id')) : 0;
}, },
scrollByPages: function (page_offset) { 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) { scroll: function (offset) {
App.Scrollable.scroll(App.byId("content-insert"), offset); App.Scrollable.scroll(document.getElementById("content-insert"), offset);
}, },
mouseIn: function (id) { mouseIn: function (id) {
this.post_under_pointer = id; this.post_under_pointer = id;

View File

@ -116,7 +116,7 @@ const CommonDialogs = {
</form> </form>
`, `,
show_error: function (msg, additional_info) { 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 ? `<br><br><h4>${__('Additional information')}</h4>${additional_info}` : ''}`; elem.innerHTML = `${msg}${additional_info ? `<br><br><h4>${__('Additional information')}</h4>${additional_info}` : ''}`;

View File

@ -166,7 +166,7 @@ const Filters = {
title: ruleStr ? __("Edit rule") : __("Add rule"), title: ruleStr ? __("Edit rule") : __("Add rule"),
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
dialog.insertRule(App.byId("filterDlg_Matches"), replaceNode); dialog.insertRule(document.getElementById("filterDlg_Matches"), replaceNode);
this.hide(); this.hide();
} }
}, },
@ -262,7 +262,7 @@ const Filters = {
}, },
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
dialog.insertAction(App.byId("filterDlg_Actions"), replaceNode); dialog.insertAction(document.getElementById("filterDlg_Actions"), replaceNode);
this.hide(); this.hide();
} }
}, },

View File

@ -309,7 +309,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
// focus headlines to route key events there // focus headlines to route key events there
setTimeout(() => { setTimeout(() => {
App.byId("headlines-frame").focus(); document.getElementById("headlines-frame").focus();
if (treeNode) { if (treeNode) {
const node = treeNode.rowNode; const node = treeNode.rowNode;
@ -318,7 +318,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
if (node && tree) { if (node && tree) {
// scroll tree to selection if needed // scroll tree to selection if needed
if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) { if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) {
App.byId("feedTree").scrollTop = node.offsetTop; document.getElementById("feedTree").scrollTop = node.offsetTop;
} }
} }
} }

View File

@ -227,7 +227,7 @@ const Feeds = {
dojo.disconnect(tmph); dojo.disconnect(tmph);
}); });
App.byId("feeds-holder").appendChild(tree.domNode); document.getElementById("feeds-holder").appendChild(tree.domNode);
const tmph2 = dojo.connect(tree, 'onLoad', function () { const tmph2 = dojo.connect(tree, 'onLoad', function () {
dojo.disconnect(tmph2); dojo.disconnect(tmph2);
@ -247,13 +247,13 @@ const Feeds = {
} }
}, },
onHide: function() { onHide: function() {
App.byId("feeds-holder_splitter").hide(); document.getElementById("feeds-holder_splitter").hide();
dijit.byId("main").resize(); dijit.byId("main").resize();
Headlines.updateCurrentUnread(); Headlines.updateCurrentUnread();
}, },
onShow: function() { onShow: function() {
App.byId("feeds-holder_splitter").show(); document.getElementById("feeds-holder_splitter").show();
dijit.byId("main").resize(); dijit.byId("main").resize();
Headlines.updateCurrentUnread(); Headlines.updateCurrentUnread();
@ -261,7 +261,7 @@ const Feeds = {
init: function() { init: function() {
console.log("in feedlist init"); 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); App.setLoadingProgress(50);
@ -350,7 +350,7 @@ const Feeds = {
this._active_feed_id = id; this._active_feed_id = id;
this._active_feed_is_cat = is_cat; 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) // TODO @deprecated: these two should be removed (replaced with data- attributes below)
container.setAttribute("feed-id", id); container.setAttribute("feed-id", id);

View File

@ -239,7 +239,7 @@ const Headlines = {
Headlines.select('none'); 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); Article.setActive(id);
@ -250,10 +250,10 @@ const Headlines = {
Headlines.toggleUnread(id, 0); Headlines.toggleUnread(id, 0);
} else { } 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 // 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) if (this.default_move_on_expand)
Article.cdmMoveToId(id); Article.cdmMoveToId(id);
@ -280,7 +280,7 @@ const Headlines = {
return false; return false;
}, },
initScrollHandler: function () { initScrollHandler: function () {
App.byId("headlines-frame").onscroll = (event) => { document.getElementById("headlines-frame").onscroll = (event) => {
clearTimeout(this._headlines_scroll_timeout); clearTimeout(this._headlines_scroll_timeout);
this._headlines_scroll_timeout = window.setTimeout(function () { this._headlines_scroll_timeout = window.setTimeout(function () {
//console.log('done scrolling', event); //console.log('done scrolling', event);
@ -317,7 +317,7 @@ const Headlines = {
Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true}); Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true});
}, },
isChildVisible: function (elem) { isChildVisible: function (elem) {
return App.Scrollable.isChildVisible(elem, App.byId("headlines-frame")); return App.Scrollable.isChildVisible(elem, document.getElementById("headlines-frame"));
}, },
firstVisible: function () { firstVisible: function () {
const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW]'); const rows = document.querySelectorAll('#headlines-frame > div[id*=RROW]');
@ -343,8 +343,8 @@ const Headlines = {
scrollHandler: function (/*event*/) { scrollHandler: function (/*event*/) {
try { try {
if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) { if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) {
const hsp = App.byId("headlines-spacer"); const hsp = document.getElementById("headlines-spacer");
const container = App.byId("headlines-frame"); const container = document.getElementById("headlines-frame");
if (hsp && hsp.previousSibling) { if (hsp && hsp.previousSibling) {
const last_row = hsp.previousSibling; const last_row = hsp.previousSibling;
@ -361,7 +361,7 @@ const Headlines = {
} }
if (App.isCombinedMode() && App.getInitParam("cdm_expanded")) { 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 */ /* don't do anything until there was some scrolling */
if (container.scrollTop > 0) if (container.scrollTop > 0)
@ -375,7 +375,7 @@ const Headlines = {
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const row = rows[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'); row.classList.remove('Unread');
} else { } else {
break; break;
@ -393,7 +393,7 @@ const Headlines = {
return this.headlines[id]; return this.headlines[id];
}, },
setCommonClasses: function (headlines_count) { setCommonClasses: function (headlines_count) {
const container = App.byId("headlines-frame"); const container = document.getElementById("headlines-frame");
container.classList.remove('cdm', 'normal'); container.classList.remove('cdm', 'normal');
@ -404,10 +404,10 @@ const Headlines = {
container.setAttribute("data-is-cdm-expanded", App.getInitParam("cdm_expanded")); container.setAttribute("data-is-cdm-expanded", App.getInitParam("cdm_expanded"));
// for floating title because it's placed outside of headlines-frame // 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()) 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 () { renderAgain: function () {
// TODO: wrap headline elements into a knockoutjs model to prevent all this stuff // TODO: wrap headline elements into a knockoutjs model to prevent all this stuff
@ -476,7 +476,7 @@ const Headlines = {
const tmp = document.createElement("div"); const tmp = document.createElement("div");
tmp.innerHTML = vgrhdr; tmp.innerHTML = vgrhdr;
App.byId("headlines-frame").appendChild(tmp.firstChild); document.getElementById("headlines-frame").appendChild(tmp.firstChild);
this.vgroup_last_feed = hl.feed_id; this.vgroup_last_feed = hl.feed_id;
} }
@ -609,11 +609,11 @@ const Headlines = {
return tmp.firstChild; return tmp.firstChild;
}, },
updateCurrentUnread: function () { updateCurrentUnread: function () {
if (App.byId("feed_current_unread")) { if (document.getElementById("feed_current_unread")) {
const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat());
if (feed_unread > 0 && !Element.visible("feeds-holder")) { 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"); Element.show("feed_current_unread");
} else { } else {
Element.hide("feed_current_unread"); Element.hide("feed_current_unread");
@ -762,18 +762,18 @@ const Headlines = {
Headlines.setCommonClasses(headlines_count); Headlines.setCommonClasses(headlines_count);
/** TODO: remove @deprecated */ /** TODO: remove @deprecated */
App.byId("headlines-frame").setAttribute("is-vfeed", document.getElementById("headlines-frame").setAttribute("is-vfeed",
reply['headlines']['is_vfeed'] ? 1 : 0); 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"); reply['headlines']['is_vfeed'] ? "true" : "false");
Article.setActive(0); Article.setActive(0);
try { try {
App.byId('headlines-frame').classList.remove('smooth-scroll'); document.getElementById('headlines-frame').classList.remove('smooth-scroll');
App.byId('headlines-frame').scrollTop = 0; document.getElementById('headlines-frame').scrollTop = 0;
App.byId('headlines-frame').classList.add('smooth-scroll'); document.getElementById('headlines-frame').classList.add('smooth-scroll');
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
} }
@ -781,27 +781,27 @@ const Headlines = {
this.headlines = []; this.headlines = [];
this.vgroup_last_feed = undefined; this.vgroup_last_feed = undefined;
/*dojo.html.set(App.byId("toolbar-headlines"), /*dojo.html.set(document.getElementById("toolbar-headlines"),
reply['headlines']['toolbar'], reply['headlines']['toolbar'],
{parseContent: true});*/ {parseContent: true});*/
Headlines.renderToolbar(reply['headlines']); Headlines.renderToolbar(reply['headlines']);
if (typeof reply['headlines']['content'] === 'string') { if (typeof reply['headlines']['content'] === 'string') {
App.byId("headlines-frame").innerHTML = reply['headlines']['content']; document.getElementById("headlines-frame").innerHTML = reply['headlines']['content'];
} else { } else {
App.byId("headlines-frame").innerHTML = ''; document.getElementById("headlines-frame").innerHTML = '';
for (let i = 0; i < reply['headlines']['content'].length; i++) { for (let i = 0; i < reply['headlines']['content'].length; i++) {
const hl = reply['headlines']['content'][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; this.headlines[parseInt(hl.id)] = hl;
} }
} }
let hsp = App.byId("headlines-spacer"); let hsp = document.getElementById("headlines-spacer");
if (!hsp) { if (!hsp) {
hsp = document.createElement("div"); hsp = document.createElement("div");
@ -821,7 +821,7 @@ const Headlines = {
/* /*
if (Feeds._search_query) { if (Feeds._search_query) {
App.byId("feed_title").innerHTML += "<span id='cancel_search'>" + document.getElementById("feed_title").innerHTML += "<span id='cancel_search'>" +
" (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" + " (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" +
"</span>"; "</span>";
} */ } */
@ -831,7 +831,7 @@ const Headlines = {
} else if (headlines_count > 0 && feed_id === Feeds.getActive() && is_cat === Feeds.activeIsCat()) { } else if (headlines_count > 0 && feed_id === Feeds.getActive() && is_cat === Feeds.activeIsCat()) {
const c = dijit.byId("headlines-frame"); const c = dijit.byId("headlines-frame");
let hsp = App.byId("headlines-spacer"); let hsp = document.getElementById("headlines-spacer");
if (hsp) if (hsp)
c.domNode.removeChild(hsp); c.domNode.removeChild(hsp);
@ -839,13 +839,13 @@ const Headlines = {
let headlines_appended = 0; let headlines_appended = 0;
if (typeof reply['headlines']['content'] === 'string') { if (typeof reply['headlines']['content'] === 'string') {
App.byId("headlines-frame").innerHTML = reply['headlines']['content']; document.getElementById("headlines-frame").innerHTML = reply['headlines']['content'];
} else { } else {
for (let i = 0; i < reply['headlines']['content'].length; i++) { for (let i = 0; i < reply['headlines']['content'].length; i++) {
const hl = reply['headlines']['content'][i]; const hl = reply['headlines']['content'][i];
if (!this.headlines[parseInt(hl.id)]) { 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; this.headlines[parseInt(hl.id)] = hl;
++headlines_appended; ++headlines_appended;
@ -880,7 +880,7 @@ const Headlines = {
console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed); 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 (hsp) {
if (first_id_changed) { if (first_id_changed) {
@ -948,7 +948,7 @@ const Headlines = {
} }
ids.forEach((id) => { ids.forEach((id) => {
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (row) { if (row) {
switch (cmode) { switch (cmode) {
@ -987,11 +987,11 @@ const Headlines = {
ids.forEach(id => this.togglePub(id)); ids.forEach(id => this.togglePub(id));
}, },
toggleMark: function (id) { toggleMark: function (id) {
App.byId(`RROW-${id}`)?.classList.toggle('marked'); document.getElementById(`RROW-${id}`)?.classList.toggle('marked');
}, },
togglePub: function (id) { togglePub: function (id) {
App.byId(`RROW-${id}`)?.classList.toggle('published'); document.getElementById(`RROW-${id}`)?.classList.toggle('published');
}, },
move: function (mode, params = {}) { move: function (mode, params = {}) {
const no_expand = params.no_expand || false; const no_expand = params.no_expand || false;
@ -1002,7 +1002,7 @@ const Headlines = {
let next_id = false; let next_id = false;
let current_id = Article.getActive(); 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...'); console.log('active article is obscured, resetting to first visible...');
current_id = Headlines.firstVisible(); current_id = Headlines.firstVisible();
prev_id = current_id; prev_id = current_id;
@ -1041,15 +1041,15 @@ const Headlines = {
} }
} else if (App.isCombinedMode()) { } else if (App.isCombinedMode()) {
// try to show hsp if no next article exists, in case there's useful information like first_id_changed etc // 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 row = document.getElementById(`RROW-${current_id}`);
const ctr = App.byId("headlines-frame"); const ctr = document.getElementById("headlines-frame");
if (row) { if (row) {
const next = row.nextSibling; const next = row.nextSibling;
// hsp has half-screen height in auto catchup mode therefore we use its first child (normally A element) // 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) { 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 // don't jump back either
if (ctr.scrollTop < offset) if (ctr.scrollTop < offset)
@ -1061,8 +1061,8 @@ const Headlines = {
if (prev_id || current_id) { if (prev_id || current_id) {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
const row = App.byId(`RROW-${current_id}`); const row = document.getElementById(`RROW-${current_id}`);
const ctr = App.byId("headlines-frame"); const ctr = document.getElementById("headlines-frame");
const delta_px = Math.round(row.offsetTop) - Math.round(ctr.scrollTop); const delta_px = Math.round(row.offsetTop) - Math.round(ctr.scrollTop);
console.log('moving back, delta_px', delta_px); console.log('moving back, delta_px', delta_px);
@ -1083,7 +1083,7 @@ const Headlines = {
}, },
updateSelectedPrompt: function () { updateSelectedPrompt: function () {
const count = Headlines.getSelected().length; const count = Headlines.getSelected().length;
const elem = App.byId("selected_prompt"); const elem = document.getElementById("selected_prompt");
if (elem) { if (elem) {
elem.innerHTML = ngettext("%d article selected", elem.innerHTML = ngettext("%d article selected",
@ -1093,7 +1093,7 @@ const Headlines = {
} }
}, },
toggleUnread: function (id, cmode) { toggleUnread: function (id, cmode) {
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (row) { if (row) {
if (typeof cmode === "undefined") cmode = 2; if (typeof cmode === "undefined") cmode = 2;
@ -1316,7 +1316,7 @@ const Headlines = {
if (!below) { if (!below) {
for (let i = 0; i < visible_ids.length; i++) { for (let i = 0; i < visible_ids.length; i++) {
if (visible_ids[i] !== id) { 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')) { if (e && e.classList.contains('Unread')) {
ids_to_mark.push(visible_ids[i]); ids_to_mark.push(visible_ids[i]);
@ -1328,7 +1328,7 @@ const Headlines = {
} else { } else {
for (let i = visible_ids.length - 1; i >= 0; i--) { for (let i = visible_ids.length - 1; i >= 0; i--) {
if (visible_ids[i] !== id) { 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')) { if (e && e.classList.contains('Unread')) {
ids_to_mark.push(visible_ids[i]); ids_to_mark.push(visible_ids[i]);
@ -1347,7 +1347,7 @@ const Headlines = {
if (App.getInitParam("confirm_feed_catchup") !== 1 || confirm(msg)) { if (App.getInitParam("confirm_feed_catchup") !== 1 || confirm(msg)) {
for (let i = 0; i < ids_to_mark.length; i++) { 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'); e.classList.remove('Unread');
} }
} }
@ -1379,8 +1379,8 @@ const Headlines = {
} }
}, },
scrollToArticleId: function (id) { scrollToArticleId: function (id) {
const container = App.byId("headlines-frame"); const container = document.getElementById("headlines-frame");
const row = App.byId(`RROW-${id}`); const row = document.getElementById(`RROW-${id}`);
if (!container || !row) return; if (!container || !row) return;
@ -1525,10 +1525,10 @@ const Headlines = {
} }
}, },
scrollByPages: function (page_offset) { 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) { scroll: function (offset) {
App.Scrollable.scroll(App.byId("headlines-frame"), offset); App.Scrollable.scroll(document.getElementById("headlines-frame"), offset);
}, },
initHeadlinesMenu: function () { initHeadlinesMenu: function () {
if (!dijit.byId("headlinesMenu")) { if (!dijit.byId("headlinesMenu")) {

View File

@ -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"; return (!item || this.model.store.getValue(item, 'type') === 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
}, },
reload: function() { reload: function() {
const searchElem = App.byId("feed_search"); const searchElem = document.getElementById("feed_search");
const search = (searchElem) ? searchElem.value : ""; const search = (searchElem) ? searchElem.value : "";
xhr.post("backend.php", { op: "Pref_Feeds", search: search }, (reply) => { xhr.post("backend.php", { op: "Pref_Feeds", search: search }, (reply) => {

View File

@ -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) { 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; return rv;
}, },
reload: function() { reload: function() {
const user_search = App.byId("filter_search"); const user_search = document.getElementById("filter_search");
let search = ""; let search = "";
if (user_search) { search = user_search.value; } if (user_search) { search = user_search.value; }

View File

@ -8,7 +8,7 @@ const Helpers = {
return Tables.getSelected("app-password-list"); return Tables.getSelected("app-password-list");
}, },
updateContent: function(data) { updateContent: function(data) {
App.byId("app_passwords_holder").innerHTML = data; document.getElementById("app_passwords_holder").innerHTML = data;
dojo.parser.parse("app_passwords_holder"); dojo.parser.parse("app_passwords_holder");
}, },
removeSelected: function() { removeSelected: function() {
@ -264,7 +264,7 @@ const Helpers = {
apply: function() { apply: function() {
xhr.post("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
Element.show("css_edit_apply_msg"); 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 () { execute: function () {
@ -784,7 +784,7 @@ const Helpers = {
}, },
OPML: { OPML: {
import: function() { import: function() {
const opml_file = App.byId("opml_file"); const opml_file = document.getElementById("opml_file");
if (opml_file.value.length === 0) { if (opml_file.value.length === 0) {
alert(__("Please choose an OPML file first.")); alert(__("Please choose an OPML file first."));
@ -826,7 +826,7 @@ const Helpers = {
dialog.show(); dialog.show();
}; };
xhr.send(new FormData(App.byId("opml_import_form"))); xhr.send(new FormData(document.getElementById("opml_import_form")));
return false; return false;
} }

View File

@ -82,7 +82,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
color = bg; color = bg;
} }
const e = App.byId(`icon-label-${id}`); const e = document.getElementById(`icon-label-${id}`);
if (e) { if (e) {
if (bg) e.style.color = bg; if (bg) e.style.color = bg;

View File

@ -5,7 +5,7 @@
const Users = { const Users = {
reload: function(sort) { reload: function(sort) {
return new Promise((resolve, reject) => { 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 : ""; const search = user_search ? user_search.value : "";
xhr.post("backend.php", { op: "Pref_Users", sort: sort, search: search }, (reply) => { xhr.post("backend.php", { op: "Pref_Users", sort: sort, search: search }, (reply) => {

View File

@ -16,12 +16,6 @@ function ngettext(msg1, msg2, n) {
return __((parseInt(n) > 1) ? msg2 : msg1); 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 // polyfill for safari https://raw.githubusercontent.com/pladaria/requestidlecallback-polyfill/master/index.js
window.requestIdleCallback = window.requestIdleCallback =
window.requestIdleCallback || window.requestIdleCallback ||
@ -364,7 +358,7 @@ const Notify = {
kind = kind || this.KIND_GENERIC; kind = kind || this.KIND_GENERIC;
keep = keep || false; keep = keep || false;
const notify = App.byId("notify"); const notify = document.getElementById("notify");
window.clearTimeout(this.timeout); window.clearTimeout(this.timeout);

View File

@ -52,7 +52,7 @@ Plugins.Shorten_Expanded = {
this.observer.observe(row); this.observer.observe(row);
}, },
expand: function(id) { expand: function(id) {
const row = App.byId(id); const row = document.getElementById(id);
if (row) { if (row) {
const link = row.querySelector('.expand-prompt'); const link = row.querySelector('.expand-prompt');