luci-base: cbi improvements and loop var fix
authorPaul Donald <redacted>
Fri, 20 Feb 2026 01:28:43 +0000 (02:28 +0100)
committerPaul Donald <redacted>
Fri, 20 Feb 2026 01:38:02 +0000 (02:38 +0100)
mainly for downstream consumers who still use Lua.

Signed-off-by: Paul Donald <redacted>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index e2c9e4e9240351a65405c6d116bfbaa19fca95f9..9b8604251fbc095f9f4070fc85801578465ba73b 100644 (file)
  * @module LuCI.cbi
  */
 const cbi_d = [];
+if (typeof window !== 'undefined')
+       window.cbi_d = cbi_d;
 const cbi_strings = { path: {}, label: {} };
+if (typeof window !== 'undefined')
+       window.cbi_strings = cbi_strings;
 
 /**
  * Read signed 8-bit integer from a byte array at the given offset.
@@ -326,7 +330,7 @@ function cbi_init() {
                const depends = JSON.parse(n.getAttribute('data-depends'));
                if (!isNaN(index) && depends.length > 0) {
                        for (let a of depends)
-                               cbi_d_add(n, depends[a], index);
+                               cbi_d_add(n, a, index);
                }
        }
 
@@ -445,7 +449,8 @@ function cbi_validate_form(form, errmsg)
                        const validator = fv;
 
                        if (!validator() && errmsg) {
-                               alert(errmsg);
+                               if (typeof window !== 'undefined' && typeof window.alert === 'function')
+                                       window.alert(errmsg);
                                return false;
                        }
                }
git clone https://git.99rst.org/PROJECT