/
sdjs.js
24 lines (24 loc) · 12.4 KB
/
sdjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,a,b){d!=Array.prototype&&d!=Object.prototype&&(d[a]=b.value)};$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(d,a,b,g){if(a){b=$jscomp.global;d=d.split(".");for(g=0;g<d.length-1;g++){var k=d[g];k in b||(b[k]={});b=b[k]}d=d[d.length-1];g=b[d];a=a(g);a!=g&&null!=a&&$jscomp.defineProperty(b,d,{configurable:!0,writable:!0,value:a})}};$jscomp.polyfill("Number.isFinite",function(d){return d?d:function(a){return"number"!==typeof a?!1:!isNaN(a)&&Infinity!==a&&-Infinity!==a}},"es6","es3");
$jscomp.polyfill("Number.isInteger",function(d){return d?d:function(a){return Number.isFinite(a)?a===Math.floor(a):!1}},"es6","es3");$jscomp.polyfill("Number.MAX_SAFE_INTEGER",function(){return 9007199254740991},"es6","es3");$jscomp.polyfill("Number.isSafeInteger",function(d){return d?d:function(a){return Number.isInteger(a)&&Math.abs(a)<=Number.MAX_SAFE_INTEGER}},"es6","es3");
(function(){var d=function(){return{isNumber:function(a){return"number"===typeof a&&!isNaN(a)},isInteger:function(a){return this.isNumber(a)&&Number.isInteger(a)},isFloat:function(a){return this.isNumber(a)&&0!==a%1},isString:function(a){return"string"===typeof a},isEmptyString:function(a){return this.isString(a)&&0==a.length},isNumberString:function(a){return this.isString(a)&&!isNaN(a)&&a==+a},isNormalizedString:function(a){return this.isString(a)&&a.replace(/[\t\r\n]/g,"")==a},isIntegerString:function(a){return this.isString(a)&&
this.isInteger(+a)},isFloatString:function(a){return this.isString(a)&&this.isFloat(+a)},isFractionString:function(a){return this.isString(a)&&/^[1-9][0-9]*\/[1-9][0-9]*$/.test(a)},isExponentString:function(a){return this.isNumberString(a)&&/e\+|-/gi.test(a)},isHexString:function(a){return this.isString(a)&&/^-?0x[0-9a-f]+$/i.test(a)},isOctalString:function(a){return this.isString(a)&&/^(-?0[0-7]+ ?)+$/.test(a)},isDateString:function(a){return this.isString(a)&&"Invalid Date"!==(new Date(a)).toString()&&
!isNaN(new Date(a))},isAsciiString:function(a){return this.isString(a)&&/^[\x00-\xFF]+$/.test(a)},isUnicodeString:function(a){return this.isString(a)&&/^[\u0000-\u10FFFF]+$/.test(a)},isEmail:function(a){var b=/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;return this.isString(a)&&b.test(a)},isUrl:function(a){var b=/^(ftp:|ftps:|ws:|wss:|http:|https:)?(\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/[-a-z\d%_.~+=]*)*(\?[;&a-z\d%_.~+=-]*)?(#[-a-z\d_]*)?$/i;
return this.isString(a)&&b.test(a)},isIpv4:function(a){var b=/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;return this.isString(a)&&b.test(a)},isUuid:function(a){var b=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$/;return this.isString(a)&&b.test(a)},isCountry:function(a){return this.isString(a)&&-1!=="AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF PM VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK SD SR SJ SZ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VE VN VG VI WF EH YE ZM ZW".split(" ").indexOf(a.trim().toUpperCase())},
isLanguage:function(a){return this.isString(a)&&/^[a-z]{2,3}(?:-[A-Z]{2,3}(?:-[a-zA-Z]{4})?)?$/.test(a)},isCssLength:function(a){var b="ch em ex rem vh vw px mm cm in pt pc".split(" ");return this.isString(a)&&-1!==b.indexOf(a.trim().slice(-2).toLowerCase())||-1!==["vmin","vmax"].indexOf(a.trim().slice(-4).toLowerCase())},isJsonString:function(a){try{JSON.parse(a)}catch(b){return!1}return!0},isRegExpString:function(a){return this.isString(a)&&this.isRegExp(new RegExp(a))},isUrlEncoded:function(a){return encodeURIComponent(decodeURIComponent(a))===
a},isBase64:function(a){try{return btoa(atob(a))==a}catch(b){return!1}},isCssAngle:function(a){return this.isString(a)&&(-1!==["deg","rad"].indexOf(a.trim().slice(-3).toLowerCase())||-1!==["grad","turn"].indexOf(a.trim().slice(-4).toLowerCase()))},isCssResolution:function(a){return this.isString(a)&&(-1!==["dpcm","dppx"].indexOf(a.trim().slice(-4).toLowerCase())||"dpi"===a.trim().slice(-3).toLowerCase())},isCssFrequency:function(a){return this.isString(a)&&("hz"===a.trim().slice(-2).toLowerCase()||
"khz"===a.trim().slice(-3).toLowerCase())},isCssTime:function(a){return this.isString(a)&&("s"===a.trim().slice(-1).toLowerCase()||"ms"===a.trim().slice(-2).toLowerCase())},isCssPercentage:function(a){return this.isString(a)&&"%"===a.trim().slice(-1).toLowerCase()},isCssPosition:function(a){return-1!==["static","relative","absolute","sticky","fixed"].indexOf(a.trim().toLowerCase())},isDate:function(a){return this.isDateString(a)&&/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/.test(a)},isTime:function(a){return this.isString(a)&&
/^([0-1][0-9]|2[0-4]):([0-5][0-9]):[0-5][0-9](.\d{3})?$/.test(a)},isDateTime:function(a){return this.isString(a)&&/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ([0-1][0-9]|2[0-4]):([0-5][0-9]):[0-5][0-9](.\d{3})?$/.test(a)},isGYear:function(a){return this.isString(a)&&/^\d{4}$/.test(a)},isGMonth:function(a){return this.isString(a)&&/^(0[1-9]|1[012])--$/.test(a)},isGDay:function(a){return this.isString(a)&&/^---(0[1-9]|[12][0-9]|3[01])$/.test(a)},isGYearMonth:function(a){return this.isString(a)&&
/^\d{4}-(0[1-9]|1[012])$/.test(a)},isGMonthDay:function(a){return this.isString(a)&&/^--(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/.test(a)},isExponent:function(a){return this.isNumber(a)&&/^e\+|-/i.test(a)},isZero:function(a){return this.isInteger(a)&&0===a},isPositiveInteger:function(a){return this.isInteger(a)&&0<a},isNonNegativeInteger:function(a){return this.isInteger(a)&&0<=a},isNegativeInteger:function(a){return this.isInteger(a)&&0>a},isNonPositiveInteger:function(a){return this.isInteger(a)&&
0>=a},isPositiveFloat:function(a){return this.isFloat(a)&&0<a},isNonNegativeFloat:function(a){return this.isFloat(a)&&0<=a},isNegativeFloat:function(a){return this.isFloat(a)&&0>a},isNonPositiveFloat:function(a){return this.isFloat(a)&&0>=a},isTrue:function(a){return this.isBoolean(a)&&!0===a},isFalse:function(a){return this.isBoolean(a)&&!1===a},isFiniteNumber:function(a){return isFinite(a)},isBoolean:function(a){return"boolean"===typeof a},isUndefined:function(a){return void 0===a},isNull:function(a){return null===
a},isRegExp:function(a){return a instanceof RegExp&&"RegExp"===Object.prototype.toString.call(a).slice(8,-1)},isArray:function(a){return Array.isArray(a)},isEmptyArray:function(a){return Array.isArray(a)&&0===a.length},isStringArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isString(a)})},isNumberArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isNumber(a)})},isIntegerArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isInteger(a)})},
isPositiveIntegerArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isInteger(a)&&0<a})},isNonNegativeIntegerArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isInteger(a)&&0<=a})},isNegativeIntegerArray:function(a){var b=this;return Array.isArray(a)&&a.every(function(a){return b.isInteger(a)&&0>a})},isCssString:function(a){return this.isString(a)&&/^(?:\s*[\S ]+\s*{[^}]*})+/.test(a)},isHexColor:function(a){return this.isString(a)&&
/^#([a-f0-9]{3}){1,2}$/i.test(a)},isRgbColor:function(a){return this.isString(a)&&/^rgb(a)?\(\d{1,3},\s?\d{1,3},\s?\d{1,3}\)$/i.test(a)},isCssRatio:function(a){return this.isString(a)&&/^[1-9][0-9]*\/[1-9][0-9]*$/.test(a)},isJsonObject:function(a){return"object"===typeof a&&"Object"===Object.prototype.toString.call(a).slice(8,-1)},isEmptyObject:function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},isSafeInteger:function(a){return this.isInteger(a)&&Number.isSafeInteger(a)},isEnumeration:function(a,
b){return Array.isArray(b)&&-1!==b.indexOf(a)},isPattern:function(a,b){if(Array.isArray(b))return 1==b.length?(new RegExp(b[0])).test(a):1<b.length?(new RegExp(b[0],b[1])).test(a):!1},isLength:function(a,b){return this.isNonNegativeInteger(b)&&this.isString(a)&&b===a.length},isMaxLength:function(a,b){return this.isNonNegativeInteger(b)&&this.isString(a)&&b>=a.length},isMinLength:function(a,b){return this.isNonNegativeInteger(b)&&this.isString(a)&&b<=a.length},isTotalDigits:function(a,b){return this.isNumber(a)&&
b===a.toString().replace(".","").length},isFractionDigits:function(a,b){return this.isFloat(a)&&b===a.toString().split(".")[1].length},isMinExclusive:function(a,b){return this.isNumber(a)&&b<a},isMaxExclusive:function(a,b){return this.isNumber(a)&&b>a},isMinInclusive:function(a,b){return this.isNumber(a)&&b<=a},isMaxInclusive:function(a,b){return this.isNumber(a)&&b>=a}}};window.sdjs=new function(a){this.NAME="SDJS";this.DESCRIPTION="SDJS for web browser "+a;var b=d();this.valiType=function(a,d,c,
e){return b["is"+a.charAt(0).toUpperCase()+a.slice(1)]?b["is"+a.charAt(0).toUpperCase()+a.slice(1)](c)?!0:(b.isPositiveInteger(d)?console.log("The value: "+c+" to index: "+d+" of property: "+e+" isn't the type: "+a):console.log("The value: "+c+" to property: "+e+" isn't the type: "+a),!1):(console.log(a+" is an invalid data type."),!1)};this.valiConstraint=function(a,d,c,e){var g=!0,h;for(h in a)a.hasOwnProperty(h)&&(b["is"+h.charAt(0).toUpperCase()+h.slice(1)]||(console.log(h+" is an invalid constraint."),
g=!1),b["is"+h.charAt(0).toUpperCase()+h.slice(1)](c,a[h])||(b.isPositiveInteger(d)?console.log("The constaint: "+h+" is invalid to the index: "+d+" of property: "+e+" with the value: "+c):console.log("The constaint: "+h+" is invalid to the property: "+e+" with the value: "+c),g=!1));return g};this.valiSdjs=function(a,d){d=d||{};var c;for(c in a)if(a.hasOwnProperty(c))if("_pfGlobal"===c&&b.isJsonObject(a._pfGlobal)&&(d=a._pfGlobal),b.isJsonObject(a[c])){var e=this.valiSdjs(a[c],d);e||(window.flag=
1)}else if(Array.isArray(a[c]))for(var f=0,h=a[c].length;f<h;f++)if(b.isJsonObject(a[c][f])||Array.isArray(a[c][f]))e=this.valiSdjs(a[c][f],d),e||(window.flag=1);else{if(a.hasOwnProperty(c+"_pfidx")){var g=null;a[c+"_pfidx"].hasOwnProperty("all")&&"undefined"!==typeof a[c+"_pfidx"].all.type?g="all":a[c+"_pfidx"].hasOwnProperty("i"+f)&&"undefined"!==typeof a[c+"_pfidx"]["i"+f].type&&(g="i"+f);null!==g&&(e=this.valiType(a[c+"_pfidx"][g].type,f,a[c][f],c),e||(window.flag=1),"undefined"!==typeof a[c+
"_pfidx"][g].constraint&&(e=this.valiConstraint(a[c+"_pfidx"][g].constraint,f,a[c][f],c),e||(window.flag=1)))}}else a.hasOwnProperty(c+"_pfsch")&&"string"===typeof a[c+"_pfsch"]&&""!==a[c+"_pfsch"]&&d.hasOwnProperty(c+"_"+a[c+"_pfsch"])&&"undefined"!==typeof d[c+"_"+a[c+"_pfsch"]].type?(e=this.valiType(d[c+"_"+a[c+"_pfsch"]].type,c,a[c],c),e||(window.flag=1),"undefined"!==typeof d[c+"_"+a[c+"_pfsch"]].constraint&&(e=this.valiConstraint(d[c+"_"+a[c+"_pfsch"]].constraint,c,a[c],c),e||(window.flag=1))):
a.hasOwnProperty(c+"_pfsch")&&"undefined"!==typeof a[c+"_pfsch"].type?(e=this.valiType(a[c+"_pfsch"].type,c,a[c],c),e||(window.flag=1),"undefined"!==typeof a[c+"_pfsch"].constraint&&(e=this.valiConstraint(a[c+"_pfsch"].constraint,c,a[c],c),e||(window.flag=1))):6<c.length&&"_pfsch"===c.slice(-6)&&"implied"===a[c].presence&&"undefined"!==typeof a[c].type&&!a.hasOwnProperty(c.slice(0,-6))&&(f="",h=null,a.hasOwnProperty(c.slice(0,-6)+"_default")?(f=c.slice(0,-6)+"_default",h=a[f]):a.hasOwnProperty(c.slice(0,
-6)+"_fixed")&&(f=c.slice(0,-6)+"_fixed",h=a[f]),null!==h&&(e=this.valiType(a[c].type,f,h,c),e||(window.flag=1),"undefined"!==typeof a[c].constraint&&(e=this.valiConstraint(a[c].constraint,f,h,c),e||(window.flag=1))));return void 0!==window.flag&&1===window.flag?(window.flag=0,!1):!0}}("Version 1.2.0")})();