luci-theme-bootstrap: use ES6 syntax

Replaced L.bind with arrow functions, used Array.from for array conversion,
applied concise method syntax, and switched to block-scoped declarations.

Signed-off-by: Eamon Xiong <eamonxiong@gmail.com>
This commit is contained in:
Eamon Xiong
2025-11-17 20:39:15 +08:00
parent fa319cfe95
commit 8a8e4d53a7
2 changed files with 19 additions and 14 deletions

View File

@@ -4,7 +4,7 @@
return baseclass.extend({
__init__() {
ui.menu.load().then(L.bind(this.render, this));
ui.menu.load().then((tree) => this.render(tree));
},
render(tree) {

View File

@@ -3,26 +3,30 @@
'require view';
return view.extend({
render: function() {
var form = document.querySelector('form'),
btn = document.querySelector('button');
render() {
const form = document.querySelector('form');
const btn = document.querySelector('button');
var dlg = ui.showModal(
const dlg = ui.showModal(
_('Authorization Required'),
[].slice.call(document.querySelectorAll('section > *')),
Array.from(document.querySelectorAll('section > *')),
'login'
);
form.addEventListener('keypress', function(ev) {
if (ev.key == 'Enter')
form.addEventListener('keypress', (ev) => {
if (ev.key === 'Enter')
btn.click();
});
btn.addEventListener('click', function() {
dlg.querySelectorAll('*').forEach(function(node) { node.style.display = 'none' });
dlg.appendChild(E('div', { 'class': 'spinning' }, _('Logging in…')));
btn.addEventListener('click', () => {
dlg.querySelectorAll('*').forEach((node) => {
node.style.display = 'none';
});
dlg.appendChild(E('div', {
class: 'spinning'
}, _('Logging in…')));
form.submit()
form.submit();
});
document.querySelector('input[type="password"]').focus();
@@ -30,5 +34,6 @@ return view.extend({
return '';
},
addFooter: function() {}
});
addFooter() {},
});