LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2012 Jo-Philipp Wich <xm@subsignal.org>
+ Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
return (this.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
},
- 'host': function()
+ 'host': function(ipv4only)
{
return cbi_validators.hostname.apply(this) ||
- cbi_validators.ipaddr.apply(this);
+ ((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
+ ((ipv4only == 1) && cb_validators.ip4addr.apply(this));
},
'hostname': function()
cbi_validators.host.apply(this);
},
+ 'hostport': function(ipv4only)
+ {
+ var hp = this.split(/:/);
+
+ if (hp.length == 2)
+ return (cbi_validators.host.apply(hp[0], ipv4only) &&
+ cbi_validators.port.apply(hp[1]));
+
+ return false;
+ },
+
+ 'ip4addrport': function()
+ {
+ var hp = this.split(/:/);
+
+ if (hp.length == 2)
+ return (cbi_validators.ipaddr.apply(hp[0]) &&
+ cbi_validators.port.apply(hp[1]));
+ return false;
+ },
+
+ 'ipaddrport': function(bracket)
+ {
+ if (this.match(/^([^\[\]:]+):([^:]+)$/)) {
+ var addr = RegExp.$1
+ var port = RegExp.$2
+ return (cbi_validators.ip4addr.apply(addr) &&
+ cbi_validators.port.apply(port));
+ } else if ((bracket == 1) && (this.match(/^\[(.+)\]:([^:]+)$/))) {
+ var addr = RegExp.$1
+ var port = RegExp.$2
+ return (cbi_validators.ip6addr.apply(addr) &&
+ cbi_validators.port.apply(port));
+ } else if ((bracket != 1) && (this.match(/^([^\[\]]+):([^:]+)$/))) {
+ var addr = RegExp.$1
+ var port = RegExp.$2
+ return (cbi_validators.ip6addr.apply(addr) &&
+ cbi_validators.port.apply(port));
+ } else {
+ return false;
+ }
+ },
+
'wpakey': function()
{
var v = this;
cbi_bind(btn, 'click', cbi_browser_btnclick);
}
-function cbi_dynlist_init(name, respath, datatype, optional, choices)
+function cbi_dynlist_init(name, respath, datatype, optional, url, defpath, choices)
{
var input0 = document.getElementsByName(name)[0];
var prefix = input0.name;
parent.appendChild(t);
parent.appendChild(b);
+ if (datatype == 'file')
+ {
+ cbi_browser_init(t.id, respath, url, defpath);
+ }
+
parent.appendChild(document.createElement('br'));
if (datatype)
if (choices)
{
cbi_combobox_init(t.id, choices[0], '', choices[1]);
- t.nextSibling.index = i;
+ b.index = i;
- cbi_bind(t.nextSibling, 'keydown', cbi_dynlist_keydown);
- cbi_bind(t.nextSibling, 'keypress', cbi_dynlist_keypress);
+ cbi_bind(b, 'keydown', cbi_dynlist_keydown);
+ cbi_bind(b, 'keypress', cbi_dynlist_keypress);
if (i == focus || -i == focus)
- t.nextSibling.focus();
+ b.focus();
}
else
{
ev = ev ? ev : window.event;
var se = ev.target ? ev.target : ev.srcElement;
+ var input = se.previousSibling;
+ while (input && input.name != name) {
+ input = input.previousSibling;
+ }
if (se.src.indexOf('remove') > -1)
{
- se.previousSibling.value = '';
+ input.value = '';
cbi_dynlist_keydown({
- target: se.previousSibling,
+ target: input,
keyCode: 8
});
}
else
{
cbi_dynlist_keydown({
- target: se.previousSibling,
+ target: input,
keyCode: 13
});
}