imfunction_utf8.js
来自「这篇文章主要用来说明获取设备表述的情况,希望大家可以得到帮助」· JavaScript 代码 · 共 1,274 行 · 第 1/5 页
JS
1,274 行
statusSpans = document.getElementsByTagName("SPAN");
spanindex = 0;
im_global.temp.userSpanArray = new Array();
var userStatusUrl = userStatusServer+"?result=js&sitid="+im_global.variable.siteid+"&uids=";
for(i=0; i<statusSpans.length; i++){
statusSpan = statusSpans[i];
if(statusSpan.className=="wdk_user_status_span" && statusSpan.id){
pos = statusSpan.id.indexOf("wdk_user_");
if(pos>=0){
var newStatusObj = new Object();
newStatusObj.destuid = statusSpan.id.substring(pos+"wdk_user_".length, statusSpan.id.length);
newStatusObj.destnick = statusSpan.title;
newStatusObj.spanElement = statusSpan;
im_global.temp.userSpanArray.push(newStatusObj);
if(im_global.temp.userSpanArray.length>1)
userStatusUrl += ",";
userStatusUrl += encodeURIComponent(newStatusObj.destuid);
}
}
}
//天涯专用,解析看帖页面用户链接
var curURL = window.location.href.toLowerCase();
var isNeedPaser = false;
if(im_global.temp.userSpanArray.length==0 && (im_global.variable.siteid=="tianya" || im_global.variable.siteid=="tianya_v2")){
var allowURLList = new Array("/publicforum/content/","/techforum/content/");
for(i=0;i<allowURLList.length;i++){
if(curURL.indexOf(allowURLList[i])>=0){
isNeedPaser = true;
break;
}
}
}
if(!isNeedPaser){
var pattern = /content.*\.asp\?/i;
if(curURL.match(pattern))
isNeedPaser = true;
}
if(isNeedPaser){
var lnks = document.links;
for(var i=0;i<lnks.length;i++){
match = lnks[i].href.match(/Listwriter\.asp\?(vid=(.*)&)?vwriter=(.*)&?/i);
if(typeof match != "undefined" && match){
var _param = { name:"span",
id:"wdk_user_"+lnks[i].innerHTML,
_class:"wdk_user_status_span",
title:lnks[i].innerHTML};
var chatSpan = im_wdkUtil.createDom(_param,lnks[i].parentNode);
var newStatusObj = new Object();
newStatusObj.destuid = lnks[i].innerHTML;
newStatusObj.destnick = lnks[i].innerHTML;
newStatusObj.spanElement = chatSpan;
im_global.temp.userSpanArray.push(newStatusObj);
if(im_global.temp.userSpanArray.length>1)
userStatusUrl += ",";
userStatusUrl += encodeURIComponent(newStatusObj.destuid);
if(im_global.temp.userSpanArray.length>60)
break;
}
}
}
userStatusUrl += "&unum="+im_global.temp.userSpanArray.length;
if(im_global.temp.userSpanArray.length>0)
im_wdkUtil.createScript(userStatusUrl);
}
//状态服务器返回脚本调用,传递用户列表状态值,用户状态值以,分开,每个值0代表离线,1代表在线
function im_onGetUserStatus(responseText){
if(responseText=="-1" || responseText=="-2" || im_global.cfg.customparams["hiddenmode"])
return;
userStatusArray = responseText.split(",");
for(i=0;i<im_global.temp.userSpanArray.length;i++){
var imgsrc;
switch(userStatusArray[i]){
case "0":
imgsrc = im_global.cache.img["offline"].src;
break;
case "1":
imgsrc = im_global.cache.img["online"].src;
break;
}
alttext="跟我聊天";
chatLinkStr = ' <a href="#" target="_blank" style="display:inline;padding:0px;overflow:visible;" alt="'+alttext+'" onClick="javascript: im_openWebchatWindow(\''+im_global.temp.userSpanArray[i].destuid+'\', \''+im_global.temp.userSpanArray[i].destnick+'\'); return false;" ';
if(im_global.cfg.customparams["show_popmenu"] && !im_global.cfg.customparams["hiddenmode"])
chatLinkStr += ' onmouseover="im_popMenu(this,\''+im_global.temp.userSpanArray[i].destuid+'\',\''+im_global.temp.userSpanArray[i].destnick+'\');" onmouseout="im_beginCloseMenu(this);"';
chatLinkStr += '><img name="wdk_presence_image" style="display:inline;left:0px;top:0px;"';
if(i==0){
chatLinkStr += ' tip="点击这里开始聊天"';
if(im_global.cfg.customparams["show_tooltip"] && !im_global.cfg.customparams["hiddenmode"])
chatLinkStr += ' onload="im_showTip(\'wdk_presence_'+im_global.temp.userSpanArray[i].destuid+'\')"';
}
chatLinkStr += " id=\"wdk_presence_"+im_global.temp.userSpanArray[i].destuid+"\" border=\"0\" src=\""+imgsrc+"\" />";
chatLinkStr += "</a>";
im_global.temp.userSpanArray[i].spanElement.innerHTML = chatLinkStr;
}
}
function im_openWebchatWindow(destuid, destname, chatid){
return im_openWebchat(im_global.variable.user_id, im_global.variable.user_name, im_global.variable.user_sid, im_global.variable.siteid, destuid, destname, chatid, im_global.variable.userparam, !im_global.cfg.customparams["webchat_inpage"], im_global.variable.scriptPath);
}
function im_openBuddyListWindow(){
if(im_myIMWindow)
im_myIMWindow.showWindow(im_global.cfg.customparams["webchat_inpage"]);
else{
var notifystr = "%u60A8%u5C1A%u672A%u767B%u5F55%uFF0C%u8BF7%u767B%u5F55%u540E%u518D%u4F7F%u7528%u597D%u53CB%u5217%u8868%uFF01";
alert(unescape(notifystr));
}
}
function im_popMenu(obj, destuid, destnick){
if(im_global.temp.menuTimer>=0){
clearTimeout(im_global.temp.menuTimer);
im_global.temp.menuTimer = -1;
return;
}
var menudiv = im_wdkUtil.$('im_popMenuid');
if(!menudiv || !obj) return;
var pos = im_wdkUtil.viewRect.get(obj);
var rect= im_wdkUtil.viewRect.get(window, true);
var browser = im_wdkUtil.Browser;
menux = pos.x+pos.w - (browser.msie56 ? 0 : rect.x);
menuy = pos.y - (browser.msie56 ? 0 : rect.y);
chatLinkStr = "<a href=\"#\" target=\"_blank\" style=\"overflow:visible;font-size:12px;font-weight:100;padding-left:5px;padding-top:5px;overflow:visible;\" onClick=\"javascript: im_openWebchatWindow('"+destuid+"', '"+destnick+"');return false;\">聊天</a>";
menuStr = "<div>" + chatLinkStr + "</div>";
buddylistLinkStr = "<a href=\"#\" target=\"_blank\" style=\"overflow:visible;font-size:12px;padding:5px;font-weight:100;\" onClick=\"javascript: im_openBuddyListWindow(); return false;\">我的好友</a>";
menuStr += "<div>"+buddylistLinkStr+"</div>";
if(im_global.variable.onlineuserURL && im_global.variable.onlineuserURL.length>0){
onlineLinkStr = "<a href=\""+im_global.variable.onlineuserURL+"\" target=\"_blank\" style=\"font-size:12px;font-weight:100;padding-left:5px; overflow:visible;\" >在线会员</a>";
menuStr += "<div>"+onlineLinkStr+"</div>";
}
menuStr += "</div>";
menudiv.innerHTML = menuStr;
menudiv.style.display = 'block';
menudiv.style.left = menux+"px";
menudiv.style.top = menuy+"px";
menudiv.onmouseover = im_popMenu;
menudiv.onmouseout = im_beginCloseMenu;
}
function im_beginCloseMenu(obj){
im_global.temp.menuTimer = setTimeout(im_closeMenu, 300);
}
function im_closeMenu(obj){
var menudiv = im_wdkUtil.$('im_popMenuid');
menudiv.style.display = 'none';
im_global.temp.menuTimer = -1;
}
Number.prototype.Timer = function(func, iT, bUrge){
if(!this.value || bUrge)
this.value = window.setTimeout(func, iT);
}
Number.prototype.EndTimer = function(){
if(this.value){
window.clearTimeout(this.value);
this.value = 0;
}
}
/*--im_ToolTip--*/
im_ToolTip.loadImage();
function im_hiddenTip(e){
if(typeof(e)=='string'){evObj = im_wdkUtil.$(e);
}else {evObj = this;}
var key = (typeof(e)=='string') ? e : (evObj.id ? 'imiT'+evObj.id : 'imiTToolTip');
im_tipFade(im_ToolTip._opac[key], key, false);
clearInterval(im_ToolTip._iTimerID[((typeof(e)=='string') ? e : evObj.id)]);
}
function im_showTip(e){
if(typeof(e)=='string'){
evObj = im_wdkUtil.$(e);
im_createTip(e);
}else{
evObj = e;
im_createTip(evObj.id ? evObj.id : 'ToolTip');
}
var key = evObj.id ? evObj.id : 'ToolTip';
evObj.onload = null;
if (typeof(e)=='string'){
im_ToolTip._step[key] = 10;
}
im_ToolTip._Time[key][1].Timer("im__showTip('"+key+"')", 100, true);
}
function im__showTip(key){
var evObj = im_wdkUtil.$(key);
var LogoRect = im_wdkUtil.viewRect.get(key);
var winRect = im_wdkUtil.viewRect.get(window, true);
var Tip_left = 0;
try{
im_ToolTip._Tips[key].innerHTML = im_getTipHTML( evObj.getAttribute('tip'), key);
}
catch(e){
im_tipFade(10, key, true);
return;
}
var tipRect = im_wdkUtil.viewRect.get(im_ToolTip._Tips[key]);
var bALlOOnB_obj = im_wdkUtil.viewRect.get('bALlOOnB_'+key);
if ( parseInt(LogoRect.x + tipRect.w + 20) > parseInt(winRect.w) ) {
im_ToolTip._Tips[key].style.top = (0 - tipRect.h) + "px";
im_ToolTip._Tips[key].style.left = ( LogoRect.w/2+30 - tipRect.w) + "px";
im_wdkUtil.$('bALlOOnB_'+key).style.left = "73px";
} else {
im_ToolTip._Tips[key].style.top = (LogoRect.y - tipRect.h - winRect.y) + 'px';
Tip_left = LogoRect.x+LogoRect.w/2-15;
im_ToolTip._Tips[key].style.left = Tip_left + 'px';
bALlOOnB_left = document.compatMode=="BackCompat" || bALlOOnB_obj.x<Tip_left || bALlOOnB_obj.x>(Tip_left + tipRect.w ) ?
'0px' :
(16 - tipRect.w/2) + 'px';
im_wdkUtil.$('bALlOOnB_'+key).style.left = bALlOOnB_left;
}
im_ToolTip._Tips[key].style.visibility = 'visible';
im_ToolTip._Tips[key].style.opacity = '.1';
im_tipFade(10, key, true);
}
function im_tipFade(opac, key, exeType){
var passed = parseInt(opac);
if( exeType == true ){//show
var newOpac = parseInt(passed+10);
if ( newOpac <= 80 ) {
im_ToolTip._Tips[key].style.opacity = '.'+newOpac;
im_ToolTip._Tips[key].style.filter = "alpha(opacity:"+newOpac+")";
im_ToolTip._Time[key][1].Timer("im_tipFade('"+newOpac+"', '"+key+"', true)",100, true);
im_ToolTip._opac[key] = newOpac;
}
else {
im_ToolTip._Time[key][1].EndTimer();
im_ToolTip._Tips[key].style.opacity = '.80';
im_ToolTip._Tips[key].style.filter = "alpha(opacity:80)";
im_ToolTip._Time[key][2].Timer("im_hiddenTip('"+key+"')", 5000, false);
}
}else{//hidden
var newOpac = parseInt(passed-im_ToolTip._step[key]);
if ( newOpac >=10 ) {
im_ToolTip._Tips[key].style.opacity = '.'+newOpac;
im_ToolTip._Tips[key].style.filter = "alpha(opacity:"+newOpac+")";
im_ToolTip._Time[key][1].Timer("im_tipFade('"+newOpac+"', '"+key+"', false)",50, true);
}
else {
im_ToolTip._Time[key][1].EndTimer();
im_ToolTip._Time[key][2].EndTimer();
im_ToolTip._Tips[key].style.visibility = 'hidden';
}
}
}
function im_createTip(El){
if(im_wdkUtil.$("imiT"+El)) return true;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?