123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790 |
-
- Namespace.register("U.MS");
- U.MS.browser = /(msie|firefox|chrome|ipad|iphone|safari|opera|version|rv).*?([\d.]+)/;
- U.MS.browsers = {
- msie: /msie ([\d.]+)|(trident)\/([\d.]+)/,
- firefox: /firefox\/([\d.]+)/,
- chrome: /chrome\/([\d.]+)/,
- opera: /opera.([\d.]+)/,
- safari: /version\/([\w.]+).*(safari)/
- };
- U.MS.Event = /\[object (Keyboard|Mouse|Focus|Wheel|Composition|Storage|MS|)Event(Obj|)\]/;
- U.MS.Guid = /^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$/;
- U.MS.English = /^[A-Za-z]+$/;
- U.MS.RNum = /\d+/g;
- U.MS.Number = /^\d+$/;
- U.MS.Num = /^(-?\d+)(\.\d+)?$/;
- U.MS.EN = /^([a-zA-Z0-9_\-]+)$/;
- U.MS.Url = /^\w+\:\/\/([\w+]).*/;
- U.MS.FileName = /^([a-zA-Z0-9\s\._-]+)$/;
- U.MS.ZWFileName = /^[0-9a-zA-Z\u4e00-\u9fa5\._-]{1,40}\\*$/;
- U.MS.PBrief = /^.{0,100}$/;
- U.MS.FFZF = /^(\w|-|[\u4E00-\u9FA5])*$/;
- U.MS.ChineseIdCard = /\d{17}[\d|X]|\d{15}/;
- U.MS.TelephoneNumber = /^1[0-9]{10}$/;
- U.MS.Email = /^\w+([_+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
- U.MS.TrueName = /^[\u4e00-\u9fa5]{1,20}$|^[a-zA-Z]{1,20}$/;
- U.MS.UserName = /^\S{1,25}$/;
- U.MS.NickName = /^[0-9a-zA-Z\u4e00-\u9fa5_-]{1,40}\\*$/;
- U.MS.PassWord = /^[^\u4E00-\u9FA5\uF900-\uFA2D]{6,20}$/;
- U.MS.Visa = /^[45]\d{15}$/;
- U.MS.rgb = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/
- U.MS.jsonToStr = function (obj) {
- var i, _type = false,
- _str = "",
- _type = typeof (obj);
-
- if (obj == null) { }
- else {
- obj = obj.valueOf();
- if ("boolean,number".indexOf(_type) > -1) {
- _str = obj.toString();
- }
- else if (_type == "string") {
- _str = "\"" + obj + "\"";
- }
- else if (U.M.GetType(obj) == "array") {
- _str = "["; for (i = 0; i < obj.length; i++) {
- _str += U.MS.jsonToStr(obj[i]) + ((i < obj.length - 1) ? "," : "")
- }; _str += "]"; return _str
- }
- else {
- _str = "{";
- for (i in obj) {
- if (obj.hasOwnProperty(i)) {
- (_str.length > 1) && (_str += ","); _str += "\"" + i + "\":" + U.MS.jsonToStr(obj[i]);
- }
- } _str += "}";
- }
- return _str;
- }
- }
- U.M.String = {
-
-
-
-
-
- escapeQuotes: function () {
- return this.replace(/'/ig, '\'').replace(/"/ig, "\"");
- },
- count: function () {
- return this.substrU();
- },
-
- substrU: function (start, end) {
- var i, _UTF, _UN = 0, _UMS = "";
- (end == null && start != null) && (end = start, start = 0);
- _UTF = (start == null && end == null);
- for (i = 0; i < this.length; i++) {
- _UN += this.charCodeAt(i) < 255 ? 1 : 2;
- if (_UN < start) { continue; }
- if (_UN <= end || _UTF) {
- _UMS += this.charAt(i);
- continue;
- }
- break;
- }
- return (_UTF ? _UN : _UMS);
- },
-
-
-
-
-
-
- isStrNull: function () {
- return this.trim() == "";
- },
-
- replaceRnToBr: function () {
- return this.replace(/\r\n/g, "<br />");
- },
-
- replaceBrToRn: function () {
- return this.replace(/<(BR)[^<>]*>/ig, "\r\n");
- },
- removeP: function () {
- return this.replace(/<(p)[^<>]*>/ig, "");
- },
- removeBr: function () {
- return this.replace(/<(BR)[^<>]*>/ig, "");
- },
- removeRn: function () {
- return this.replace(/\r\n/g, "");
- },
- replaceBrAndBlank: function () {
- return this.replaceBrToRn().replace(/ /g, '');
- },
-
- isHtmlNull: function () {
- return this.removeBr().removeP().trim() != "";
- },
-
- replaceLtAndGt: function () {
- return this.replace(/</g, "<").replace(/>/g, ">");
- },
-
- replaceAngleBrackets: function () {
- return this.replace(/</g, "<").replace(/>/g, ">");
- },
-
-
-
- replaceHtmlSign: function () {
- return this.replace(/&(?!#?[a-zA-Z0-9]+;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
- },
- replaceDoubleToAngleBrackets: function () {
- return this.replace(/\《/g, "<").replace(/\》/g, ">");
- },
- replaceAngleToDoubleBrackets: function () {
- return this.replace(/\</g, "《").replace(/\>/g, "》");
- },
- trim: function (UST) {
- return this.replace(/\ |\ |\s+|\n|\r|\t/g, UST || "");
- },
- lTrim: function () {
- return this.replace(/(^\s*)/g, "");
- },
- rTrim: function () {
- return this.replace(/(\s*$)/g, "");
- },
- addPreSpace: function (n) {
- var i, k = "";
- for (i = 0; i < n; i++)
- k += " ";
- return k + this;
- },
- insertString: function (str, n) {
-
- var _pre = this.substr(0, n);
- var _back = this.substr(n, this.length);
- return _pre + str + _back;
- },
-
- addEllipsis: function (n) {
- var _str = this.substrU(0, n);
- if (_str != this) {
- _str = _str + "...";
- }
-
- return _str.valueOf();
- },
-
- toInt: function () {
- var _UTV = this.valueOf(), _UMS = _UTV.match(/^(-|\+)?\d+/g);
- return _UMS && _UMS.length == 1 ? Number(_UMS[0]) : _UTV;
- },
-
- replaceStr: function (source, target) {
- return this.replace(new RegExp(source, "gm"), target);
- },
- parseJSON: function () {
- var _UJE = null, _UST = this;
- try {
- _UJE = eval("0,(" + _UST + ")");
- } catch (e) { }
- return (_UJE == null ? _UST : _UJE).valueOf();
- },
- capitalizeFirstLetter: function () {
- return this.replace(/\b(\w)|\s(\w)/g, function (UAE) { return UAE.toUpperCase(); });
- },
-
- SplitRN: function () {
- return this.replace(/\r\n/g, "\n").split("\n");
- },
-
-
-
- SplitAngleBrackets: function (h) {
- var i, s, a = [];
- for (i = 0; i < h.length; i++) {
- if (h[i] == "<")
- s = i;
- if (h[i] == ">")
- a.push(h.substring(s, i + 1));
- };
- return a;
- },
-
- htmlToText: function () {
- return String(this).replace(/(<(.[^>]*)>)/g, "");
- },
-
- htmlToTextRn: function () {
- return this.replace(/(<(.[^>]*)>)/g, function (str) {
- return (/(<\/(div|DIV|p|P)([|^>]*)>)|<(BR)[^<>]*>/g.test(str)) ? "\r\n" : "";
- });
- }
- };
- U.M.Number = {
-
- formatMoney: function () {
- var _split;
- var _arr = [];
- var _str = this.toString();
- while (_str) {
- _split = _str.length - 3;
-
- _arr.unshift(_str.substr(_split < 0 ? 0 : _split));
- _str = _str.substr(0, _split);
- }
- return _arr.join(",");
- },
-
- prefixInteger: function (n) {
- return (this < 10 ? "0" + this : this).valueOf();
-
- return (Array(n).join(0) + this).slice(-n);
- },
-
- toRadians: function () {
- return this * Math.PI / 180;
- }
- };
- Array.isArray = Array.isArray || function (arr) {
- return Object.prototype.toString.call(arr) === "[object Array]";
- }
- U.M.Array = {
-
- indexOf: Array.prototype.indexOf || function (val, startpoint) {
- var i = startpoint || 0,
- j;
-
- for (; i < this.length; i++) {
-
- if (this[i] == val) {
- return i;
- }
- }
-
- return -1;
- },
-
-
- objIndexOf: function (obj) {
- var i,
- j,
- _isfind;
- for (i = 0; i < this.length; i++) {
- _isfind = false;
-
- for (j in obj) {
-
- if (this[i][j] == obj[j]) {
- _isfind = true;
- }
-
- else {
- _isfind = false;
- break;
- }
- }
-
- if (_isfind) {
- return i;
- }
- }
-
- return -1;
- },
-
- unique: function () {
-
- var result = [];
- var obj = {};
- for (var i = 0; i < this.length; i++) {
- if (!obj[this[i]]) {
- result.push(this[i]);
- obj[this[i]] = true;
- }
- }
- return result
- },
-
-
-
-
- forEach: Array.prototype.forEach || function (cb, thisArg) {
- var i = 0;
- var _length = this.length;
- while (i < _length) {
- cb.call(thisArg, this[i], i, this);
- i++;
- }
- },
-
- every: Array.prototype.every || function (cb, thisArg) {
-
- var i = 0, b;
- var _length = this.length;
- while (i < _length) {
- b = cb.call(thisArg, this[i], i, this);
- if (b == false) {
- return b;
- }
- i++;
- }
- return true;
- },
-
- some: Array.prototype.some || function (cb, thisArg) {
- var t = Object(this);
- var len = t.length;
- for (var i = 0; i < len; i++) {
- if (i in t && cb.call(thisArg, t[i], i, t))
-
- return true;
- }
- return false;
- },
-
- map: Array.prototype.map || function (cb, thisArg) {
-
-
- var i = 0;
-
- var _length = this.length;
-
- var arr = [];
-
- if (typeof cb != "function")
- throw new TypeError();
-
- while (i < _length) {
-
- if(i in this){
-
- arr.push(cb.call(thisArg, this[i], i, this));
- }
-
- i++;
- }
-
- return arr;
- },
-
- filter: Array.prototype.filter || function (cb, thisArg) {
-
-
- var i = 0;
-
- var _length = this.length;
-
- var arr = [];
-
- if (typeof cb != "function")
- throw new TypeError();
- while (i < _length) {
-
- if (i in this && cb.call(thisArg, this[i], i, this))
- arr.push(this[i]);
- i++;
- }
- return arr;
- },
-
-
- findIndex: Array.prototype.findIndex || function (predicate) {
-
-
- var i = 0;
-
- var _length = this.length;
-
- if (typeof predicate != "function")
- throw new TypeError();
- while (i < _length) {
-
- if (predicate(this[i], i, this))
-
- return i;
- i++;
- }
- return -1;
- },
-
- lastIndexOf: Array.prototype.lastIndexOf || function (searchElement, fromIndex) {
- var n, k,
- t = Object(this),
- len = t.length;
- if (len === 0) {
-
- return -1;
- }
- n = len - 1;
- if (arguments.length > 1) {
- n = Number(arguments[1]);
- if (n != n) {
- n = 0;
- }
- else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) {
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
- }
- }
- for (k = n >= 0
- ? Math.min(n, len - 1)
- : len - Math.abs(n); k >= 0; k--) {
- if (k in t && t[k] === searchElement) {
-
- return k;
- }
- }
-
- return -1;
-
-
- },
-
-
-
- fill: Array.prototype.fill || function (value) {
- var O = Object(this);
-
- var len = O.length;
- var start = arguments[1];
- var relativeStart = start;
-
- var k = relativeStart < 0 ?
- Math.max(len + relativeStart, 0) :
- Math.min(relativeStart, len);
- var end = arguments[2];
- var relativeEnd = end === undefined ?
- len : end;
-
- var _final = relativeEnd < 0 ?
- Math.max(len + relativeEnd, 0) :
- Math.min(relativeEnd, len);
-
- while (k < _final) {
- O[k] = value;
- k++;
- }
- return O;
- },
-
- copyWithin: Array.prototype.copyWithin || function (target, start, end) {
- var O = Object(this);
- var len = O.length;
-
- var relativeTarget = target;
-
- var to = relativeTarget < 0 ?
- Math.max(len + relativeTarget, 0) :
- Math.min(relativeTarget, len);
-
- var relativeStart = start;
-
- var from = relativeStart < 0 ?
- Math.max(len + relativeStart, 0) :
- Math.min(relativeStart, len);
- var end = arguments[2];
- var relativeEnd = end === undefined ? len : end >> 0;
-
- var _final = relativeEnd < 0 ?
- Math.max(len + relativeEnd, 0) :
- Math.min(relativeEnd, len);
- var count = Math.min(_final - from, len - to);
- var direction = 1;
- if (from < to && to < (from + count)) {
- direction = -1;
- from += count - 1;
- to += count - 1;
- }
-
- while (count > 0) {
- if (from in O) {
- O[to] = O[from];
- } else {
- delete O[to];
- }
- from += direction;
- to += direction;
- count--;
- }
-
- return O;
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- deepCopy: function () {
- var _newarr = [];
- for (i = 0; this.length; i++) {
- if (Array.isArray(this[i])) {
-
- deepCopy(this[i]);
- }
- else {
- return this.concat();
- }
- }
- return _newarr;
- }
- };
- window.Guid = U.M.Guid = {
-
- newGuid: function () {
- var _UN, i, _UGID = "";
- for (i = 0; i < 32; i++) {
- _UGID += Math.floor(Math.random() * 16).toString(16);
- _UN = Math.floor((i - 7) / 4);
- if (_UN > -1 && _UN < 4 && (i == (7 + 4 * _UN))) {
- _UGID += "-";
- }
- }
- return _UGID;
- },
-
- emptyGuid: US.NU,
-
- guidNoDash: function () {
- return Guid.newGuid().replace(/-/g, "");
- },
-
- IsGuid: function (UGID) {
- return U.MS.Guid.test(UGID);
- }
- }
|