⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webimpopup.js

📁 这是我用QT和TTS写的一个电话本管理系统
💻 JS
📖 第 1 页 / 共 2 页
字号:
	            var maxLeft=(body.scrollLeft+body.clientWidth-this.dragDiv.offsetWidth-1);

	            if(ddLeft>maxLeft){this.dragDiv.style.left=maxLeft+'px';}
	            else if(ddLeft<1){this.dragDiv.style.left='1px';}
	            else {this.dragDiv.style.left=ddLeft+'px';}
	            
	            if(ddTop>maxTop){this.dragDiv.style.top=maxTop+'px';}
	            else if(ddTop<1){this.dragDiv.style.top='1px';}
	            else {this.dragDiv.style.top=ddTop+'px';}
	            
	            return false;
			}
		};
		
		document.onmouseup=function(e)
		{
            if (e == null) { e = window.event;} 
			document.onmousemove=null;
			document.onmouseup=null;
			this.dragOK=false;
            realDiv.style.left=this.dragDiv.style.left;
            realDiv.style.top=this.dragDiv.style.top;
			dd.style.display='none';
		};
		
		return false;
    }
    //////
}
webImForm.setDivTop=function(div)
{
    webImForm.zIndex[0]=div.style.zIndex;
    var zi=parseInt(webImForm.zIndex[5]);
    if(zi<65000)
    {
        zi++;webImForm.zIndex[5]=zi.toString();
    }
    else
    {
        webImForm.zIndex[0]="30000";zi=30000;
    }
    div.style.zIndex=zi;
}
webImForm.zIndex=new Array(10000,60001,60002,60003,60004,61000);
webImForm.hasChatWindow=false;
webImForm.rootUrl=csdn_im_defaultDomain+'/Web_References/Provide_Services/CSDN/Popup/';



/********************************************************/
//webimPopup类,共有属性,方法
var webimPopup=function(){}

webimPopup.divPrefix='im_popupWindow_';
webimPopup.scriptId="webIM_popup_js";
webimPopup.rootUrl=csdn_im_defaultDomain+'/Web_References/Provide_Services/CSDN/Popup/';
webimPopup.requestUrl=webimPopup.rootUrl+'PopupMessages.aspx';
webimPopup.sysMsgDivId=webimPopup.divPrefix + 'sysMsg';
webimPopup.senderDivId=webimPopup.divPrefix + 'sender';
webimPopup.csdnMsgDivId=webimPopup.divPrefix + 'csdnMsg';
webimPopup.chatDivId=webimPopup.divPrefix + 'chat';
webimPopup.hiMsgDivId=webimPopup.divPrefix+'hiMsg';
webimPopup.hiMsgScriptUrl='http://notify.hi.csdn.net/NotifySummary.ashx?UserName=';
webimPopup.senderItemCount=-1;
webimPopup.miniMsgDivId=webimPopup.divPrefix+'miniMsg';

webimPopup.dispose=function(eleID)
{
	var eleObj=document.getElementById(eleID);
	if(eleObj&&eleObj.parentNode)
	{
		eleObj.parentNode.removeChild(eleObj);
	}
}
webimPopup.render=function(jsonMsg)///该方法被加载的script自动调用
{
    if(jsonMsg)
	{
		webimPopup.renderWindow(jsonMsg);
	    //加载hi的新鲜事
	    //if(!webim$username){return;}
	    //this.loadScript(this.hiMsgScriptUrl+webim$username, this.renderHiMsg);
		webImForm.resizeHandler();
	    document.onmousedown=webImForm.dragHandler;
	    window["onresize"]=webImForm.resizeHandler;
	    window["onscroll"]=webImForm.resizeHandler;
    		
		var pv=document.createElement('img');
		pv.src='http://counter.csdn.net/pv.aspx?id=227';
		pv.alt='';
		pv.style.display='none';
		document.body.appendChild(pv);
	}
}
//fanwx 临时测试的方法---------------------------------------------
webimPopup.renderTest=function(jm)
{
    if(jm&&jm.miniMsg)
    {
        var f=new webImForm();
        f.title='推荐';
        f.addPadding=false;
        f.content=jm.miniMsg;
        f.divId=this.miniMsgDivId;
        f.position=true;
        f.zIndex=webImForm.zIndex[4];
        f.ifAutoHide=false;//不自动隐藏
        f.show();
        webImForm.resizeHandler();
    }
}
webimPopup.renderWindow=function(json)
{
    var f;
    if(json.sysMsg&&json.sysMsg.Content&&json.sysMsg.Content.length>0)//全站消息
    {
        f=new webImForm();
        f.title='系统消息';
        f.content=json.sysMsg.Content;
        f.divId=this.sysMsgDivId;
        f.position=false;
        f.zIndex=webImForm.zIndex[3];
        f.show();
    }
    if(json.csdnMsg)//csdn帐号的消息
    {
        f=new webImForm();
        f.title='csdn的未读消息';
        f.content=webimPopup.getCsdnMsg(json.csdnMsg);
        f.divId=this.csdnMsgDivId;
        f.position=true;
        f.zIndex=webImForm.zIndex[2];
        f.show();
    }
    if(json.sender)//用户消息
    {
        f=new webImForm();
        f.title='未读消息';
        f.content=webimPopup.getSender(json.sender);
        f.divId=this.senderDivId;
        f.position=true;
        f.zIndex=webImForm.zIndex[1];
        f.show();
    }
    if(webimPopup.miniMsg)
    {
        //alert(webimPopup.miniMsg);
        f=new webImForm();
        f.title='推荐';
        f.addPadding=false;
        f.content=webimPopup.miniMsg;
        f.divId=this.miniMsgDivId;
        f.position=true;
        f.zIndex=webImForm.zIndex[4];
        f.show();
    }
}
webimPopup.renderHiMsg=function()
{
    if('undefined'==typeof notifySummary){return;}
    if(notifySummary)
    {
        f=new webImForm();
        f.title='我的新鲜事';
        f.content=notifySummary.replace(/&amp;/g,'&').replace(/&quot;/g,'\"').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
        f.divId=webimPopup.hiMsgDivId;
        f.width='270px';
        f.position=true;
        f.zIndex=webImForm.zIndex[1];
        f.maxHeight='126';
        f.show();
        webImForm.setToRightCorner(document.getElementById(webimPopup.hiMsgDivId));
    }
}
//入口函数->
webimPopup.request=function()
{
    if(!this.checkShowSettings()) return;
    if(!this.checkUrl()) return;
    var tt=new Date();
    var rndQs=tt.getMilliseconds()+'_'+tt.getSeconds();
	this.loadScript(this.requestUrl+'?'+rndQs,null);
	//fanwx 2008-05-20 显示mini消息
	//this.loadScript("http://webim.csdn.net/Web_References/Provide_Services/CSDN/Popup/MiniMsg.aspx",null);
	this.loadScript("http://webim.csdn.net/Web_References/Provide_Services/CSDN/Popup/MiniMsg.ashx"+'?'+rndQs,null);
}
webimPopup.loadScript=function(scriptUrl,callback)
{
    var scp=document.createElement("script");
	scp.type="text/javascript";
	scp.id=this.scriptId+new Date().getMilliseconds();
	scp.src=scriptUrl;
	document.getElementsByTagName("head")[0].appendChild(scp);
	
	if(scp.readyState)
	{
		scp.onreadystatechange=function()
		{
			if(scp.readyState=="loaded")
			{
			    if(callback && 'function'==typeof callback)callback();
				webimPopup.dispose(scp.id);
			}
		}
	}	
	else
	{
		scp.onload=function()
		{
			if(callback && 'function'==typeof callback)callback();
            webimPopup.dispose(scp.id);
		}
	}
}
webimPopup.getCsdnMsg=function(arr)
{
    if(arr && arr.length && arr.length>0)
    {
        var l=[];
        l.push('<div style="width:260px;padding:10px;overflow:hidden;">');
        for(var i=0;i<arr.length;i++)
	    {
		    l.push('.&nbsp;'+ arr[i] +'<br/>');
	    }
	    l.push('</div>');
	    return l.join('');
    }
}
webimPopup.getSender=function(arr)
{
    if(arr && arr.length && arr.length>0)
    {
        var l=[];
        l.push('<div style="width:260px;padding:10px;">');
        for(var i=0;i<arr.length;i++)
	    {
	        l.push('<div id="sdr_'+i+'" style="padding:1px;"><a href="http://hi.csdn.net/'+encodeURIComponent(arr[i])+'" target="_blank"><img class="userAvatar" src="http://profile.csdn.net/'+ encodeURIComponent(arr[i]) +'/picture/4.jpg" alt=""/></a>');
	        //fanwx 081030 修改
		    //l.push('&nbsp;<a href="#" onclick="webimPopup.showChat(\''+ arr[i] +'\');return false;">'+ arr[i] +'</a><br/>');
            l.push('&nbsp;<a href="'+csdn_im_defaultDomain+'/messages/'+encodeURIComponent(arr[i])+'.ashx" target="_blank" onclick="webimPopup.hideItem(\''+i+'\')">'+ arr[i] +'</a></div>');
	    }
	    l.push('</div>');
	    webimPopup.senderItemCount=i-1;
	    return l.join('');
    }
}
webimPopup.hideItem=function(id)
{
    var d=document.getElementById('sdr_'+id);
    if(!d) return;
    d.style.display='none';
    var k=document.getElementById(this.senderDivId);
    if(k) 
    {
        if(webimPopup.senderItemCount>0){webImForm.setToRightCorner(k);webimPopup.senderItemCount--;}
        else{k.style.display='none';}
    }
}
webimPopup.showChat=function(name)
{
//    if(webImForm.hasChatWindow)
//    {
//        if(confirm("该操作将关闭当前聊天窗口,打开新窗口,您确定吗?"))
//        {
//            webImForm.close(this.chatDivId);
//            webImForm.renderChat(name);
//	          webImForm.hasChatWindow=true;
//	    }
//    }
//    else
//    {
//	    webImForm.renderChat(name);
//	    webImForm.hasChatWindow=true;
//	}
}
//如果调用方页面显示声明变量WEBIM_IS_DISPLAY=false,则不显示
webimPopup.checkShowSettings=function()
{
    if(typeof(WEBIM_POPUP_IS_DISPLAY)!='undefined' && WEBIM_POPUP_IS_DISPLAY==false) {return false;}
    else return true;
}
webimPopup.checkUrl=function()
{
    var currentUrl=window.location.href;
    if(currentUrl.indexOf('http://')!=0)
    {
        currentUrl+='http://';
    }
    for(var i=0;i<this.nullityUrlArray.length;i++)
    {
        if(currentUrl.indexOf(this.nullityUrlArray[i])==0) return false;
    }
    return true;
}
webimPopup.checkRepeatLoad=function()
{
    if('undefined'==typeof window.webim_repeat_load_flag)
    {
        window.webim_repeat_load_flag='ok';
        return false;
    }
    else
    {
        return true;
    }
}
webimPopup.nullityUrlArray=new Array("http://passport.csdn.net/", "http://webim.csdn.net/MessageList/IFrame/", "http://webim-local.csdn.net/MessageList/IFrame/");

//run314
webimPopup.request();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -