libs/web: remove neg_ipaddr, neg_ip4addr and neg_network_ip4addr datatypes, can be...
[project/luci.git] / libs / web / htdocs / luci-static / resources / cbi.js
index 4b8cd5c..05e15d2 100644 (file)
@@ -42,31 +42,23 @@ var cbi_validators = {
                return cbi_validators.ip4addr(v) || cbi_validators.ip6addr(v);
        },
 
-       'neg_ipaddr': function(v)
-       {
-               return cbi_validators.ip4addr(v.replace(/^\s*!/, "")) || cbi_validators.ip6addr(v.replace(/^\s*!/, ""));
-       },
-
        'ip4addr': function(v)
        {
-               if( v.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\/(\d+))?$/) )
+               if (v.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(\/(\S+))?$/))
                {
                        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)))
+                              ((RegExp.$6.indexOf('.') < 0)
+                                 ? ((RegExp.$6 >= 0) && (RegExp.$6 <= 32))
+                                 : (cbi_validators.ip4addr(RegExp.$6)))
                        ;
                }
 
                return false;
        },
 
-       'neg_ip4addr': function(v)
-       {
-               return cbi_validators.ip4addr(v.replace(/^\s*!/, ""));
-       },
-
        'ip6addr': function(v)
        {
                if( v.match(/^([a-fA-F0-9:.]+)(\/(\d+))?$/) )
@@ -189,12 +181,6 @@ var cbi_validators = {
                return (v.match(/^[a-zA-Z0-9_]+$/) != null);
        },
 
-       'neg_network_ip4addr': function(v)
-       {
-               v = v.replace(/^\s*!/, "");
-               return cbi_validators.uciname(v) || cbi_validators.ip4addr(v);
-       },
-
        'range': function(v, args)
        {
                var min = parseInt(args[0]);
@@ -499,6 +485,7 @@ function cbi_dynlist_init(name, respath, datatype, optional, choices)
        var input0 = document.getElementsByName(name)[0];
        var prefix = input0.name;
        var parent = input0.parentNode;
+       var holder = input0.placeholder;
 
        var values;
 
@@ -543,6 +530,11 @@ function cbi_dynlist_init(name, respath, datatype, optional, choices)
                                t.index = i;
                                t.className = 'cbi-input-text';
 
+                       if (i == 0 && holder)
+                       {
+                               t.placeholder = holder;
+                       }
+
                        var b = document.createElement('img');
                                b.src = respath + ((i+1) < values.length ? '/cbi/remove.gif' : '/cbi/add.gif');
                                b.className = 'cbi-image-button';
@@ -722,7 +714,7 @@ function cbi_dynlist_init(name, respath, datatype, optional, choices)
                return false;
        }
 
-       cbi_dynlist_redraw(0, -1, -1);
+       cbi_dynlist_redraw(-1, -1, -1);
 }
 
 //Hijacks the CBI form to send via XHR (requires Prototype)