From: Eamon Xiong Date: Mon, 17 Nov 2025 12:39:15 +0000 (+0800) Subject: luci-theme-bootstrap: use ES6 syntax X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=8a8e4d53a7391ac474471df8ad6239ee1fc1c321;p=project%2Fluci.git 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 --- diff --git a/themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js b/themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js index 94dcfa816e..a246cc1e2a 100644 --- a/themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js +++ b/themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js @@ -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) { diff --git a/themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js b/themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js index fd936c9b10..cace51b27c 100644 --- a/themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js +++ b/themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js @@ -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() {}, + +}); \ No newline at end of file