X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=libs%2Fcbi%2Fhtdocs%2Fluci-static%2Fresources%2Fcbi.js;h=247228d225b47d6a3f15a88e3ecefae176153be7;hb=bddc2053b4d020a1982c8bfb86dde5a88dc47be6;hp=227e33269d6bd8fbc40f6bafea335278933fe681;hpb=a35337e6a150412a5a7be8b4fe06eaba04dc4fa5;p=project%2Fluci.git diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js index 227e33269..247228d22 100644 --- a/libs/cbi/htdocs/luci-static/resources/cbi.js +++ b/libs/cbi/htdocs/luci-static/resources/cbi.js @@ -1,6 +1,23 @@ +/* + LuCI - Lua Configuration Interface + + Copyright 2008 Steven Barth + Copyright 2008-2009 Jo-Philipp Wich + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + $Id$ +*/ + var cbi_d = []; +var cbi_t = []; +var cbi_c = []; -function cbi_d_add(field, dep) { +function cbi_d_add(field, dep, next) { var obj = document.getElementById(field); if (obj) { var entry @@ -12,63 +29,98 @@ function cbi_d_add(field, dep) { } if (!entry) { entry = { - "id": field, "node": obj, - "parent": obj.parentNode, - "next": obj.nextSibling, + "id": field, + "parent": obj.parentNode.id, + "next": next, "deps": [] }; cbi_d.unshift(entry); - } + } entry.deps.push(dep) } } -function cbi_d_value(target) { +function cbi_d_checkvalue(target, ref) { var t = document.getElementById(target); - var value - - if (!t || !t.value) { + var value; + + if (!t) { + var tl = document.getElementsByName(target); + + if( tl.length > 0 && tl[0].type == 'radio' ) + for( var i = 0; i < tl.length; i++ ) + if( tl[i].checked ) { + value = tl[i].value; + break; + } + + value = value ? value : ""; + } else if (!t.value) { value = ""; } else { value = t.value; - + if (t.type == "checkbox") { value = t.checked ? value : ""; } } - - return value + + return (value == ref) } function cbi_d_check(deps) { + var reverse; + var def = false; for (var i=0; i