X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fhtdocs%2Fluci-static%2Fresources%2Fcbi.js;h=8bf94a6c5097be817e563bcaaa301b54f3f8c84b;hp=1c4123bdadcb3cd7465e1277678ddede2b67137f;hb=808c1b77f9008bc9f4a760ea0629b3fd4e49fbcb;hpb=967bb1f36f9f30d19e13aecf3a550eea5fd73c6b;ds=sidebyside diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 1c4123bda..8bf94a6c5 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -13,7 +13,6 @@ var cbi_d = []; var cbi_t = []; -var cbi_c = []; var cbi_validators = { @@ -345,7 +344,7 @@ var cbi_validators = { { return (this.match(/^[0-9\*#!\.]+$/) != null); }, - 'timehhmmss': function() + 'timehhmmss': function() { return (this.match(/^[0-6][0-9]:[0-6][0-9]:[0-6][0-9]$/) != null); }, @@ -389,12 +388,12 @@ var cbi_validators = { }; -function cbi_d_add(field, dep, next) { - var obj = document.getElementById(field); +function cbi_d_add(field, dep, index) { + var obj = (typeof(field) === 'string') ? document.getElementById(field) : field; if (obj) { var entry for (var i=0; i entry.index) { + break; + } + } + if (!next) { parent.appendChild(entry.node); } else { - next.parentNode.insertBefore(entry.node, next); + parent.insertBefore(entry.node, next); } + state = true; - if( entry.parent ) - cbi_c[entry.parent]++; } } @@ -499,6 +502,22 @@ function cbi_d_update() { } } +function cbi_init() { + var nodes = document.querySelectorAll('[data-depends]'); + + for (var i = 0, node; (node = nodes[i]) !== undefined; i++) { + var index = parseInt(node.getAttribute('data-index'), 10); + var depends = JSON.parse(node.getAttribute('data-depends')); + if (!isNaN(index) && depends.length > 0) { + for (var alt = 0; alt < depends.length; alt++) { + cbi_d_add(node, depends[alt], index); + } + } + } + + cbi_d_update(); +} + function cbi_bind(obj, type, callback, mode) { if (!obj.addEventListener) { obj.attachEvent('on' + type, @@ -876,27 +895,6 @@ function cbi_dynlist_init(name, respath, datatype, optional, url, defpath, choic cbi_dynlist_redraw(NaN, -1, -1); } -//Hijacks the CBI form to send via XHR (requires Prototype) -function cbi_hijack_forms(layer, win, fail, load) { - var forms = layer.getElementsByTagName('form'); - for (var i=0; i 0 ) + if (hl_tabs.length > 0) window.setTimeout(function() { for( var i = 0; i < hl_tabs.length; i++ ) hl_tabs[i].className = hl_tabs[i].className.replace(/ cbi-tab-highlighted/g, '');