luci-theme-bootstrap: use ES6 syntax
authorEamon Xiong <[email protected]>
Mon, 17 Nov 2025 12:39:15 +0000 (20:39 +0800)
committerEamon Xiong <[email protected]>
Mon, 17 Nov 2025 15:40:51 +0000 (23:40 +0800)
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 <[email protected]>
themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js
themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js

index 94dcfa816e141466f4ec440375e9ffd92336819a..a246cc1e2a9c813169914ef3da4fefd347badf03 100644 (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) {
index fd936c9b1037a75356f65226a7e97864c0d6d390..cace51b27c1426ca136dcd6f84e4e78882b59e6f 100644 (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() {},
+
+});
\ No newline at end of file