projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #980 from NvrBst/pull-request-upnp_description
[project/luci.git]
/
modules
/
luci-base
/
htdocs
/
luci-static
/
resources
/
cbi.js
diff --git
a/modules/luci-base/htdocs/luci-static/resources/cbi.js
b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index
8e66cbc
..
b334703
100644
(file)
--- a/
modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/
modules/luci-base/htdocs/luci-static/resources/cbi.js
@@
-118,48
+118,88
@@
var cbi_validators = {
return false;
},
return false;
},
- 'ip
mask
': function()
+ 'ip
4prefix
': function()
{
{
- return cbi_validators.ipmask4.apply(this) ||
- cbi_validators.ipmask6.apply(this);
+ return !isNaN(this) && this >= 0 && this <= 32;
},
},
- 'ip
mask4
': function()
+ 'ip
6prefix
': function()
{
{
- var ip = this, mask = 32;
+ return !isNaN(this) && this >= 0 && this <= 128;
+ },
- if (ip.match(/^(\S+)\/(\S+)$/))
+ '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;
{
ip = RegExp.$1;
mask = RegExp.$2;
+ return cbi_validators.ip4addr.apply(ip) &&
+ cbi_validators.ip4prefix.apply(mask);
}
}
+ return false;
+ },
- if (!isNaN(mask) && (mask < 0 || mask > 32))
- return false;
-
- if (isNaN(mask) && !cbi_validators.ip4addr.apply(mask))
- return false;
-
- return cbi_validators.ip4addr.apply(ip);
+ '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;
},
},
- 'ip
mask6
': function()
+ 'ip
net4
': function()
{
{
- var ip = this, mask = 128;
+ if (this.match(/^(\S+)\/(\S+)$/))
+ {
+ ip = RegExp.$1;
+ net = RegExp.$2;
+ return cbi_validators.ip4addr.apply(ip) &&
+ cbi_validators.ip4addr.apply(net);
+ }
+ return false;
+ },
- if (ip.match(/^(\S+)\/(\S+)$/))
+ 'ipnet6': function()
+ {
+ if (this.match(/^(\S+)\/(\S+)$/))
{
ip = RegExp.$1;
{
ip = RegExp.$1;
- mask = RegExp.$2;
+ net = RegExp.$2;
+ return cbi_validators.ip6addr.apply(ip) &&
+ cbi_validators.ip6addr.apply(net);
}
}
+ return false;
+ },
- if (!isNaN(mask) && (mask < 0 || mask > 128))
- return false;
+ 'ipmask': function()
+ {
+ return cbi_validators.ipmask4.apply(this) ||
+ cbi_validators.ipmask6.apply(this);
+ },
- if (isNaN(mask) && !cbi_validators.ip6addr.apply(mask))
- return false;
+ 'ipmask4': function()
+ {
+ return cbi_validators.cidr4.apply(this) ||
+ cbi_validators.ipnet4.apply(this) ||
+ cbi_validators.ip4addr.apply(this);
+ },
- return cbi_validators.ip6addr.apply(ip);
+ 'ipmask6': function()
+ {
+ return cbi_validators.cidr6.apply(this) ||
+ cbi_validators.ipnet6.apply(this) ||
+ cbi_validators.ip6addr.apply(this);
},
'port': function()
},
'port': function()
@@
-189,7
+229,7
@@
var cbi_validators = {
{
return cbi_validators.hostname.apply(this) ||
((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
{
return cbi_validators.hostname.apply(this) ||
((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
- ((ipv4only == 1) && cb_validators.ip4addr.apply(this));
+ ((ipv4only == 1) && cb
i
_validators.ip4addr.apply(this));
},
'hostname': function()
},
'hostname': function()
@@
-481,8
+521,9
@@
function cbi_d_check(deps) {
istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
}
}
istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
}
}
- if (istat) {
- return !reverse;
+
+ if (istat ^ reverse) {
+ return true;
}
}
return def;
}
}
return def;
@@
-648,9
+689,6
@@
function cbi_combobox(id, values, def, man, focus) {
var dt = obj.getAttribute('cbi_datatype');
var op = obj.getAttribute('cbi_optional');
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");
if (!values[obj.value]) {
if (obj.value == "") {
var optdef = document.createElement("option");
@@
-685,6
+723,9
@@
function cbi_combobox(id, values, def, man, focus) {
obj.style.display = "none";
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";
cbi_bind(sel, "change", function() {
if (sel.selectedIndex == sel.options.length - 1) {
obj.style.display = "inline";
@@
-727,7
+768,7
@@
function cbi_filebrowser(id, defpath) {
browser.focus();
}
browser.focus();
}
-function cbi_browser_init(id, defpath)
+function cbi_browser_init(id,
resource,
defpath)
{
function cbi_browser_btnclick(e) {
cbi_filebrowser(id, defpath);
{
function cbi_browser_btnclick(e) {
cbi_filebrowser(id, defpath);
@@
-738,7
+779,7
@@
function cbi_browser_init(id, defpath)
var btn = document.createElement('img');
btn.className = 'cbi-image-button';
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);
field.parentNode.insertBefore(btn, field.nextSibling);
cbi_bind(btn, 'click', cbi_browser_btnclick);
@@
-805,7
+846,7
@@
function cbi_dynlist_init(parent, datatype, optional, choices)
parent.appendChild(b);
if (datatype == 'file')
{
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'));
}
parent.appendChild(document.createElement('br'));