luci-mod-network: move var ipaddrs in dhcp.js
authorDavid Härdeman <[email protected]>
Mon, 20 Oct 2025 21:46:22 +0000 (23:46 +0200)
committerPaul Donald <[email protected]>
Fri, 24 Oct 2025 13:57:43 +0000 (15:57 +0200)
Move var ipaddrs down to the sole place where it is used.

Signed-off-by: David Härdeman <[email protected]>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js

index 07791ea048a188bb7d8fffd0304e653e824a9404..3ed68427c5bc6d452ba891aa785122edc9e2c365 100644 (file)
@@ -294,15 +294,6 @@ return view.extend({
                s.tab('relay', _('Relay'));
                s.tab('pxe_tftp', _('PXE/TFTP'));
 
-               var ipaddrs = {};
-
-               Object.keys(hosts).forEach(function(mac) {
-                       var addrs = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4);
-
-                       for (var i = 0; i < addrs.length; i++)
-                               ipaddrs[addrs[i]] = hosts[mac].name || mac;
-               });
-
                // Begin general
                s.taboption('general', form.Flag, 'authoritative',
                        _('Authoritative'),
@@ -503,7 +494,13 @@ return view.extend({
 
                        return _('The IP address is outside of any DHCP pool address range');
                };
+               var ipaddrs = {};
+               Object.keys(hosts).forEach(function(mac) {
+                       var addrs = L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4);
 
+                       for (var i = 0; i < addrs.length; i++)
+                               ipaddrs[addrs[i]] = hosts[mac].name || mac;
+               });
                L.sortedKeys(ipaddrs, null, 'addr').forEach(function(ipv4) {
                        so.value(ipv4, ipaddrs[ipv4] ? '%s (%s)'.format(ipv4, ipaddrs[ipv4]) : ipv4);
                });