📄 messenger.js
字号:
<?php
ob_start("ob_gzhandler");
//header("Content-type: text/javascript; charset: UTF-8");
//header("Cache-Control: must-revalidate");
//$offset = 60 * 60 ;
//$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
//header($ExpStr);
?>
document.write('<div id="messenger" style="position:fixed; top:0px; overflow:visible; font-family: Arial; color:#000000; font-size:12px; text-align:left; z-index:5; height:1px; width:1px"><div style="padding:10px"><img id="IMWinNotify" src="new_im.gif" onclick="IMWinShow();" style="cursor:pointer; display:none; width:52px; height:45px" border="0" /><div id="IMWinBuddylist" style="background-color:#efefef; width:150px; height:150px; border:1px solid #c0c0c0; position:absolute; text-align:center; display:none"><b>Buddylist</b><br>Coming Soon!</div><div id="IMWinMsg" style="position:relative; background-color:#efefef; display:none; width:250px; height:150px; border:1px solid #c0c0c0; top:0px; left:0px"><div onMouseDown="IMWinStartDrag();" style="font-weight:bold; text-align:right; border-bottom:1px solid #c0c0c0; cursor:move; overflow:hidden; height:22px; -moz-user-select:none; -khtml-user-select:none; user-select:none"><div style="text-align:center; padding:3px" onselectstart="return false;">Messenger Window</div><img style="position:relative; top:-19px; left:-3px; cursor:pointer" onmousedown="IMClose();" onMouseMove="return false;" src="close_IM.gif" /></div><div id="IMMsgContainer" style="width:246px; background-color:#fafafa; overflow:auto; height:89px"><div id="IMMsg" style="text-align:left; padding-left:3px"><font style="color:#0000ff; font-weight:bold">Automated Message</font>: Hey! Welcome to UberGameShack.com</div></div><div style="border-top:1px solid #c0c0c0; border-bottom:1px solid #c0c0c0"><div style="height:17px; padding-left:3px"><b>To: <font id="IMWinTo" style="color:#ff0000; cursor:pointer">*</font></b> <span onclick="IMChangeTo();" style="cursor:pointer">(Change)</span></div></div><div style="height:20px; overflow:hidden"><input id="IMInput" type="text" style="width:100%; height:18px; border:0px; text-decoration: none; font-size:14px" value="" onclick="IMClearMsg();" onkeypress="IMKeyPress(event);" /><div style="height:8px; width:8px; position:relative; left:100%; margin-left:-8px; top:-7px"><img src="IM_resize.gif" style="cursor:nw-resize; -moz-user-select:none; -khtml-user-select:none; user-select:none; position:absolute; z-index:6" onMouseDown="IMWinStartResize();return false;" onMouseMove="return false;" onselectstart="return false;" /></div></div></div></div></div></div>');
messengerAJAX = new ajaxWrapper();
messengerAJAX.attach('messengerAJAX');
var IMWin = document.getElementById('messenger');
var IMMsgWin = document.getElementById('IMWinMsg');
var IMMsg = document.getElementById('IMMsg');
var IMNotify = document.getElementById('IMWinNotify');
var IMVisible = false;
var IMNew = false;
var mX,mY;
var IMx = 10;
var IMy = 10;
var IMw = 250;
var IMh = 150;
var IMDrag = false;
var IMResize = false;
var IMName = '';
var IMToId = 0;
var IMToName = '';
var IMText = document.getElementById('IMMsg').innerHTML;
var t='0';
var CheckTimer='';
var IMCanSend=true;
var IMDefaultTitle = document.title;
var IMlist = new Array();
var pendSend = false;
if (typeof document.attachEvent!='undefined') {
document.attachEvent('onmousemove',IMWinDrag);
document.attachEvent('onmouseup',IMWinDragStop);
} else {
document.addEventListener('mousemove',IMWinDrag,false);
document.addEventListener('mouseup',IMWinDragStop,false);
}
if(document.all) {
document.getElementById('messenger').style.position='absolute';
if (typeof document.attachEvent!='undefined') {
window.attachEvent('onscroll',scrollIMWin);
} else {
document.addEventListener('scroll',scrollIMWin,false);
}
}
function scrollIMWin(e) {
if(IMNew==true) {
var scrollTop=0;
if(document.all) {
if (document.documentElement && document.documentElement.scrollTop)
scrollTop = document.documentElement.scrollTop;
else if (document.body)
scrollTop = document.body.scrollTop;
//} else {
//scrollTop = window.pageYOffset;
}
IMWin.style.top=scrollTop+'px';
}
}
function newIM() {
if(IMVisible==false) {
IMFlash();
IMNotify.style.display = 'block';
IMNew = true;
scrollIMWin();
}
setCookie('v',1);
}
function IMWinShow() {
IMStopFlash();
IMNotify.style.display = 'none';
IMMsgWin.style.display = 'block';
document.getElementById('IMMsg').scrollTop=document.getElementById('IMMsg').scrollHeight;
IMVisible = true;
setCookie('v',2);
document.getElementById('IMMsgContainer').scrollTop=document.getElementById('IMMsgContainer').scrollHeight;
IMFocus();
}
function IMWinStartDrag() {
mX=NmX;
mY=NmY;
IMx=document.getElementById('IMWinMsg').offsetLeft;
IMy=document.getElementById('IMWinMsg').offsetTop;
IMDrag=true;
}
function IMWinDrag(e) {
var evt,ScrL,ScrT;
e?evt=e:evt=event;
ScrT=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
ScrL=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;
NmX=evt.pageX?evt.pageX-ScrL:evt.clientX-document.body.clientLeft;
NmY=evt.pageY?evt.pageY-ScrT:evt.clientY-document.body.clientTop;
NmX2=evt.pageX?evt.pageX:evt.clientX;
NmY2=evt.pageY?evt.pageY:evt.clientY;
if(!IMVisible)
return;
if(IMDrag) {
IMMove((NmX-mX),(NmY-mY));
}
if(IMResize) {
IMWinResize((NmX-mX),(NmY-mY));
}
mY=NmY;
mX=NmX;
}
function IMWinDragStop(e) {
if(IMVisible) {
if(IMDrag) {
setCookie('x',IMx,3);
setCookie('y',IMy,3);
IMFocus();
}
if(IMResize) {
setCookie('h',IMh,3);
setCookie('w',IMw,3);
IMFocus();
}
}
IMResize=false;
IMDrag=false;
}
function IMWinStartResize() {
mX=NmX;
mY=NmY;
IMResize=true;
}
function IMMove(moveX,moveY) {
IMx+=moveX;
IMy+=moveY;
document.getElementById('IMWinMsg').style.top=(IMy-10)+'px';
document.getElementById('IMWinMsg').style.left=(IMx-10)+'px';
}
function IMWinResize(rX,rY) {
IMw+=rX;
IMh+=rY;
var tmpScroll = false;
if(document.getElementById('IMMsgContainer').scrollTop>=(document.getElementById('IMMsgContainer').scrollHeight-document.getElementById('IMMsgContainer').offsetHeight))
tmpScroll = true;
if((IMh-61)>50) {
document.getElementById('IMWinMsg').style.height=IMh+'px';
document.getElementById('IMMsgContainer').style.height=(IMh-61)+'px';
} else {
IMh-=rY;
}
if(IMw>200) {
document.getElementById('IMWinMsg').style.width=IMw+'px';
document.getElementById('IMMsgContainer').style.width=IMw+'px';
} else {
IMw-=rX;
}
if(tmpScroll)
document.getElementById('IMMsgContainer').scrollTop=document.getElementById('IMMsgContainer').scrollHeight;
}
function IMClearMsg() {
document.getElementById('IMInput').value = '';
}
function IMAddNew(from,fid,to,tid,time,message,type) {
IMSetCheck();
var tmpIM='';
var transC = '00';
var transG = '';
IMCanSend=true;
if(type==1) {
newIM();
} else if(type==3) {
transC = 'bb';
transG = ' style="color:#bbbbbb"';
//tmpIM = '<span style="opacity:.40; filter:alpha(opacity=\'40\')">';
}
message = messengerAJAX.decodeString(message);
message = parseSmilies(message);
var tmpScroll = false;
if(document.getElementById('IMMsgContainer').scrollTop>=(document.getElementById('IMMsgContainer').scrollHeight-document.getElementById('IMMsgContainer').offsetHeight))
tmpScroll = true;
//alert('sceollTop=' + document.getElementById('IMMsg').scrollTop + ', scrollHeight=' + document.getElementById('IMMsg').scrollHeight + ', height=' + document.getElementById('IMMsg').style.height);
if(to!=IMName) {
tmpIM = tmpIM + '<font style="color:#ff'+transC+''+transC+'; font-weight:bold; cursor:pointer" onmouseover="menuOpen=window.setTimeout(\'userMenu(\\\''+tid+'\\\')\',600)" onmouseout="clearTimeout(menuOpen)" onclick="IMSetActive(\''+to+'\',\''+tid+'\')">'+to+'</font>: <span'+transG+'>'+message+'</span>';
} else {
tmpIM = tmpIM + '<font style="color:#'+transC+''+transC+'ff; font-weight:bold; cursor:pointer" onmouseover="menuOpen=window.setTimeout(\'userMenu(\\\''+fid+'\\\')\',600)" onmouseout="clearTimeout(menuOpen)" onclick="IMSetActive(\''+from+'\',\''+fid+'\')">'+from+'</font>: <span'+transG+'>'+message+'</span>';
}
if(type==3) {
//tmpIM = tmpIM + '</span>';
}
document.getElementById('IMMsg').innerHTML=document.getElementById('IMMsg').innerHTML+'<br />'+tmpIM;
if(type!=2) {
if(IMlist.length>10)
IMlist.shift();
IMlist.push(tmpIM);
}
if(tmpScroll)
document.getElementById('IMMsgContainer').scrollTop=document.getElementById('IMMsgContainer').scrollHeight;
}
function IMKeyPress(e) {
var keynum;
window.event?keynum=e.keyCode:keynum=e.which
if(keynum == 13 && IMCanSend==true) {
if(IMToId,document.getElementById('IMInput').value=='') { return; }
IMCanSend=false;
//window.setTimeout('IMCanSend=true;',10);
clearTimeout(CheckTimer);
IMCheck(IMToId,document.getElementById('IMInput').value);
IMClearMsg();
}
}
function IMCheck(to,message) {
clearTimeout(CheckTimer);
if(to==null||message==null) {
messengerAJAX.pingPost();
} else {
messengerAJAX.post('i=' + to + '&m=' + messengerAJAX.encodeString(message));
}
IMVisible?CheckTimer=window.setTimeout('IMDisconnected()',7000):CheckTimer=window.setTimeout('IMDisconnected()',11000);
}
function SC() {
IMSetCheck();
}
function IMSetCheck() {
if(!(CheckTimer==null))
clearTimeout(CheckTimer);
IMVisible?CheckTimer=window.setTimeout('IMCheck()',5000):CheckTimer=window.setTimeout('IMCheck()',9000);
}
function IMSetActive(name,id) {
IMToId = id;
document.getElementById('IMWinTo').innerHTML = name;
IMFocus();
}
function IMChangeTo() {
IMToName = prompt("Please enter name of user:");
if(IMToName!=null)
messengerAJAX.post('c=' + IMToName);
IMFocus();
}
function IMDisconnected() {
messengerAJAX.abort();
messengerAJAX.performQueue();
IMAddNew('Automated Message',0,IMName,0,t,'IM Check Timeout.',0);
}
function IMClose() {
IMNew = false;
IMVisible = false;
document.getElementById('IMMsg').innerHTML = IMlist.join('<br />');
IMMsgWin.style.display = 'none';
deleteCookie('v');
}
function IMFocus() {
document.getElementById('IMInput').focus();
}
function IMFlash() {
document.title = 'New IM!';
}
function IMStopFlash() {
document.title = IMDefaultTitle;
}
function IMLogout() {
IMlist = new Array();
document.getElementById('IMMsg').innerHTML = '';
}
function IMLogin() {
t='0';
IMCheck();
}
function parseSmilies(text) {
text = text.replace(/ ;\)/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/wink.gif\" />");
text = text.replace(/^;\)/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/wink.gif\" />");
text = text.replace(/ :\)/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/smile.gif\" />");
text = text.replace(/^:\)/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/smile.gif\" />");
text = text.replace(/ :\//g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/slant.gif\" />");
text = text.replace(/^:\//g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/slant.gif\" />");
text = text.replace(/ :P/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/tongue.gif\" />");
text = text.replace(/^:P/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/tongue.gif\" />");
text = text.replace(/ \^\^/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/smirk.gif\" />");
text = text.replace(/^\^\^/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/smirk.gif\" />");
text = text.replace(/ ;\(/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/cry.gif\" />");
text = text.replace(/^;\(/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/cry.gif\" />");
text = text.replace(/ 8\)/g, " <img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/bigsmile.gif\" />");
text = text.replace(/^8\)/g, "<img style=\"margin-bottom:-2px; height:14px; width:16px\" src=\"smilies/bigsmile.gif\" />");
return text;
}
messengerAJAX.set('http://www.sentertainment.net/new2/ajax_IM.php');
messengerAJAX.setPostExtension('"t="+t');
messengerAJAX.setOnFail('IMAddNew(\'Automated Message\',0,IMName,0,t,\'Action failed.\',0)');
IMSetCheck();
if(getCookie('x'))
IMx=parseInt(getCookie('x'));
if(getCookie('y'))
IMy=parseInt(getCookie('y'));
if(getCookie('w'))
IMw=parseInt(getCookie('w'));
if(getCookie('h'))
IMh=parseInt(getCookie('h'));
if(getCookie('v')==1)
newIM();
if(getCookie('v')==2) {
newIM();
IMWinShow();
}
IMMove(0,0);
IMWinResize(0,0);
var IMLoaded = true;
function _debug(foo) {
var arg;
for (var i = 0; i < arguments.length; i++) {
arg = arguments[i];
if (window.console) window.console.log(arg);
else if (window.opera) window.opera.postError(arg);
else if (window.Log) {
if (!window._logger)
window._logger = new Log(Log.INFO, Log.popupLogger);
window._logger.debug(arg);
} else alert(arg);
}
}
//_debug('test');
function o(list) {
list = list.split('@');
var id,name,string;
string = '';
for(var i=0;i<list.length;i+=3) {
string = string + ' <span onmouseover="menuOpen=window.setTimeout(\'userMenu(\\\''+list[i]+'\\\')\',600)" onmouseout="clearTimeout(menuOpen)" onclick="newIM();IMWinShow();IMSetActive(\''+list[(i+1)]+'\','+list[i]+')" style="cursor:pointer;font-weight:bold">'+list[(i+1)]+'</span> ';
}
document.getElementById('online').innerHTML = string;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -