Select Git revision
gluon-web.js
Forked from
firmware / FFS Gluon
Source project has a limited visibility.
-
Matthias Schiffer authored
If a value is unset or optional, an empty choice is added to the selection. This empty choice will be marked as invalid if the value is not optional. This is properly supported for the 'select' widget only for now, and not for 'radio'.
Matthias Schiffer authoredIf a value is unset or optional, an empty choice is added to the selection. This empty choice will be marked as invalid if the value is not optional. This is properly supported for the 'select' widget only for now, and not for 'radio'.
gluon-web.js 11.02 KiB
/*
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
Copyright 2017 Matthias Schiffer <mschiffer@universe-factory.net>
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
*/
/*
Build using:
uglifyjs javascript/gluon-web.js -o files/lib/gluon/web/www/static/resources/gluon-web.js -c -m --support-ie8
*/
(function() {
var dep_entries = {};
function Int(x) {
return (/^-?\d+$/.test(x) ? +x : NaN);
}
function Dec(x) {
return (/^-?\d*\.?\d+?$/.test(x) ? +x : NaN);
}
var validators = {
'integer': function() {
return !isNaN(Int(this));
},
'uinteger': function() {
return (Int(this) >= 0);
},
'float': function() {
return !isNaN(Dec(this));
},
'ufloat': function() {
return (Dec(this) >= 0);
},
'ipaddr': function() {
return validators.ip4addr.apply(this) ||
validators.ip6addr.apply(this);
},
'ip4addr': function() {
var match;
if ((match = this.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/))) {
return (match[1] >= 0) && (match[1] <= 255) &&
(match[2] >= 0) && (match[2] <= 255) &&
(match[3] >= 0) && (match[3] <= 255) &&
(match[4] >= 0) && (match[4] <= 255);
}
return false;
},
'ip6addr': function() {
if (this.indexOf('::') < 0)
return (this.match(/^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i) != null);