return false;
},
+ 'ip4prefix': function()
+ {
+ return !isNaN(this) && this >= 0 && this <= 32;
+ },
+
+ 'ip6prefix': function()
+ {
+ return !isNaN(this) && this >= 0 && this <= 128;
+ },
+
+ 'cidr': function()
+ {
+ return cbi_validators.cidr4.apply(this) ||
+ cbi_validators.cidr6.apply(this);
+ },
+
+ 'cidr4': function()
+ {
+ if (this.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ mask = RegExp.$2;
+ return cbi_validators.ip4addr.apply(ip) &&
+ cbi_validators.ip4prefix.apply(mask);
+ }
+ return false;
+ },
+
+ 'cidr6': function()
+ {
+ if (this.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ mask = RegExp.$2;
+ return cbi_validators.ip6addr.apply(ip) &&
+ cbi_validators.ip6prefix.apply(mask);
+ }
+ return false;
+ },
+
+ 'ipnet4': function()
+ {
+ if (this.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ net = RegExp.$2;
+ return cbi_validators.ip4addr.apply(ip) &&
+ cbi_validators.ip4addr.apply(net);
+ }
+ return false;
+ },
+
+ 'ipnet6': function()
+ {
+ if (this.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ net = RegExp.$2;
+ return cbi_validators.ip6addr.apply(ip) &&
+ cbi_validators.ip6addr.apply(net);
+ }
+ return false;
+ },
+
+ 'ipmask': function()
+ {
+ return cbi_validators.ipmask4.apply(this) ||
+ cbi_validators.ipmask6.apply(this);
+ },
+
+ 'ipmask4': function()
+ {
+ return cbi_validators.cidr4.apply(this) ||
+ cbi_validators.ipnet4.apply(this) ||
+ cbi_validators.ip4addr.apply(this);
+ },
+
+ 'ipmask6': function()
+ {
+ return cbi_validators.cidr6.apply(this) ||
+ cbi_validators.ipnet6.apply(this) ||
+ cbi_validators.ip6addr.apply(this);
+ },
+
'port': function()
{
var p = Int(this);
{
return cbi_validators.hostname.apply(this) ||
((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
- ((ipv4only == 1) && cb_validators.ip4addr.apply(this));
+ ((ipv4only == 1) && cbi_validators.ip4addr.apply(this));
},
'hostname': function()
istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
}
}
- if (istat) {
- return !reverse;
+
+ if (istat ^ reverse) {
+ return true;
}
}
return def;
}
}
- nodes = document.querySelectorAll('[data-type]');
-
- for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
- cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
- node.getAttribute('data-type'));
- }
-
nodes = document.querySelectorAll('[data-choices]');
for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
cbi_dynlist_init(node, choices[2], choices[3], options);
}
+ nodes = document.querySelectorAll('[data-type]');
+
+ for (var i = 0, node; (node = nodes[i]) !== undefined; i++) {
+ cbi_validate_field(node, node.getAttribute('data-optional') === 'true',
+ node.getAttribute('data-type'));
+ }
+
cbi_d_update();
}
var obj = document.getElementById(id)
var sel = document.createElement("select");
sel.id = selid;
+ sel.index = obj.index;
sel.className = obj.className.replace(/cbi-input-text/, 'cbi-input-select');
if (obj.nextSibling) {
var dt = obj.getAttribute('cbi_datatype');
var op = obj.getAttribute('cbi_optional');
- if (dt)
- cbi_validate_field(sel, op == 'true', dt);
-
if (!values[obj.value]) {
if (obj.value == "") {
var optdef = document.createElement("option");
obj.style.display = "none";
+ if (dt)
+ cbi_validate_field(sel, op == 'true', dt);
+
cbi_bind(sel, "change", function() {
if (sel.selectedIndex == sel.options.length - 1) {
obj.style.display = "inline";
browser.focus();
}
-function cbi_browser_init(id, defpath)
+function cbi_browser_init(id, resource, defpath)
{
function cbi_browser_btnclick(e) {
cbi_filebrowser(id, defpath);
var btn = document.createElement('img');
btn.className = 'cbi-image-button';
- btn.src = cbi_strings.path.resource + '/cbi/folder.gif';
+ btn.src = (resource || cbi_strings.path.resource) + '/cbi/folder.gif';
field.parentNode.insertBefore(btn, field.nextSibling);
cbi_bind(btn, 'click', cbi_browser_btnclick);
parent.appendChild(b);
if (datatype == 'file')
{
- cbi_browser_init(t.id, parent.getAttribute('data-browser-path'));
+ cbi_browser_init(t.id, null, parent.getAttribute('data-browser-path'));
}
parent.appendChild(document.createElement('br'));
input.value = '';
cbi_dynlist_keydown({
- target: se,
+ target: input,
keyCode: 8
});
}
else
{
cbi_dynlist_keydown({
- target: se,
+ target: input,
keyCode: 13
});
}
var quot_esc = [/"/g, '"', /'/g, '''];
function esc(s, r) {
+ if (typeof(s) !== 'string' && !(s instanceof String))
+ return '';
+
for( var i = 0; i < r.length; i += 2 )
s = s.replace(r[i], r[i+1]);
return s;
break;
case 'd':
- subst = (+param || 0);
+ subst = ~~(+param || 0);
break;
case 'u':
- subst = Math.abs(+param || 0);
+ subst = ~~Math.abs(+param || 0);
break;
case 'f':