05-util.js 8.92 KB
!function(t,r){var n=t.parseInt;t.parseInt=function(t,r){return r=r||"10",n(t,r)};var e={};e={},e.datetime={},e.url={},e.map={},e.validate={},e.encrypt={},e.isNaN=function(t){return isNaN(t)},e.isUndef=function(t){return"undefined"==typeof t},e.isNull=function(t){return null==t},e.isFunc=function(t){return"function"==typeof t},e.nothing=function(t){return e.isUndef(t)||e.isNull(t)},e.trim=function(t){return e.isStr(t)?r.trim(t):""},e.isStr=function(t){return"string"==typeof t},e.strLen=function(t){return"string"==typeof t?t.length:0},e.isEmptyStr=function(t){return!!e.isUndef(t)||(!!e.isNull(t)||!(!e.isStr(t)||""!=e.trim(t)))},e.toJsonStr=function(r,n,e){return t.JSON.stringify(r,n,e)},e.toJsonObj=function(r,n){return t.JSON.parse(r,n)},e.isArr=function(t){return"[object Array]"==Object.prototype.toString.call(t)},e.arrLen=function(t){return e.isArr(t)?t.length:0},e.isEmptyArr=function(t){return!e.isArr(t)||0==e.arrLen(t)},e.isEmptyObj=function(t){var r;for(r in t)return!1;return!0},e.eachArr=function(t,r){if(e.isArr(t))for(var n=e.arrLen(t),i=0;i<n&&r(t[i],i,t)!==!1;i++);},e.arrFind=function(t,r){var n,i=[];if(e.isArr(t))for(var o=e.arrLen(t),u=0;u<o;u++)n=r(t[u],u,t),e.nothing(n)||i.push(n);return i},e.toArr=function(t){return Array.prototype.slice.call(t,0)},e.split=function(t,r){return e.isStr(t)||(t=""),r=r||" ",t.split(r)},e.join=function(t,r){return r=r||" ",e.isArr(t)?t.join(r):""},e.splitJoin=function(t,r,n){return e.join(e.split(t,r),n)},e.extend=function(t,n){return n=n||t,t=r.extend({},t),r.extend(t,n)},e.sortStrArr=function(t){return Array.prototype.sort.apply(t)},e.sortNumArr=function(t){return t.sort(function(t,r){return parseInt(t)>parseInt(r)})},e.inArr=function(t,r){return!e.isEmptyArr(e.arrFind(t,function(t,n,e){return t==r?r:null}))},e.diffDays=function(t){var t=new Date(t.replace(/-/g,"/")),r=new Date,n=t.getTime()-r.getTime();return parseInt(n/864e5)},e.datetime.isGreater=function(t,r){return new Date(t).getTime()>=new Date(r.toUTCString().replace(new RegExp("-","g"),"/")).getTime()},e.getTop=function(t){var r=t.offsetTop;return null!=t.offsetParent&&(r+=e.getTop(t.offsetParent)),r},e.getLeft=function(t){var r=t.offsetLeft;return null!=t.offsetParent&&(r+=e.getLeft(t.offsetParent)),r},e.url.getCDNUuid=function(t){var r=t.lastIndexOf("/");return r>=0?t.substr(t.lastIndexOf("/")+1):t},e.url.getCDNFile=function(t){var r=t.substring(t.indexOf("http://"),t.indexOf("?"));if(r.lastIndexOf("/")>=0)r=r.substr(r.lastIndexOf("/")+1);else{if(!(t.lastIndexOf("/")>=0))return t;r=t.substr(t.lastIndexOf("/")+1)}return r},e.url.getRemoteUrl=function(t){return t?t.substring(0,t.indexOf("?")):""},e.url.getCDNFileExtension=function(t){return t.substr(t.lastIndexOf(".")+1)},e.validate.isUrl=function(t){return/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[\/?#]\S*)?$/i.test(t)},function(t){function r(t,r){var n=t[0],f=t[1],s=t[2],a=t[3];n=e(n,f,s,a,r[0],7,-680876936),a=e(a,n,f,s,r[1],12,-389564586),s=e(s,a,n,f,r[2],17,606105819),f=e(f,s,a,n,r[3],22,-1044525330),n=e(n,f,s,a,r[4],7,-176418897),a=e(a,n,f,s,r[5],12,1200080426),s=e(s,a,n,f,r[6],17,-1473231341),f=e(f,s,a,n,r[7],22,-45705983),n=e(n,f,s,a,r[8],7,1770035416),a=e(a,n,f,s,r[9],12,-1958414417),s=e(s,a,n,f,r[10],17,-42063),f=e(f,s,a,n,r[11],22,-1990404162),n=e(n,f,s,a,r[12],7,1804603682),a=e(a,n,f,s,r[13],12,-40341101),s=e(s,a,n,f,r[14],17,-1502002290),f=e(f,s,a,n,r[15],22,1236535329),n=i(n,f,s,a,r[1],5,-165796510),a=i(a,n,f,s,r[6],9,-1069501632),s=i(s,a,n,f,r[11],14,643717713),f=i(f,s,a,n,r[0],20,-373897302),n=i(n,f,s,a,r[5],5,-701558691),a=i(a,n,f,s,r[10],9,38016083),s=i(s,a,n,f,r[15],14,-660478335),f=i(f,s,a,n,r[4],20,-405537848),n=i(n,f,s,a,r[9],5,568446438),a=i(a,n,f,s,r[14],9,-1019803690),s=i(s,a,n,f,r[3],14,-187363961),f=i(f,s,a,n,r[8],20,1163531501),n=i(n,f,s,a,r[13],5,-1444681467),a=i(a,n,f,s,r[2],9,-51403784),s=i(s,a,n,f,r[7],14,1735328473),f=i(f,s,a,n,r[12],20,-1926607734),n=o(n,f,s,a,r[5],4,-378558),a=o(a,n,f,s,r[8],11,-2022574463),s=o(s,a,n,f,r[11],16,1839030562),f=o(f,s,a,n,r[14],23,-35309556),n=o(n,f,s,a,r[1],4,-1530992060),a=o(a,n,f,s,r[4],11,1272893353),s=o(s,a,n,f,r[7],16,-155497632),f=o(f,s,a,n,r[10],23,-1094730640),n=o(n,f,s,a,r[13],4,681279174),a=o(a,n,f,s,r[0],11,-358537222),s=o(s,a,n,f,r[3],16,-722521979),f=o(f,s,a,n,r[6],23,76029189),n=o(n,f,s,a,r[9],4,-640364487),a=o(a,n,f,s,r[12],11,-421815835),s=o(s,a,n,f,r[15],16,530742520),f=o(f,s,a,n,r[2],23,-995338651),n=u(n,f,s,a,r[0],6,-198630844),a=u(a,n,f,s,r[7],10,1126891415),s=u(s,a,n,f,r[14],15,-1416354905),f=u(f,s,a,n,r[5],21,-57434055),n=u(n,f,s,a,r[12],6,1700485571),a=u(a,n,f,s,r[3],10,-1894986606),s=u(s,a,n,f,r[10],15,-1051523),f=u(f,s,a,n,r[1],21,-2054922799),n=u(n,f,s,a,r[8],6,1873313359),a=u(a,n,f,s,r[15],10,-30611744),s=u(s,a,n,f,r[6],15,-1560198380),f=u(f,s,a,n,r[13],21,1309151649),n=u(n,f,s,a,r[4],6,-145523070),a=u(a,n,f,s,r[11],10,-1120210379),s=u(s,a,n,f,r[2],15,718787259),f=u(f,s,a,n,r[9],21,-343485551),t[0]=g(n,t[0]),t[1]=g(f,t[1]),t[2]=g(s,t[2]),t[3]=g(a,t[3])}function n(t,r,n,e,i,o){return r=g(g(r,t),g(e,o)),g(r<<i|r>>>32-i,n)}function e(t,r,e,i,o,u,f){return n(r&e|~r&i,t,r,o,u,f)}function i(t,r,e,i,o,u,f){return n(r&i|e&~i,t,r,o,u,f)}function o(t,r,e,i,o,u,f){return n(r^e^i,t,r,o,u,f)}function u(t,r,e,i,o,u,f){return n(e^(r|~i),t,r,o,u,f)}function f(t){txt="";var n,e=t.length,i=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=t.length;n+=64)r(i,s(t.substring(n-64,n)));t=t.substring(n-64);var o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(n=0;n<t.length;n++)o[n>>2]|=t.charCodeAt(n)<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(r(i,o),n=0;n<16;n++)o[n]=0;return o[14]=8*e,r(i,o),i}function s(t){var r,n=[];for(r=0;r<64;r+=4)n[r>>2]=t.charCodeAt(r)+(t.charCodeAt(r+1)<<8)+(t.charCodeAt(r+2)<<16)+(t.charCodeAt(r+3)<<24);return n}function a(t){for(var r="",n=0;n<4;n++)r+=h[t>>8*n+4&15]+h[t>>8*n&15];return r}function c(t){for(var r=0;r<t.length;r++)t[r]=a(t[r]);return t.join("")}function l(t){return c(f(t))}function d(t){var r,n,e,i,o,u;for(e=t.length,n=0,r="";n<e;){if(i=255&t.charCodeAt(n++),n==e){r+=A.charAt(i>>2),r+=A.charAt((3&i)<<4),r+="==";break}if(o=t.charCodeAt(n++),n==e){r+=A.charAt(i>>2),r+=A.charAt((3&i)<<4|(240&o)>>4),r+=A.charAt((15&o)<<2),r+="=";break}u=t.charCodeAt(n++),r+=A.charAt(i>>2),r+=A.charAt((3&i)<<4|(240&o)>>4),r+=A.charAt((15&o)<<2|(192&u)>>6),r+=A.charAt(63&u)}return r}function p(t){var r,n,e,i,o,u,f;for(u=t.length,o=0,f="";o<u;){do r=v[255&t.charCodeAt(o++)];while(o<u&&r==-1);if(r==-1)break;do n=v[255&t.charCodeAt(o++)];while(o<u&&n==-1);if(n==-1)break;f+=String.fromCharCode(r<<2|(48&n)>>4);do{if(e=255&t.charCodeAt(o++),61==e)return f;e=v[e]}while(o<u&&e==-1);if(e==-1)break;f+=String.fromCharCode((15&n)<<4|(60&e)>>2);do{if(i=255&t.charCodeAt(o++),61==i)return f;i=v[i]}while(o<u&&i==-1);if(i==-1)break;f+=String.fromCharCode((3&e)<<6|i)}return f}var h="0123456789abcdef".split(""),g=function(t,r){return t+r&4294967295};"5d41402abc4b2a76b9719d911017c592"!=l("hello")&&(g=function(t,r){var n=(65535&t)+(65535&r),e=(t>>16)+(r>>16)+(n>>16);return e<<16|65535&n});var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",v=new Array((-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),(-1),62,(-1),(-1),(-1),63,52,53,54,55,56,57,58,59,60,61,(-1),(-1),(-1),(-1),(-1),(-1),(-1),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,(-1),(-1),(-1),(-1),(-1),(-1),26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,(-1),(-1),(-1),(-1),(-1));t.base64={},t.base64.encode=d,t.base64.decode=p,t.md5=l}(e.encrypt),e.map.iterator=function(t,n,e,i){var o=[],u=function(t){return t&&t[i]instanceof Array&&t[i].length>0};r.each(t,function(t,r){r.level=0,f(r)});var f=function(t){if(!t){if(!o.length)return;f(o.pop())}return t[n]===e?(o=[],t):(u(t)&&f(o.pop()),u(t)||r.each(t[i].reverse(),function(r,n){n.level=++t.level,o.push(n)}),void f(o.pop()))}},e.autoSetPop=function(t,n){if(n)t.css("position",n.position),t.css("top",n.top);else{var e=t.height()+50;if(e<r(window).height())t.css("position","fixed"),t.css("top",(r(window).height()-e)/2);else if(t.css("position","absolute"),r(document).scrollTop()>0){var i=r(document).scrollTop()+20;t.css("top",i>0?i-r(window).height()/3:"10%")}else t.css("top","10%")}},e.autoSetPopCenter=function(t,n){if(n)t.css("position",n.position),t.css("top",n.top);else{t.css("top",0);var e=t.height();e<r(window).height()?(t.css("position","fixed"),t.css("top",(r(window).height()-e)/2)):(t.css("position","absolute"),t.css("top",r(document).scrollTop()-t.offset().top+50))}},t.utils=t.utils||e}(window,jQuery);