Skip to content

Commit 67721e6

Browse files
committed
luci-theme-*: use ES6 syntax
Updated to arrow functions for clearer `this` binding, replaced slice.call with Array.from for more readable array conversion, and adopted ES6 block-scoped declarations. Signed-off-by: Eamon Xiong <[email protected]>
1 parent 9717162 commit 67721e6

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

themes/luci-theme-bootstrap/htdocs/luci-static/resources/menu-bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
render(tree) {

themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,35 @@
33
'require view';
44

55
return view.extend({
6-
render: function() {
7-
var form = document.querySelector('form'),
8-
btn = document.querySelector('button');
6+
render() {
7+
const form = document.querySelector('form');
8+
const btn = document.querySelector('button');
99

10-
var dlg = ui.showModal(
10+
const dlg = ui.showModal(
1111
_('Authorization Required'),
12-
[].slice.call(document.querySelectorAll('section > *')),
13-
'login'
12+
Array.from(document.querySelectorAll('section > *')),
13+
'login',
1414
);
1515

16-
form.addEventListener('keypress', function(ev) {
17-
if (ev.key == 'Enter')
18-
btn.click();
16+
form.addEventListener('keypress', (ev) => {
17+
if (ev.key === 'Enter') btn.click();
1918
});
2019

21-
btn.addEventListener('click', function() {
22-
dlg.querySelectorAll('*').forEach(function(node) { node.style.display = 'none' });
23-
dlg.appendChild(E('div', { 'class': 'spinning' }, _('Logging in…')));
20+
btn.addEventListener('click', () => {
21+
dlg.querySelectorAll('*').forEach((node) => {
22+
node.style.display = 'none';
23+
});
24+
dlg.appendChild(E('div', {
25+
class: 'spinning'
26+
}, _('Logging in…')));
2427

25-
form.submit()
28+
form.submit();
2629
});
2730

2831
document.querySelector('input[type="password"]').focus();
2932

3033
return '';
3134
},
3235

33-
addFooter: function() {}
34-
});
36+
addFooter() {},
37+
});

themes/luci-theme-material/htdocs/luci-static/resources/menu-material.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
render(tree) {

themes/luci-theme-openwrt-2020/htdocs/luci-static/resources/menu-openwrt2020.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
render(tree) {

themes/luci-theme-openwrt/htdocs/luci-static/resources/menu-openwrt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
render(tree) {

0 commit comments

Comments
 (0)