
ajaxFileUpload=function(objUpload){var nowTime=(new Date()).valueOf();var keyStr=objUpload.option.appId+objUpload.option.uid+nowTime;var keys=md5(keyStr);var formData=new FormData();formData.append('file',objUpload.option.file);$.ajax({type:"post",url:'/pic/yf/upload',contentType:false,processData:false,data:formData,dataType:'json',success:function(data){objUpload.option.fileUpload(data);},error:function(XMLHttpRequest,textStatus,errorThrown,data){objUpload.option.error(data);}});}
ajaxIMFileUpload=function(objUpload){var nowTime=(new Date()).valueOf();var keyStr=IMConf.APPID+objUpload.option.uid+nowTime;var keys=md5(keyStr);var formData=new FormData();formData.append('file',objUpload.option.file);formData.append('appId',IMConf.APPID);if(objUpload.option.uid==null||objUpload.option.uid==undefined||objUpload.option.uid<0){objUpload.option.uid=this.getRandomNum(1000,10000);}
formData.append('uid',objUpload.option.uid);formData.append('currentTime',nowTime);formData.append('key',keys);formData.append('traceId',new Date().getTime()+"!"+Math.random(10000));$.ajax({type:"post",url:IMConstants.IM_FILESERVERLIST+"/im-upload/ImageUploadServlet.do",contentType:false,processData:false,data:formData,dataType:'json',success:function(data){console.log("==imageUr"+JSON.stringify(data));objUpload.option.fileUpload(data)},error:function(XMLHttpRequest,textStatus,errorThrown,data){objUpload.option.error(data);}});}
sendListOffileMsgs=function(obj){var msgSeqId=obj.option.msgSeqId;if(msgSeqId==0){}else{$.ajax({type:"POST",url:IMConf.IM_API_URL+"customerMsg/jsPullCustomerMsg.json?appId="+IMConf.APPID+"&scn="+obj.option.token+"&imUserId="+obj.option.imUserId+"&groupId="+obj.option.groupId+"&time="+obj.option.time+"&channelId="+obj.option.channelId+"&seqId="+obj.option.msgSeqId+"&pageSize="+obj.option.pageSize+"&osType="+IMConf.OSTYPE+"&version="+IMConf.VERSION,dataType:'json',success:function(data){obj.callback.success(data);},error:function(XMLHttpRequest,textStatus,errorThrown,data){obj.callback.error(data);}});}}
sendCustomInfo=function(obj){$.ajax({type:"POST",url:IMConf.IM_API_URL+"customerMsg/jsGetCustomInfo.json?appId="+IMConf.APPID+"&scn="+obj.option.token+"&imUserId="+obj.option.imUserId+"&groupId="+obj.option.groupId+"&channelId="+obj.option.channelId+"&osType="+IMConf.OSTYPE+"&version="+IMConf.VERSION,dataType:'json',success:function(data){obj.option.customInfo(data);},error:function(XMLHttpRequest,textStatus,errorThrown,data){obj.option.error(data);}});}
sendListGroupMsgs=function(obj){$.ajax({type:"POST",url:IMConf.IM_API_URL+"customerMsg/jsListCustomerGroupPage.json?appId="+IMConf.APPID+"&scn="+obj.option.token+"&imUserId="+obj.option.uid+"&lastGroupId="+obj.option.lastGroupId+"&osType="+IMConf.OSTYPE+"&version="+IMConf.VERSION,dataType:'json',success:function(data){obj.callback.success(data);},error:function(XMLHttpRequest,textStatus,errorThrown,data){obj.callback.error(data);}});}
getServerVideoAndPicPath=function(message){var videopic="";var videoName="";if(message.attach!==undefined&&message.attach[0].attachUrl!==undefined){videopic=message.attach["0"].attachUrl;if(videopic.toLowerCase().indexOf("_vedio.mp4")!==-1){videoName=videopic.replace("_vedio.mp4","_img.jpg");message.attach["0"].attachUrl=videoName;}}
return message;}
Dictionary=function(){this.data=new Array();this.put=function(key,value){this.data[key]=value;};this.get=function(key){return this.data[key];};this.remove=function(key){this.data[key]=null;};this.isEmpty=function(){return this.data.length==0;};this.size=function(){return this.data.length;};}
Date.prototype.Format=function(fmt){var o={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),"S":this.getMilliseconds()};if(/(y+)/.test(fmt))fmt=fmt.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));for(var k in o)
if(new RegExp("("+k+")").test(fmt))fmt=fmt.replace(RegExp.$1,(RegExp.$1.length==1)?(o[k]):(("00"+o[k]).substr((""+o[k]).length)));return fmt;}
dateDiff=function(date1,date2){var type1=typeof date1,type2=typeof date2;if(type1=='string')
date1=stringToTime(date1);else if(date1.getTime)
date1=date1.getTime();if(type2=='string')
date2=stringToTime(date2);else if(date2.getTime)
date2=date2.getTime();return(date1-date2)/1000;}
get_time_format=function(timestamp){if(timestamp){var date=new Date(timestamp);}else{var date=new Date();}
Y=date.getFullYear(),m=date.getMonth()+1,d=date.getDate(),H=date.getHours(),i=date.getMinutes(),s=date.getSeconds();if(m<10){m='0'+m;}
if(d<10){d='0'+d;}
if(H<10){H='0'+H;}
if(i<10){i='0'+i;}
if(s<10){s='0'+s;}
var t=Y+'-'+m+'-'+d+' '+H+':'+i+':'+s;return t;}
unique=function(arr){var result=[],isRepeated;for(var i=0,len=arr.length;i<len;i++){isRepeated=false;for(var j=0,len=result.length;j<len;j++){if(arr[i]==result[j]){isRepeated=true;break;}}
if(!isRepeated){result.push(arr[i]);}}
return result;}
imChatList=function(params){$.ajax({type:'post',url:IMConf.IM_API_URL+'msg/jsListGroup.json',data:{appId:IMConf.APPID,imUserId:params.option.uid,time:params.option.time,token:params.option.token,deviceType:IMConf.DEVICE_TYPE,osType:IMConf.OSTYPE,version:IMConf.VERSION},dataType:'json',success:function(data){params.callback.success(data)},error:function(e){params.callback.error(e)}})}
imOffLineMsg=function(params){$.ajax({type:'post',url:IMConf.IM_API_URL+'msg/jsPullMsg.json',data:{appId:IMConf.APPID,imUserId:params.option.imUserId,groupId:params.option.groupId,time:params.option.time,token:params.option.token,deviceType:IMConf.DEVICE_TYPE,osType:IMConf.OSTYPE,version:IMConf.VERSION,pageSize:params.option.pageSize,msgSeqId:params.option.msgSeqId},dataType:'json',success:function(data){params.callback.success(data)},error:function(e){params.callback.error(e)}})}