var hrjia = {
check: {
isPhone: function() {
var ua = navigator.userAgent.toLowerCase(),
reg = /iPhone|iPad|Android|ucweb|windows\s+mobile|Windows\s+Phone/i;
return reg.test(ua)
},
isIE6: window.VBArray && !window.XMLHttpRequest,
isNick: function(str) {
var nickReg = /^[\u4e00-\u9fa5A-Za-z0-9-_]+$/;
return nickReg.test(str)
},
isEmail: function(str) {
var emailReg = /^[a-z0-9][\w\.]*@([a-z0-9][a-z0-9-]*\.)+[a-z]{2,5}$/i;
return emailReg.test(str)
},
isMobile: function(str) {
var mobileReg = /^1[345678][0-9]{9}$/;
return mobileReg.test(str)
},
isTelephone: function(str) {
var phoneReg = /^0\d{2,3}-\d{5,9}$/;
return phoneReg.test(str)
},
isUrl: function(str) {
var urlReg = /^http:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?$/;
return urlReg.test(str)
},
isNum: function(str) {
var numReg = /^[0-9]\d*$/;
return numReg.test(str)
},
isFloatNum: function(str) {
var floatReg = /^(-?\d+)(\.\d+)?$/;
return floatReg.test(str)
},
isDate: function(str) {
var dateReg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
return dateReg.test(str)
},
isAnimate: function(style) {
var prefix = ["webkit", "Moz", "ms", "o"],
i, humpString = [],
htmlStyle = document.documentElement.style,
_toHumb = function(string) {
return string.replace(/-(\w)/g, function($0, $1) {
return $1.toUpperCase()
})
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + "-" + style))
}
humpString.push(_toHumb(style));
for (i in humpString) {
if (humpString[i] in htmlStyle) {
return true
}
}
return false
}
} ,
tools: {
getUrlParams: function(name) {
var url = location.href,
value = null,
index = url.indexOf("?");
if (index < 0) {
if( name ){
return undefined ;
}else{
return {} ;
}
} else {
var paramstr = url.substring(index + 1),
obj = {},
arrParams = paramstr.split("&");
for (var i = 0; i < arrParams.length; i++) {
var tmp = arrParams[i].split("=");
obj[tmp[0]] = tmp[1] ? decodeURIComponent( tmp[1] ) : undefined ;
}
if (name) {
return obj[name]
} else {
return obj
}
}
} ,
getUrlTree: function(index) {
var urlNode = location.href.replace(/http:\/\//i, "").replace(/\?.*/i, "").split("/"),
length = urlNode.length;
if (index == undefined) {
return urlNode
} else {
return index < 0 ? urlNode[length + index] : urlNode[index]
}
}
} ,
pad:function(num, n) {
var len = num.toString().length;
while(len < n) {
num = "0" + num;
len++;
}
return num;
} ,
padNumber: function(num, fill) {
var len = ('' + num).length;
return (Array(
fill > len ? fill - len + 1 || 0 : 0
).join(0) + num);
} ,
UUID: function (){
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x7|0x8)).toString(16);
});
return uuid;
} ,
isDateObj: function (o) {
return {}.toString.call(o) === "[object Date]" && o.toString() !== 'Invalid Date' && !isNaN(o);
} ,
checkDate: function( date ){
var dateReg = /^(?:(?!0000)[0-9]{4}([-/.]?)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))$/;
var dateTimeReg = /^(?:(?!0000)[0-9]{4}([-/.]?)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))\s+([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/;
if( date.indexOf(':') < 0 ){
return dateReg.test( date ) ;
}else{
return dateTimeReg.test( date ) ;
}
}
};