From ede4aca4b95c9e664e4830fd43c54b627b122538 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 12 Oct 2010 05:15:32 +0000 Subject: libs: merge libs/cbi into libs/web --- libs/web/htdocs/luci-static/resources/cbi.js | 518 +++++++++++++++++++++ libs/web/htdocs/luci-static/resources/cbi/add.gif | Bin 0 -> 378 bytes .../web/htdocs/luci-static/resources/cbi/apply.gif | Bin 0 -> 268 bytes .../web/htdocs/luci-static/resources/cbi/arrow.gif | Bin 0 -> 135 bytes .../htdocs/luci-static/resources/cbi/download.gif | Bin 0 -> 189 bytes libs/web/htdocs/luci-static/resources/cbi/edit.gif | Bin 0 -> 280 bytes .../htdocs/luci-static/resources/cbi/fieldadd.gif | Bin 0 -> 379 bytes libs/web/htdocs/luci-static/resources/cbi/find.gif | Bin 0 -> 273 bytes libs/web/htdocs/luci-static/resources/cbi/help.gif | Bin 0 -> 266 bytes libs/web/htdocs/luci-static/resources/cbi/key.gif | Bin 0 -> 230 bytes libs/web/htdocs/luci-static/resources/cbi/link.gif | Bin 0 -> 279 bytes .../htdocs/luci-static/resources/cbi/reload.gif | Bin 0 -> 248 bytes .../htdocs/luci-static/resources/cbi/remove.gif | Bin 0 -> 385 bytes .../web/htdocs/luci-static/resources/cbi/reset.gif | Bin 0 -> 258 bytes libs/web/htdocs/luci-static/resources/cbi/save.gif | Bin 0 -> 263 bytes libs/web/htdocs/luci-static/resources/cbi/user.gif | Bin 0 -> 246 bytes 16 files changed, 518 insertions(+) create mode 100644 libs/web/htdocs/luci-static/resources/cbi.js create mode 100644 libs/web/htdocs/luci-static/resources/cbi/add.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/apply.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/arrow.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/download.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/edit.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/fieldadd.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/find.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/help.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/key.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/link.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/reload.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/remove.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/reset.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/save.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/user.gif (limited to 'libs/web/htdocs/luci-static/resources') diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js new file mode 100644 index 0000000000..4af6e58d9b --- /dev/null +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -0,0 +1,518 @@ +/* + LuCI - Lua Configuration Interface + + Copyright 2008 Steven Barth + Copyright 2008-2010 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 +*/ + +var cbi_d = []; +var cbi_t = []; +var cbi_c = []; + +var cbi_validators = { + + 'integer': function(v) + { + return (v.match(/^-?[0-9]+$/) != null); + }, + + 'uinteger': function(v) + { + return (cbi_validators.integer(v) && (v >= 0)); + }, + + 'ipaddr': function(v) + { + return cbi_validators.ip4addr(v) || cbi_validators.ip6addr(v); + }, + + 'ip4addr': function(v) + { + if( v.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\/(\d+))?$/) ) + { + return (RegExp.$1 >= 0) && (RegExp.$1 <= 255) && + (RegExp.$2 >= 0) && (RegExp.$2 <= 255) && + (RegExp.$3 >= 0) && (RegExp.$3 <= 255) && + (RegExp.$4 >= 0) && (RegExp.$4 <= 255) && + (!RegExp.$5 || ((RegExp.$6 >= 0) && (RegExp.$6 <= 32))) + ; + } + + return false; + }, + + 'ip6addr': function(v) + { + if( v.match(/^([a-fA-F0-9:.]+)(\/(\d+))?$/) ) + { + if( !RegExp.$2 || ((RegExp.$3 >= 0) && (RegExp.$3 <= 128)) ) + { + var addr = RegExp.$1; + + if( addr == '::' ) + { + return true; + } + + if( addr.indexOf('.') > 0 ) + { + var off = addr.lastIndexOf(':'); + + if( !(off && cbi_validators.ip4addr(addr.substr(off+1))) ) + return false; + + addr = addr.substr(0, off) + ':0:0'; + } + + if( addr.indexOf('::') < 0 ) + { + return (addr.match(/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/) != null); + } + + var fields = 0; + + for( var i = 0, last = 0, comp = false; i <= addr.length; i++ ) + { + if( (addr.charAt(i) == ':') || (i == addr.length) ) + { + if( (i == last) && !comp ) + { + comp = true; + } + else + { + var f = addr.substring(last, i); + if( !(f && f.match(/^[a-fA-F0-9]{1,4}$/)) ) + return false; + } + + fields++; + last = i + 1; + } + } + + return (fields == 8); + } + } + + return false; + }, + + 'port': function(v) + { + return cbi_validators.integer(v) && (v >= 0) && (v <= 65535); + }, + + 'portrange': function(v) + { + if( v.match(/^(\d+)-(\d+)$/) ) + { + var p1 = RegExp.$1; + var p2 = RegExp.$2; + + return cbi_validators.port(p1) && + cbi_validators.port(p2) && + (parseInt(p1) <= parseInt(p2)) + ; + } + else + { + return cbi_validators.port(v); + } + }, + + 'macaddr': function(v) + { + return (v.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null); + }, + + 'host': function(v) + { + return cbi_validators.hostname(v) || cbi_validators.ipaddr(v); + }, + + 'hostname': function(v) + { + return (v.match(/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/) != null); + }, + + 'wpakey': function(v) + { + if( v.length == 64 ) + return (v.match(/^[a-fA-F0-9]{64}$/) != null); + else + return (v.length >= 8) && (v.length <= 63); + }, + + 'wepkey': function(v) + { + if( v.substr(0,2) == 's:' ) + v = v.substr(2); + + if( (v.length == 10) || (v.length == 26) ) + return (v.match(/^[a-fA-F0-9]{10,26}$/) != null); + else + return (v.length == 5) || (v.length == 13); + }, + +}; + + +function cbi_d_add(field, dep, next) { + var obj = document.getElementById(field); + if (obj) { + var entry + for (var i=0; i 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 == ref) +} + +function cbi_d_check(deps) { + var reverse; + var def = false; + for (var i=0; i