日期方法集

作者:官方彩票手机投注网站-服务器运维

数组方法集

Angela.array = { //# 数组方法 // index, 返回位置! 不存在则返回 -1; index: function  { //# 返回当前值所在数组的位置 if  { return arr.indexOf; } for (var i = arr.length ; i--;) { if  { return i * 1; } }; return -1; } //返回对象 的 键值! 返回值 类型为数组。 , getKey: function  { //# 返回对象所有的键值 var arr = [] , k ; for  { arr.push; }; return arr; } //从数组中 随机取出 一个值 , random: function  { //# 从数组中 随机取出 一个值 arrays = arrays || []; var len = arrays.length , index = Tydic.math.randInt ; return arrays[index] || ''; } // 一维 数组去重 , unique: function  { //#一维数组去重 array = array || []; for (var i = 0, len = array.length; i < len; i++) { for (var j = i + 1; j < array.length; j++) { if (array[i] === array[j]) { array.splice; j--; } } } return array; } // max , 数组中最大的项 , max: function  {//#求数组中最大的项 return Math.max.apply; } // min , 数组中最小的项 , min: function  { //#求数组中最小的项 return Math.min.apply; } // remove , 移除 , remove: function  { //#移除数组中某值 var length = array.length; while  { if (value === array[length]) { array.splice; } } return array; } //清空数组 , empty: function  { //# 清空数组 .length = 0; return array; } // removeAt ,删除指定位置的 值 //@index , 索引. 不传递 index ,会删除第一个 , removeAt: function  { //#删除数组中 指定位置的值 array.splice; return array; } //打乱数组排序 , shuffle: function  { //#打乱数组排序 var array =  , length = array.length , i = length //遍历 , tmp = null // 临时 , rand = Tydic.math.randInt //位置 , pos = 0 ; while  { pos = rand; //交换随机位置 tmp = array[pos]; array[pos] = array[i]; array[i] = tmp; } return array; }};

cookie方法集

Angela.cookie = { //# Cookie // 浏览器是够支持 cookie enable: !!navigator.cookieEnabled //读取COOKIE , get: function  { //#读取 cookie var reg = new RegExp" + name + "? , val = document.cookie.match ; return val ? (val[2] ? unescape : ''; } //写入COOKIES , set: function (name, value, expires, path, domain, secure) { //# 写入 cookie var exp = new Date() , expires = arguments[2] || null , path = arguments[3] || "/" , domain = arguments[4] || null , secure = arguments[5] || false ; expires ? exp.setMinutes + parseInt : ""; document.cookie = name + '=' + escape + (expires ? ';expires=' + exp.toGMTString + (path ? ';path=' + path : '') + (domain ? ';domain=' + domain : '') + (secure ? ';secure' : ''); } //删除cookie , del: function (name, path, domain, secure) { //#删除 cookie var value = $getCookie; if  { var exp = new Date(); exp.setMinutes - 1000); path = path || "/"; document.cookie = name + '=;expires=' + exp.toGMTString() + (path ? ';path=' + path : '') + (domain ? ';domain=' + domain : '') + (secure ? ';secure' : ''); } }};

url方法集

Angela.url = { //#URL //参数:变量名,url为空则表从当前页面的url中取 getQuery: function  { var u = arguments[1] || window.location.search , reg = new RegExp" + name + "= , r = u.substr + 1).match ; return r != null ? r[2] : ""; } , getHash: function  { //# 获取 hash值 var u = arguments[1] || location.hash; var reg = new RegExp" + name + "=; var r = u.substr.match { return r[2]; } return ""; } , parse: function  { //# 解析URL var a = document.createElement; url = url || document.location.href; a.href = url; return { source: url , protocol: a.protocol.replace , host: a.hostname , port: a.port , query: a.search , file: (a.pathname.match || [, ''])[1] , hash: a.hash.replace , path: a.pathname.replace , relative: (a.href.match(/tps?://[^/]+[1] , segments: a.pathname.replace }; }};

正则表达式方法集

Angela.regExp = { //# 字符串匹配 //是否为 数字!整数,浮点数 isNum: function  { //# 是否为数组 return !isNaN; } , isEmail: function  {//# 是否为 邮箱 return /^([a-z0-9]+[_-.]?)*[a-z0-9]+@([a-z0-9]+[_-.]?)*[a-z0-9]+.[a-z]{2,5}$/i.test; } , isIdCard: function  { //# 是否为 身份证 return /^; } , isMobile: function  { //# 是否为 手机 return /^0*1d{10}$/.test; } , isQQ: function  { //# 是否为 QQ return /^[1-9]d{4,10}$/.test; } , isTel: function  { //# 是否为 电话 return /^d{3,4}-d{7,8}?$/.text; } , isUrl: function  { //# 是否为 URL return /https?://[a-z0-9.-]{1,255}.[0-9a-z-]{1,255}/i.test; } , isColor: function  { //# 是否为 16进制颜色 return /#{1,2}$/i.test; } //@id : 身份证 , // @now : 当前时间 如:new Date , '2013/12/12' // @age : 允许的年龄 , isAdult: function  { //# 是否年龄是否成年 var age = 0 // 用户 年月日 , nowDate = 0 //当前年月日 ; allowAge = parseFloat || 18; now = typeof now == 'string' ? new Date : ; if  { return false; } //15位身份证 if  { age = '19' + id.slice; } else { age = id.slice; } // 类型转换 整型 age = ~~age; nowDate = ~~(Tydic.date.format; //比较年龄 if (nowDate - age < allowAge * 1e4) { return false; } return true; } //浮点数 , isFloat: function  { //# 是否为 浮点数 return /^|0)$/.test; } //正整数 , isInt: function  { //# 是否为 正整数 return /^[1-9]d*$/.test; } //是否全为汉字 , isChinese: function  { //# 是否全为 汉字 return /^([u4E00-u9FA5]|[uFE30-uFFA0])+$/gi.test; }};

字符串方法集

Angela.string = { //# 字符串 codeHtml: function  { //# 转义 HTML 字符 return this.replace(content, { '&': "&" , '"': """ , "'": ''' , '': ">" , ' ': "" , 't': "    " , '': ")" , '*': "*" , '+': "+" , ',': "," , '-': "-" , '.': "." , '/': "/" , '?': "?" , '\': "" , 'n': "
" }); } //重复字符串 , repeat: function  { //# 重复字符串 end = end || ''; //加在末位 length = ~~length; return new Array.join + '' + end; } //增加前缀 , addPre: function  { //# 补齐。如给数字前 加 0 pre = pre || '0'; size = parseInt || 0; word = String; var length = Math.max(0, size - word.length); return this.repeat; } //去除两边空格 , trim: function  { //# 去除两边空格 return .replace; } //字符串替换 , replace: function  { //# 字符串替换 str = str || ''; for  { replace; }; function replace { var arr = str.split; }; return str; } , xss: function  { //# XSS 转义 //空过滤 if  { return str === 0 ? "0" : ""; } switch  { case "html": //过滤html字符串中的XSS return str.replace(/[&'"<>/\-x00-x09x0b-x0cx1fx80-xff]/g, function  { return "" + r.charCodeAt.replace.replace.replace.replace; break; case "htmlEp": //过滤DOM节点属性中的XSS return str.replace(/[&'"<>/\-x00-x1fx80-xff]/g, function  { return "" + r.charCodeAt; break; case "url": //过滤url return escape.replace; break; case "miniUrl": return str.replace; break; case "script": return str.replace(/[\"']/g, function  { return "\" + r; }).replace.replace.replace.replace; break; case "reg": return str.replace(/[\^$*+?{}.\[]]/g, function  { return "\" + a; }); break; default: return escape.replace(/[&'"<>/\-x00-x09x0b-x0cx1fx80-xff]/g, function  { return "" + r.charCodeAt.replace.replace.replace.replace; break; } } // badword , 过滤敏感词 //@text : 要过滤的文本 , 类型 :字符串 //@words : 敏感词 ,类型,数组, 如 : ['你妹', '我丢' ,'我靠'] // 如果 用 正则匹配, text 长度 100万,words 100万,需要 4秒! , badWord: function  { //# 敏感词过滤 text = String; words = words || []; var reg = new RegExp , _self = this; return text.replace { var length = String.length; return _self.repeat; }};

加密方法集

Angela.encrypt = { //# 加密 md5: function  { //# md5 哈希算法 /* * Crypto-JS 3.1.2 * http://code.google.com/p/crypto-js */ var CryptoJS = function  { var m = {}, l = m.lib = {}, n = function () { }, r = l.Base = { extend: function  { n.prototype = this; var h = new n; b && h.mixIn; h.hasOwnProperty ||  { h.$super.init.apply; h.init.prototype = h; h.$super = this; return h }, create: function () { var b = this.extend(); b.init.apply; return b }, init: function () { }, mixIn: function  b.hasOwnProperty && ; b.hasOwnProperty && (this.toString = b.toString) }, clone: function () { return this.init.prototype.extend } }, q = l.WordArray = r.extend({ init: function  { b = this.words = b || []; this.sigBytes = h != p ? h : 4 * b.length }, toString: function .stringify }, concat: function  { var h = this.words, a = b.words, j = this.sigBytes; b = b.sigBytes; this.clamp for (var g = 0; g < b; g++) h[j + g >>> 2] |= (a[g >>> 2] >>> 24 - 8 *  << 24 - 8 * ; else if  for  h[j + g >>> 2] = a[g >>> 2]; else h.push.apply; this.sigBytes += b; return this }, clamp: function () { var b = this.words, h = this.sigBytes; b[h >>> 2] &= 4294967295 << 32 - 8 * ; b.length = s.ceil }, clone: function () { var b = r.clone.call; b.words = this.words.slice; return b }, random: function  { for (var h = [], a = 0; a < b; a += 4) h.push(4294967296 * s.random; return new q.init, v = m.enc = {}, t = v.Hex = { stringify: function  { var a = b.words; b = b.sigBytes; for (var g = [], j = 0; j < b; j++) { var k = a[j >>> 2] >>> 24 - 8 *  & 255; g.push.toString.toString } return g.join }, parse: function  { for (var a = b.length, g = [], j = 0; j < a; j += 2) g[j >>> 3] |= parseInt << 24 - 4 * ; return new q.init } }, a = v.Latin1 = { stringify: function  { var a = b.words; b = b.sigBytes; for (var g = [], j = 0; j < b; j++) g.push(String.fromCharCode(a[j >>> 2] >>> 24 - 8 * ; return g.join }, parse: function  { for (var a = b.length, g = [], j = 0; j < a; j++) g[j >>> 2] |=  & 255) << 24 - 8 * ; return new q.init } }, u = v.Utf8 = { stringify: function  { try { return decodeURIComponent)) } catch  { throw Error("Malformed UTF-8 data"); } }, parse: function  { return a.parse(unescape)) } }, g = l.BufferedBlockAlgorithm = r.extend { this._data = new q.init; this._nDataBytes = 0 }, _append: function  { "string" == typeof b && ; this._data.concat; this._nDataBytes += b.sigBytes }, _process: function  { var a = this._data, g = a.words, j = a.sigBytes, k = this.blockSize, m = j / , m = b ? s.ceil - this._minBufferSize, 0); b = m * k; j = s.min { for (var l = 0; l < b; l += k) this._doProcessBlock; l = g.splice; a.sigBytes -= j } return new q.init }, clone: function () { var b = r.clone.call; b._data = this._data.clone(); return b }, _minBufferSize: 0 }); l.Hasher = g.extend, init: function  { this.cfg = this.cfg.extend }, reset: function () { g.reset.call; this._doReset() }, update: function ; this._process(); return this }, finalize: function  { b && this._append; return this._doFinalize() }, blockSize: 16, _createHelper: function  { return function  { return .finalize } }, _createHmacHelper: function  { return function  { return ).finalize; var k = m.algo = {}; return m } { function p { a = a +  + l + m; return (a << j | a >>> 32 - j) + k } function m { a = a +  + l + m; return (a << j | a >>> 32 - j) + k } function l { a = a +  + l + m; return (a << j | a >>> 32 - j) + k } function n { a = a +  + l + m; return (a << j | a >>> 32 - j) + k } for (var r = CryptoJS, q = r.lib, v = q.WordArray, t = q.Hasher, q = r.algo, a = [], u = 0; 64 > u; u++) a[u] = 4294967296 * s.abs | 0; q = q.MD5 = t.extend({ _doReset: function () { this._hash = new v.init([1732584193, 4023233417, 2562383102, 271733878]) }, _doProcessBlock: function  { for (var b = 0; 16 > b; b++) { var h = k + b, w = g[h]; g[h] =  & 16711935 |  & 4278255360 } var b = this._hash.words, h = g[k + 0], w = g[k + 1], j = g[k + 2], q = g[k + 3], r = g[k + 4], s = g[k + 5], t = g[k + 6], u = g[k + 7], v = g[k + 8], x = g[k + 9], y = g[k + 10], z = g[k + 11], A = g[k + 12], B = g[k + 13], C = g[k + 14], D = g[k + 15], c = b[0], d = b[1], e = b[2], f = b[3], c = p(c, d, e, f, h, 7, a[0]), f = p(f, c, d, e, w, 12, a[1]), e = p(e, f, c, d, j, 17, a[2]), d = p(d, e, f, c, q, 22, a[3]), c = p(c, d, e, f, r, 7, a[4]), f = p(f, c, d, e, s, 12, a[5]), e = p(e, f, c, d, t, 17, a[6]), d = p(d, e, f, c, u, 22, a[7]), c = p(c, d, e, f, v, 7, a[8]), f = p(f, c, d, e, x, 12, a[9]), e = p(e, f, c, d, y, 17, a[10]), d = p(d, e, f, c, z, 22, a[11]), c = p(c, d, e, f, A, 7, a[12]), f = p(f, c, d, e, B, 12, a[13]), e = p(e, f, c, d, C, 17, a[14]), d = p(d, e, f, c, D, 22, a[15]), c = m(c, d, e, f, w, 5, a[16]), f = m(f, c, d, e, t, 9, a[17]), e = m(e, f, c, d, z, 14, a[18]), d = m(d, e, f, c, h, 20, a[19]), c = m(c, d, e, f, s, 5, a[20]), f = m(f, c, d, e, y, 9, a[21]), e = m(e, f, c, d, D, 14, a[22]), d = m(d, e, f, c, r, 20, a[23]), c = m(c, d, e, f, x, 5, a[24]), f = m(f, c, d, e, C, 9, a[25]), e = m(e, f, c, d, q, 14, a[26]), d = m(d, e, f, c, v, 20, a[27]), c = m(c, d, e, f, B, 5, a[28]), f = m(f, c, d, e, j, 9, a[29]), e = m(e, f, c, d, u, 14, a[30]), d = m(d, e, f, c, A, 20, a[31]), c = l(c, d, e, f, s, 4, a[32]), f = l(f, c, d, e, v, 11, a[33]), e = l(e, f, c, d, z, 16, a[34]), d = l(d, e, f, c, C, 23, a[35]), c = l(c, d, e, f, w, 4, a[36]), f = l(f, c, d, e, r, 11, a[37]), e = l(e, f, c, d, u, 16, a[38]), d = l(d, e, f, c, y, 23, a[39]), c = l(c, d, e, f, B, 4, a[40]), f = l(f, c, d, e, h, 11, a[41]), e = l(e, f, c, d, q, 16, a[42]), d = l(d, e, f, c, t, 23, a[43]), c = l(c, d, e, f, x, 4, a[44]), f = l(f, c, d, e, A, 11, a[45]), e = l(e, f, c, d, D, 16, a[46]), d = l(d, e, f, c, j, 23, a[47]), c = n(c, d, e, f, h, 6, a[48]), f = n(f, c, d, e, u, 10, a[49]), e = n(e, f, c, d, C, 15, a[50]), d = n(d, e, f, c, s, 21, a[51]), c = n(c, d, e, f, A, 6, a[52]), f = n(f, c, d, e, q, 10, a[53]), e = n(e, f, c, d, y, 15, a[54]), d = n(d, e, f, c, w, 21, a[55]), c = n(c, d, e, f, v, 6, a[56]), f = n(f, c, d, e, D, 10, a[57]), e = n(e, f, c, d, t, 15, a[58]), d = n(d, e, f, c, B, 21, a[59]), c = n(c, d, e, f, r, 6, a[60]), f = n(f, c, d, e, z, 10, a[61]), e = n(e, f, c, d, j, 15, a[62]), d = n(d, e, f, c, x, 21, a[63]); b[0] = b[0] + c | 0; b[1] = b[1] + d | 0; b[2] = b[2] + e | 0; b[3] = b[3] + f | 0 }, _doFinalize: function () { var a = this._data, k = a.words, b = 8 * this._nDataBytes, h = 8 * a.sigBytes; k[h >>> 5] |= 128 << 24 - h % 32; var l = s.floor; k[ + 15] =  & 16711935 |  & 4278255360; k[ + 14] =  & 16711935 |  & 4278255360; a.sigBytes = 4 * ; this._process(); a = this._hash; k = a.words; for  h = k[b], k[b] =  & 16711935 |  & 4278255360; return a }, clone: function () { var a = t.clone.call; a._hash = this._hash.clone; r.MD5 = t._createHelper; r.HmacMD5 = t._createHmacHelper; return CryptoJS.MD5; } // sha1 , sha1: function  { //# sha1 哈希算法 var CryptoJS = function  { var p = {}, j = p.lib = {}, l = function () { }, f = j.Base = { extend: function  { l.prototype = this; var c = new l; a && c.mixIn; c.hasOwnProperty ||  { c.$super.init.apply; c.init.prototype = c; c.$super = this; return c }, create: function () { var a = this.extend(); a.init.apply; return a }, init: function () { }, mixIn: function  a.hasOwnProperty && ; a.hasOwnProperty && (this.toString = a.toString) }, clone: function () { return this.init.prototype.extend } }, n = j.WordArray = f.extend({ init: function  { a = this.words = a || []; this.sigBytes = c != m ? c : 4 * a.length }, toString: function .stringify }, concat: function  { var c = this.words, q = a.words, d = this.sigBytes; a = a.sigBytes; this.clamp for (var b = 0; b < a; b++) c[d + b >>> 2] |= (q[b >>> 2] >>> 24 - 8 *  << 24 - 8 * ; else if  for  c[d + b >>> 2] = q[b >>> 2]; else c.push.apply; this.sigBytes += a; return this }, clamp: function () { var a = this.words, c = this.sigBytes; a[c >>> 2] &= 4294967295 << 32 - 8 * ; a.length = e.ceil }, clone: function () { var a = f.clone.call; a.words = this.words.slice; return a }, random: function  { for (var c = [], b = 0; b < a; b += 4) c.push(4294967296 * e.random; return new n.init, b = p.enc = {}, h = b.Hex = { stringify: function  { var c = a.words; a = a.sigBytes; for (var b = [], d = 0; d < a; d++) { var f = c[d >>> 2] >>> 24 - 8 *  & 255; b.push.toString.toString } return b.join }, parse: function  { for (var c = a.length, b = [], d = 0; d < c; d += 2) b[d >>> 3] |= parseInt << 24 - 4 * ; return new n.init } }, g = b.Latin1 = { stringify: function  { var c = a.words; a = a.sigBytes; for (var b = [], d = 0; d < a; d++) b.push(String.fromCharCode(c[d >>> 2] >>> 24 - 8 * ; return b.join }, parse: function  { for (var c = a.length, b = [], d = 0; d < c; d++) b[d >>> 2] |=  & 255) << 24 - 8 * ; return new n.init } }, r = b.Utf8 = { stringify: function  { try { return decodeURIComponent)) } catch  { throw Error("Malformed UTF-8 data"); } }, parse: function  { return g.parse(unescape)) } }, k = j.BufferedBlockAlgorithm = f.extend { this._data = new n.init; this._nDataBytes = 0 }, _append: function  { "string" == typeof a && ; this._data.concat; this._nDataBytes += a.sigBytes }, _process: function  { var c = this._data, b = c.words, d = c.sigBytes, f = this.blockSize, h = d / , h = a ? e.ceil - this._minBufferSize, 0); a = h * f; d = e.min { for (var g = 0; g < a; g += f) this._doProcessBlock; g = b.splice; c.sigBytes -= d } return new n.init }, clone: function () { var a = f.clone.call; a._data = this._data.clone(); return a }, _minBufferSize: 0 }); j.Hasher = k.extend, init: function  { this.cfg = this.cfg.extend }, reset: function () { k.reset.call; this._doReset() }, update: function ; this._process(); return this }, finalize: function  { a && this._append; return this._doFinalize() }, blockSize: 16, _createHelper: function  { return function  { return .finalize } }, _createHmacHelper: function  { return function  { return ).finalize; var s = p.algo = {}; return p } { var e = CryptoJS, m = e.lib, p = m.WordArray, j = m.Hasher, l = [], m = e.algo.SHA1 = j.extend({ _doReset: function () { this._hash = new p.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function  { for (var b = this._hash.words, h = b[0], g = b[1], e = b[2], k = b[3], j = b[4], a = 0; 80 > a; a++) { if  l[a] = f[n + a] | 0; else { var c = l[a - 3] ^ l[a - 8] ^ l[a - 14] ^ l[a - 16]; l[a] = c << 1 | c >>> 31 } c =  + j + l[a]; c = 20 > a ? c +  + 1518500249) : 40 > a ? c +  + 1859775393) : 60 > a ? c + ((g & e | g & k | e & k) - 1894007588) : c +  - 899497514); j = k; k = e; e = g << 30 | g >>> 2; g = h; h = c } b[0] = b[0] + h | 0; b[1] = b[1] + g | 0; b[2] = b[2] + e | 0; b[3] = b[3] + k | 0; b[4] = b[4] + j | 0 }, _doFinalize: function () { var f = this._data, e = f.words, b = 8 * this._nDataBytes, h = 8 * f.sigBytes; e[h >>> 5] |= 128 << 24 - h % 32; e[ + 14] = Math.floor; e[ + 15] = b; f.sigBytes = 4 * e.length; this._process(); return this._hash }, clone: function () { var e = j.clone.call; e._hash = this._hash.clone; e.SHA1 = j._createHelper; e.HmacSHA1 = j._createHmacHelper; return CryptoJS.SHA1; } // time33 哈希 , time33: function  { //# time33 哈希算法 words = words || ''; //哈希time33算法 for (var i = 0, len = words.length, hash = 5381; i < len; ++i) { hash +=  + words.charAt; }; return hash & 0x7fffffff; }}

日期方法集

Angela.date = { //# 日期时间 //@s : 开始时间 //@e : 结束时间 //@n : 当前时间 , n 的格式为 毫秒数 isInArea: function  { //# 判断时间区域 var start = this.parse, end = this.parse, now = parseFloat ; start = Math.min; end = Math.max; return now >= start && now <= end ? true : false; } //把 字符窜转化为 毫秒 //@date : 2013-03-02 1:2:2 , parse: function  { //# 格式化时间 return Date.parse; //.replace } //@time , 时间 , 如 new Date //@pre , 星期的 前缀,如:周 ,星期 //@ nums ,如:一二三四五六日 , getWeek: function  { //# 获取星期几 time = typeof time == 'string' ? this.parse : ; pre = pre || '星期'; //周 nums = '日一二三四五六'; return pre + nums[time.getDay()]; } //@formatType : YYYY, YY, MM //@ time : new Date //@weeks : 日一二三四五六 , format: function (formatType, time, weeks) { //格式化输出时间 var pre = '0' ; formatType = formatType || 'YYYY-MM-DD' weeks = weeks || '日一二三四五六'; time = time || new Date(); //格式化时间 return  .replace(/yyyy|YYYY/g, time.getFullYear .replace(/yy|YY/g, Tydic.string.addPre(pre, time.getFullYear .replace(/mm|MM/g, Tydic.string.addPre + 1, 2)) .replace(/m|M/g, time.getMonth .replace(/dd|DD/g, Tydic.string.addPre, 2)) .replace(/d|D/g, time.getDate .replace(/hh|HH/g, Tydic.string.addPre, 2)) .replace(/h|H/g, time.getHours .replace(/ii|II/g, Tydic.string.addPre(pre, time.getMinutes .replace(/i|I/g, time.getMinutes .replace(/ss|SS/g, Tydic.string.addPre(pre, time.getSeconds .replace(/s|S/g, time.getSeconds .replace .replace(/W/g, weeks[time.getDay ; } //倒计时 , countDown: function  { //# 倒计时 var option = { nowTime: 0 // 当前时间, ,2013/02/01 18:30:30 , endTime: 0 //截止时间 ,2013/02/01 18:30:30 , interval: 1 //间隔回调时间,秒 , called: function (day, hour, second, minute) { }//每次回调 , finaled: function () { } //完成后回调 } , opts = {} , timer = null ; opts = Tydic.extend; //当前时间 if  { opts.nowTime = ; } else { opts.nowTime = this.parse; } //当前时间 if  { opts.endTime = ; } else { opts.endTime = this.parse; } timer = setInterval(loop, opts.interval * 1e3); // 循环 function loop() { var ts = opts.endTime - opts.nowTime //计算剩余的毫秒数 , dd = parseInt //计算剩余的天数 , hh = parseInt//计算剩余的小时数 , mm = parseInt//计算剩余的分钟数 , ss = parseInt//计算剩余的秒数 ; //当前时间递减 opts.nowTime += opts.interval * 1e3; if  { clearInterval; opts.finaled(); } else { opts.called; } } }};

浏览器检测方法集

Angela.browser = { //#浏览器 browsers: { //# 浏览器内核类别 weixin: /micromessenger*/ //微信内置浏览器 , mqq: /mqqbrowser*/ //手机QQ浏览器 , uc: /ucbrowser*/ //UC浏览器 , chrome: /*/ //chrome浏览器 , firefox: /firefox*/ //火狐浏览器 , opera: /opera*/ //欧朋浏览器 , sougou: /sogoumobilebrowser*/ //搜狗手机浏览器 , baidu: /baidubrowser*/ //百度手机浏览器 , 360: /360browser/ //360浏览器 , safari: /safari*/ //苹果浏览器 , ie: /msies*/ // ie 浏览器 } //@errCall : 错误回调 , addFav: function  { //#加入收藏夹 try { window.external.addFavorite; } catch  { try { window.sidebar.addPanel; } catch ; } } }, //浏览器版本 coreInit: function () { //#noadd var i = null , browsers = this.browsers , ua = window.navigator.userAgent.toLowerCase() , brower = '' , pos = 1 ; for  { if (brower = ua.match { if  { pos = 2; } else { pos = 1; } this.version = .replace; this.core = i; return i; } } } // 检测IE版本 !仅支持IE: 5,6,7,8,9 版本 , ie:  { //# 检测IE版本 !仅支: ie5,6,7,8,9 var v = 3, div = document.createElement, all = div.getElementsByTagName; while ( div.innerHTML = '', all[0] ); return v > 4 ? v : false; })() , isWebkit: /webkit/i.test };

json方法

Angela.json = { //# json 对象 // 字符串 变为 json 对象 parse: function  { //# 格式化字符串,变为 json 对象 var // JSON RegExp rvalidchars = /^[],:{}s]*$/ , rvalidbraces = /+/g , rvalidescape = /\(?:["\/bfnrt]|u[da-fA-F]{4})/g , rvalidtokens = /"[^"\rn]*"|true|false|null|-?d+(?:[eE][+-]?d+|)/g ; if (window.JSON && window.JSON.parse) { return window.JSON.parse; } if  { return data; } if (typeof data === "string") { data = data.replace; if (data && rvalidchars.test(data.replace .replace .replace { return (new Function; } } return ''; }};

extend方法

Angela.extend = function () { //# 对象扩展 var target = arguments[0] || {} , i = 1 , length = arguments.length , options ; if (typeof target != "object" && typeof target != "function") target = {}; for  { if ((options = arguments[i]) != null) { for  { var copy = options[name]; if  { continue; } if  { target[name] = copy; } } } } return target;};

类型判断的方法

/**判断变量val是不是整数类型*/function isNumber { return typeof val === 'number' && isFinite;}/**判断变量val是不是布尔类型*/function isBoolean { return typeof val === 'boolean';}/**判断变量val是不是字符串类型*/function isString  { return typeof val === 'string';}/**判断变量val是不是undefined*/function isUndefined { return typeof val === 'undefined';}/**判断变量val是不是对象*/function isObj { if (str===null||typeof str==='undefined') { return false; } return typeof str === 'object';}/**判断变量val是不是null*/function isNull { return val === null;}/**判断变量arr是不是数组*方法一*/function isArray1 { return Object.prototype.toString.apply === '[object Array]';}/**判断变量arr是不是数组*方法二*/function isArray2 { if (arr === null || typeof arr === 'undefined') { return false; } return arr.constructor === Array;}

本文由彩票投注软件发布,转载请注明来源

关键词: