"
if(childitem.imgurl)
{
//width=20 height=20
tablehtml+="";
}
else
{
tablehtml+="";
}
if(childitem.hotkey)
{
tablehtml+=" | "+childitem.html+" | ";
tablehtml+=""+childitem.hotkey+" | ";
}
else
{
tablehtml+=""+childitem.html+" | ";
}
if(true)
{
tablehtml+=" 4 | ";
else
tablehtml+=";font-family:arial;font-size:14px;'> > ";
}
else
{
if(childitem.items.length==0&&childitem.oninitialize!=null)
{
tablehtml+=" 4 | ";
else
tablehtml+=";font-family:arial;font-size:14px;'> > ";
}
}
tablehtml+="";
var itemdiv=framedoc.createElement("DIV");
childitem.itemdiv=itemdiv;
Html_SetCssText(itemdiv,"cursor:default;margin:1px;width:100%;overflow:visible;"+(childitem.enable?"":"filter:alpha(opacity=40);"));
if(!childitem.enable)itemdiv.style.MozOpacity=0.4;
itemdiv.innerHTML=tablehtml;
if(Html_IsGecko || Html_IsOpera)
{
itemdiv.onmousedown=new Function("event","event.cancelBubble=true;");
}
if(childitem.enable)
{
itemdiv.onmouseover=Create_MenuItemDiv_OnMouseOver(childitem);
itemdiv.onmouseout=Create_MenuItemDiv_OnMouseOut(childitem);
itemdiv.onclick=Create_MenuItemDiv_OnClick(childitem);
if(childitem.onclick)
{
itemdiv.style.cursor='hand';
}
}
else
{
//itemdiv.disabled=!childitem.enable;
}
cell.appendChild(itemdiv);
}
framebody.appendChild(table);
frame.style.width=table.offsetWidth+16+"px";
frame.style.height=table.offsetHeight+6+"px";
return frame;
}
function MenuClass()
{
var frame=null;
var menu=this;
menu.menu=menu;
menu.items=[];
menu.zIndex=7777777;
menu.closed=true;
function OnWindowBlur()
{
setTimeout(CloseIt,250);
function CloseIt()
{
if(menu.Close)
menu.Close();
}
}
function OnDocumentClick()
{
if(menu.Close)
menu.Close();
}
function OnWindowUnload()
{
if(menu.Close)
menu.Close();
}
menu.Show=function menu_Show(target,offsetX,offsetY)
{
if(_menuclass_currentmenu)
_menuclass_currentmenu.Close();
menu.Close();
window.focus();
if(menu.frame==null)
{
menu.frame=MenuClass_CreateFrame(menu);
}
Menu_ShowFrame(menu.frame,target,offsetX,offsetY);
_menuclass_currentmenu=menu;
//Html_AttachEvent(window,"blur",OnWindowBlur);
Html_AttachEvent(document,"mousedown",OnDocumentClick);
Html_AttachEvent(window,"beforeunload",OnWindowUnload);
menu.opened=true;
}
menu.Close=function()
{
if(!menu.opened)return;
menu.opened=false;
//Html_DetachEvent(window,"blur",OnWindowBlur);
Html_DetachEvent(document,"mousedown",OnDocumentClick);
Html_DetachEvent(window,"beforeunload",OnWindowUnload);
if(_menuclass_currentmenu==menu)
_menuclass_currentmenu=null;
if(menu.frame==null)
return;
menu.frame.style.display='none';
if(menu.openitem)
menu.openitem.Close();
//Dispose on close..
Dispose();
}
menu.HideByClick=function()
{
if(menu.frame)
{
menu.frame.style.display='none';
}
if(menu.openitem)
menu.openitem.Close();
}
menu.Dispose=function()
{
menu.Close();
Dispose();
}
function Dispose()
{
if(menu.isdisposed)return;
menu.isdisposed=true;
for(var i=0;i0?true:false;
childmenu.html=html;
childmenu.imgurl=imgurl==null?null:(imgurl.indexOf('.')==-1?(menuimagebase+imgurl+".gif"):imgurl);
childmenu.onclick=onclick;
childmenu.oninitialize=oninitialize;
menu.items[menu.items.length]=childmenu;
return childmenu;
}
function ChildMenuClass()
{
var menuitem=this;
menuitem.items=[];
menuitem.AddSpliter=function()
{
if(menuitem.items.length==0||menuitem.items[menuitem.items.length-1].html!='-')
return menuitem.AddMenuItem(1,"-");
return menuitem.items[menuitem.items.length-1];
}
menuitem.AddMenuItem=
menuitem.Add=function(state,html,imgurl,onclick,oninitialize)
{
var childmenu=new ChildMenuClass();
childmenu.zIndex=menuitem.zIndex+1;
childmenu.menu=menu;
childmenu.owner=menuitem;
childmenu.enable=state>0?true:false;
childmenu.html=html;
childmenu.imgurl=imgurl==null?null:(imgurl.indexOf('.')==-1?(menuimagebase+imgurl+".gif"):imgurl);
childmenu.onclick=onclick;
childmenu.oninitialize=oninitialize;
menuitem.items[menuitem.items.length]=childmenu;
return childmenu;
}
menuitem.Show=function(target,offsetX,offsetY)
{
if(menuitem.isopen)return;
if(menuitem.frame==null)
{
menuitem.frame=MenuClass_CreateFrame(menuitem);
}
Menu_ShowFrame(menuitem.frame,target,offsetX,offsetY);
menuitem.owner.openitem=menuitem;
menuitem.isopen=true;
}
menuitem.Close=function()
{
if(!menuitem.isopen)return;
if(menuitem.openitem)
menuitem.openitem.Close();
MenuItemDiv_OnMouseOut(menuitem.itemdiv);
menuitem.frame.style.display='none';
menuitem.frame.style.top='0px'
menuitem.frame.style.left='0px'
menuitem.owner.openitem=null;
menuitem.isopen=false;
}
menuitem.Dispose=function()
{
if(menuitem.isdisposed)return;
menuitem.isdisposed=true;
for(var i=0;i18)throw(_SL_CreateException(TEXT("UI_CONNECTION_LongNickName")));
for(var i=0;i256)
continue;
if(c>=48 && c<=57)
continue;
if(c>=65 && c<=90)
continue;
if(c>=97 && c<=122)
continue;
throw(_SL_CreateException("unsupport char '"+name.charAt(i)+"'"));
}
chatclient.guestname=name;
}
function SetPassword(pwd)
{
chatclient.password=pwd;
}
function SetFontName(fontname)
{
chatclient.fontname=fontname;
_InvokeChatEvent("OPTION",["OPTION","FONTNAME",fontname]);
}
function GetFontName()
{
return chatclient.fontname;
}
function SetFontSize(fontsize)
{
chatclient.fontsize=fontsize;
_InvokeChatEvent("OPTION",["OPTION","FONTSIZE",fontsize]);
}
function GetFontSize()
{
return chatclient.fontsize;
}
function SetFontColor(fontcolor)
{
chatclient.fontcolor=fontcolor;
_InvokeChatEvent("OPTION",["OPTION","FONTCOLOR",fontcolor]);
}
function GetFontColor()
{
return chatclient.fontcolor;
}
function SetFontBold(fontbold)
{
chatclient.fontbold=fontbold;
_InvokeChatEvent("OPTION",["OPTION","FONTBOLD",fontbold]);
}
function GetFontBold()
{
return chatclient.fontbold;
}
function SetFontItalic(fontitalic)
{
chatclient.fontitalic=fontitalic;
_InvokeChatEvent("OPTION",["OPTION","FONTITALIC",fontitalic]);
}
function GetFontItalic()
{
return chatclient.fontitalic;
}
function SetFontUnderline(fontunderline)
{
chatclient.fontunderline=fontunderline;
_InvokeChatEvent("OPTION",["OPTION","FONTUNDERLINE",fontunderline]);
}
function GetFontUnderline()
{
return chatclient.fontunderline;
}
function SetWhisper(whisper)
{
chatclient.whisper=whisper;
_InvokeChatEvent("OPTION",["OPTION","WHISPER",whisper]);
}
function GetWhisper()
{
return chatclient.whisper;
}
function SetInstantContact(contact)
{
chatclient.targetContact=contact;
}
function GetInstantContact()
{
return chatclient.targetContact;
}
var chatmessages=[];
var chatvars={};
__ResetChatVars()
function __ResetChatVars()
{
chatvars={};
chatvars.traces=[];
chatvars.errors=[];
//chatvars.place=null;
//chatvars.myinfo=null;
chatvars.itemmap={};
chatvars.userbyguid={};
chatvars.userbyname={}
chatvars.userbyid={};
chatvars.users=[];
chatvars.contactbyid={};
chatvars.contactbyname={};
chatvars.ignorebyid={};
chatvars.ignorebyname={};
chatvars.contacts=[];
chatvars.ignores=[];
chatvars.tabusers=[];
chatvars.cts=[];
}
function GetTraces()
{
return chatvars.traces;
}
function GetErrors()
{
return chatvars.errors;
}
function _Trace(message)
{
chatvars.traces[chatvars.traces.length]=message;
_InvokeChatEvent("TRACE",["TRACE",message]);
}
function _Error(error)
{
chatvars.errors[chatvars.errors.length]=error;
_InvokeChatEvent("ERROR",["ERROR",error]);
}
function _General_Return(res)
{
}
function _General_Error(err)
{
_Error(err);
}
function SetItemInfo(guid,name,value)
{
if(chatvars.tempiteminfomap==null)chatvars.tempiteminfomap={};
var userinfo=chatvars.tempiteminfomap[guid];
if(userinfo==null)
{
userinfo={};
chatvars.tempiteminfomap[guid]=userinfo;
}
userinfo[name]=value;
}
function GetItemInfo(guid,name)
{
if(chatvars.tempiteminfomap==null)return;
var userinfo=chatvars.tempiteminfomap[guid];
if(userinfo==null)return;
return userinfo[name];
}
function IsConnected()
{
return chatvars.connected;
}
function IsConnecting()
{
return chatvars.connecting || chatvars.connectinqueue;
}
function Connect(placename)
{
if(chatvars.connecting)return;
if(chatvars.connected)return;
if(!chatvars.connectinqueue)
{
if(placename)
{
chatclient.placename=placename;
}
__ResetChatVars();
}
var cookie=chatvars.cookie={};
cookie.GuestName=chatclient.guestname;
cookie.Password=chatclient.password;
chatvars.connecting=true;
chatvars.connect_cancelled=false;
_Trace("Connecting..");
ChatService_Connect(cookie,chatclient.placename,Connect_Callback,Connect_Error);
if(!chatvars.connectinqueue)
{
_InvokeChatEvent("CONNECTION",["CONNECTION","CONNECTING"]);
}
}
function Connect_Callback(res)
{
if(chatvars.connect_cancelled && res.ReturnCode!="READY")return;
chatvars.connecting=false;
chatvars.connected=false;
if(res.ReturnCode!="INQUEUE")
{
_Trace("Connect_Callback . "+res.ReturnCode+" , "+res.ServerMessage);
}
switch(res.ReturnCode)
{
case "READY":
chatvars.cookie=res.Cookie||chatvars.cookie;
chatclient.guestname=chatvars.cookie.GuestName;
if(chatvars.connect_cancelled)
{
_Disconnect();
return;
}
chatvars.connected=true;
chatvars.connectedtime=new Date().getTime();
chatvars.connectinqueue=false;
_Chat_Start_Sync();
_InvokeChatEvent("CONNECTION",["CONNECTION","READY"]);
if(IsMessenger())
{
PushCTSMessage(JoinToMsg("USER_COMMAND",null,["LOADHISTORY"]))
chatclient.loadedhistories=true;
}
break;
case "INQUEUE"://TODO:not tested..
chatvars.cookie=res.Cookie||chatvars.cookie;
chatclient.guestname=chatvars.cookie.GuestName;
chatvars.connectTimerid=setTimeout("Connect()",5000);
if(!chatvars.connectinqueue)
{
chatvars.connectinqueue=true;
_InvokeChatEvent("CONNECTION",["CONNECTION","INQUEUE"]);
}
break;
case "LIMITED"://there are too many connections..
case "IDEXISTS":
case "ERROR":
case "NOPLACE":
case "KICK":
case "REJECTED":
case "REMOVED":
case "NEEDLOGIN":
case "NEEDNAME":
case "LOCKED":
case "NOTENABLE":
case "NEEDPASSWORD":
//case "NOCONNECTION"://only when syncing..
chatvars.connectinqueue=false;
_InvokeChatEvent("CONNECTION",["CONNECTION",res.ReturnCode,res.ServerMessage]);
break;
default:
chatvars.connectinqueue=false;
_Trace("Unknown connection response code : '"+res.ReturnCode+"'");
_InvokeChatEvent("CONNECTION",["CONNECTION","ERROR","Unknown connection response code : '"+res.ReturnCode+"'"]);
break;
}
}
function Connect_Error(err)
{
chatvars.connecting=false;
chatvars.connected=false;
chatvars.connectinqueue=false;
if(chatvars.connect_cancelled)return;
_InvokeChatEvent("CONNECTION",["CONNECTION","ERROR",err.message]);
_Error(err);
}
function Disconnect(rightNow)
{
if(chatvars.connecting)
{
chatvars.connecting=false;
chatvars.connect_cancelled=true;
chatvars.connectinqueue=false;
_InvokeChatEvent("CONNECTION",["CONNECTION","CANCELLED"]);
}
if(chatvars.connectinqueue)
{
chatvars.connectinqueue=false;
clearTimeout(chatvars.connectTimerid);
_InvokeChatEvent("CONNECTION",["CONNECTION","CANCELLED"]);
return;
}
if(chatvars.connected)
{
chatvars.connected=false;
_Chat_Stop_Sync();
_Disconnect(rightNow);
_InvokeChatEvent("CONNECTION",["CONNECTION","DISCONNECT"]);
}
}
function _Disconnect(rightNow)
{
if(chatvars.cookie==null)
return;
_Trace("_Disconnect("+rightNow+")");
if(rightNow)
{
try
{
ChatService_SendRequest(chatvars.cookie,chatclient.placename,"DISCONNECT");
}
catch(err)
{
_Error(err);
}
}
else
{
ChatService_SendRequest(chatvars.cookie,chatclient.placename,"DISCONNECT",null,null,_Disconnect_Callback,_Disconnect_Error);
}
}
function _Disconnect_Callback()
{
}
function _Disconnect_Error(err)
{
_Error(err);
}
function DoSync()
{
if(chatvars.syncing)
{
//skip use this flag
//chatvars.forcesync=true;
return;
}
else
{
chatvars.forcesync=false;
__CallSync();
}
}
function __CallSync()
{
if(!chatvars.sync)return;
var resyncforcts=!!chatvars.lastctscount;
var sendmsg=chatvars.hasmessagesending;
chatvars.hasmessagesending=false;
var messages=chatvars.cts;
chatvars.lastctscount=messages.length;
chatvars.cts=[];
var ms1=new Date().getTime() - (chatvars.typingTime||0);
var ms2=new Date().getTime() - (chatvars.typingSend||0);
if(ms1TYPINGINTERNVAL)
{
chatvars.typingSend=new Date().getTime()
var typingtarget=null;
var addtyping=true;
if(IsMessenger())
{
if(chatvars.typingContact==null)
{
addtyping=false;
}
else
{
typingtarget=chatvars.typingContact.Guid;
}
}
else
{
if(GetSelectedUser())
{
typingtarget=GetSelectedUser().Guid;
}
}
if(addtyping)
{
_Trace("_CTS:USER_TYPING:"+(typingtarget||""));
messages.push(JoinToMsg("USER_TYPING",null,[typingtarget]));
}
}
var nvc={};
if(resyncforcts && RequireReSyncForCTS)
{
nvc["CTSRESYNC"]="1";
}
if(sendmsg)
{
nvc["HASMESSAGE"]="1";
}
chatvars.syncxh=ChatService_SendRequest(chatvars.cookie,chatclient.placename,"SYNCDATA",messages,nvc,_Sync_Return,_Sync_Error);
chatvars.syncing=true;
}
function _Chat_Start_Sync()
{
if(chatvars.sync)return;
chatvars.sync=true;
chatvars.synctimerid=setTimeout(_Chat_Sync_HandleTimeout,Chat_Sync_Timeout);
}
function _Chat_Stop_Sync()
{
if(chatvars.sync)
{
chatvars.sync=false;
clearTimeout(chatvars.synctimerid);
}
}
function _Chat_Sync_HandleTimeout()
{
//sync timeout reset here , just equals interval
clearTimeout(chatvars.synctimerid);
chatvars.synctimerid=setTimeout(_Chat_Sync_HandleTimeout,Chat_Sync_Timeout);
var nowtime=new Date().getTime();
if(chatvars.syncing)
{
var time=chatvars.lastsynctime||0;
if(nowtime-time<10000)
{
return;
}
else
{
_Trace("* * * * * * * * re sync for xh timeout.");
if(chatvars.syncxh!=null)
{
try
{
chatvars.syncxh.abort();
}
catch(x)
{
}
}
}
}
chatvars.lastsynctime=nowtime;
__CallSync();
}
function _Sync_Return(res)
{
chatvars.syncing=false;
if(!chatvars.connected)
return;
//invalid request .
if(res.Cookie!=null&&res.Cookie.ConnectionId!=chatvars.cookie.ConnectionId)
{
return;
}
_Sync_HandleResponse(res);
//if I have send something.
if(chatvars.lastctscount && RequireReSyncForCTS)
{
_Trace("re-sync for CTS Res");
DoSync();
}
else if(chatvars.cts.length>0)
{
_Trace("re-sync for new CTS");
DoSync();
}
else if(chatvars.forcesync)
{
_Trace("force sync");
DoSync();
//chatvars.forcesync=false;
//clearTimeout(chatvars.synctimerid);
//chatvars.synctimerid=setTimeout(_Chat_Sync_HandleTimeout,1);
_Trace("force sync");
}
}
function _Sync_HandleResponse(res)
{
switch(res.ReturnCode)
{
case "READY":
chatvars.cookie=res.Cookie||chatvars.cookie;
//TODO:handle items
for(var i=0;i";
html=div+html+"";
return __SendMessage(text,html,nvc);
}
function SendEmotion(emotion)
{
var nvc={};
nvc.Emotion=emotion;
return __SendMessage(emotion,null,nvc);
}
function __UpdateUserTo(user,obj,userUpdated)
{
if(obj==null)return;
if(user==null)
{
obj.OnlineStatus="OFFLINE";
obj.IsOnline=false;
if(!obj.CopyUser&&!obj.UserName)
{
obj.UserName=obj.DisplayName;
}
return;
}
obj.IsOnline=user.IsOnline;
obj.Guid=user.Guid;//setup runtime guid
obj.UserName=user.UserName;
obj.DisplayName=user.DisplayName
obj.Description=user.Description;
obj.OnlineStatus=user.OnlineStatus;
obj.PublicProperties=user.PublicProperties;
obj.CopyUser=true;
if(userUpdated)
{
if(obj.IsContact)
_InvokeChatEvent("CONTACT",["CONTACT","UPDATED",obj,obj]);
if(obj.IsIgnore)
_InvokeChatEvent("IGNORE",["IGNORE","UPDATED",obj,obj]);
}
}
function UserEquals(user1,user2)
{
if(user1==user2)return true;
if(user1==null||user2==null)return false;
if(user1.UserId.toLowerCase()==user2.UserId.toLowerCase())return true;
//do not check Guid
return false;
}
function GetUsers()
{
return chatvars.users;
}
function GetUserByGuid(userguid)
{
return chatvars.userbyguid[userguid];
}
function GetUserByName(name)
{
if(name)
return chatvars.userbyname[name.toLowerCase()];
}
function GetUserById(userid)
{
if(userid)
return chatvars.userbyid[userid.toLowerCase()];
}
function GetTypingUsers()
{
var typings=[];
for(var i=0;i (new Date().getTime()-TYPINGDISPLAYTIME))
{
typings.push(user.DisplayName);
}
}
return typings;
}
function IsUserTyping(user)
{
if(!user)return false;
var time=GetItemInfo(user.Guid,"TypingTime");
if(time && time > (new Date().getTime()-TYPINGDISPLAYTIME))
{
return true;
}
return false;
}
function GetSelectedUser()
{
return GetUserById( (chatclient.selecteduser||{}).UserId );
}
function SetSelectedUser(user)
{
var users=GetUsers();
var olduser;
if(chatclient.selecteduser)
{
for(var i=0;i
var CHATUI_DEBUG=true;
var CHATUI_MAX_MESSAGE_ITEM_COUNT=500;
var CHATUI_AUTOAWAYTIMEOUT=1800;
if(typeof(__cc_version)=="undefined")
{
alert("Unable to load LoadSettings.aspx!");
}
var chatui_random=__cc_version;
if(CHATUI_DEBUG)chatui_random=Math.random();
function LoadSkinClasses(skin,layout)
{
_SL_ParseXml(_SL_LoadXmlDocument(__cc_urlbase+"Skins/"+skin+"/"+layout),null);
}
function LoadChatClasses(url)
{
var lower=url.toLowerCase();
if(lower.substr(0,1)!="/"&&lower.substr(0,4)!="http")
{
url=__cc_urlbase+"Xml/"+url
}
return _SL_LoadXmlDocument(url);
}
function m_over(element) {
element.className='buttonover';
}
function m_out(element) {
element.className='button';
}
function ChatUI_FormatTime(time)
{
var h=String(time.getHours());
var m=String(time.getMinutes());
var s=String(time.getSeconds());
if(h.length==1)h="0"+h;
if(m.length==1)m="0"+m;
if(s.length==1)s="0"+s;
return h+":"+m+":"+s;
}
function ChatUI_ShowHelp()
{
OpenWindowAsync(null,"chat-user-guide/");
}
function ChatUI_ShowMessengerHelp()
{
OpenWindowAsync(null,"messenger-user-guide/");
}
function HelpSplashCommandHandler()
{
//TODO:change the help text
var msg={};
msg.Type="LOCAL";
msg.Text=TEXT("UI_ChatCommands");
for(var key in CHATUI_SPLASHCOMMANDS)
{
msg.Text+="\r\n /"+key;
}
FireMessage(msg,true);
return true;
}
function FindUserByName(name)
{
if(!name)return null;
name=name.toLowerCase();
var users=GetUsers();
for(var i=0;i=0;i--)
{
var handler=cmd["Arg"+i];
if(handler)
{
if(typeof(handler)=="function")
{
res=handler.apply(this,arr);
}
else //string
{
res=handler.replace(/\%ME/ig,GetMyInfo().DisplayName);
for(var j=0;jnew Date().getTime())
return;
_lastsoundplaytime=new Date().getTime();
SoundManager_Play(soundfile);
}
function ChatUI_SetEnableSound(enable)
{
enable=_SL_ToBoolean(enable);
if(enable)
{
SetCookie("CCNoSound","false",3600*24*365);
}
else
{
SetCookie("CCNoSound","true",3600*24*365);
}
}
function ChatUI_GetEnableSound()
{
var v=GetCookie("CCNoSound");
if(v=="true")
return false;
if(v=="false")
return true;
return DefaultEnableSound; //default allow sound..
}
function ChatUI_PlayBuzz()
{
ChatUI_PlaySound("nudge");
ChatUI_FocusWindow();
var movefactor=5;
var posarr=[
[1,1],[1,-1],[-1,-1],[-1,1],
[1,-1],[-1,-1],[-1,1],[1,1],
[-1,-1],[-1,1],[1,1],[1,-1],
[-1,1],[1,1],[1,-1],[-1,-1],
[1,1],[1,-1],[-1,-1],[-1,1]
,
[1,1],[1,-1],[-1,-1],[-1,1],
[1,-1],[-1,-1],[-1,1],[1,1],
[-1,-1],[-1,1],[1,1],[1,-1],
[-1,1],[1,1],[1,-1],[-1,-1],
[1,1],[1,-1],[-1,-1],[-1,1]
];
var index=0;
function MoveFunc()
{
var pos=posarr[index];
if(pos)
{
try
{
window.moveBy(pos[0]*movefactor,pos[1]*movefactor);
}
catch(x)
{
}
}
index++;
if(index==='+thetext+'===<'}
if (step==2) {document.title='=>=='+thetext+'==<='}
if (step==3) {document.title='>=>='+thetext+'=<=<'}
if (step==4) {document.title='=>=>'+thetext+'<=<='}
if (step==5) {document.title='==>='+thetext+'=<=='}
if (step==6) {document.title='===>'+thetext+'<==='}
setTimeout(flash_title,400);
}
flash_title()
}
function ChatUI_FocusWindow()
{
FlashWindowTitle();
if( ! ChatUI_GetAutoFocus() ) return;
FocusWindow();
}
var chatui_sendmsgtimes=[];
var chatui_floodmsgsend=false;
function ChatUI_CheckFloodControl()
{
if(IsMessenger()||GetLocation()=="Support")return true;
var count = FloodControlCount;
var maxms = FloodControlDelay* 1000;
if(chatui_sendmsgtimes.length>=count)
{
var timespan=new Date().getTime()-chatui_sendmsgtimes[chatui_sendmsgtimes.length-count];
if(timespan < maxms)
{
if(!chatui_floodmsgsend)
{
ChatUI_PlaySound("Alert");
Desktop.Alert(null,TEXT("UI_FloodControlMessage"),TEXT("UI_FloodControlTitle"));
chatui_floodmsgsend=true;
}
return false;
}
//reset while 100 sent messages
if(chatui_sendmsgtimes.length>100)
{
chatui_sendmsgtimes.splice(0,90);
}
}
chatui_floodmsgsend=false;
return true;
}
function ChatUI_SendMessageWithFloodControl(text,html)
{
if(text && text.substr(0,1)=="/")
{
//TODO:
return ChatUI_HandleSplashCommand(text.substring(1));
}
if( ! ChatUI_CheckFloodControl() )
{
return false;
}
if(html==null)
{
html=ChatUI_TranslateText(text)
}
var sended=SendMessage(text,html);
if(sended)
{
chatui_sendmsgtimes[chatui_sendmsgtimes.length]=new Date().getTime();
}
return sended;
}
function ChatUI_SendEmotionWithFloodCoontrol(text)
{
if( ! ChatUI_CheckFloodControl() )
{
return false;
}
var ismessenger=IsMessenger();
if(ismessenger)
{
var tc=GetInstantContact();
if(tc==null||!tc.IsOnline)
{
ChatUI_PlaySound("Alert");
Desktop.Alert(null,TEXT("TargetUserNotOnline"),TEXT("UI_ALERT"));
return false;
}
}
var sended=SendEmotion(text);
if(sended)
{
chatui_sendmsgtimes[chatui_sendmsgtimes.length]=new Date().getTime();
}
return sended;
}
function ChatUI_SetContextMenu(obj,func)
{
obj.oncontextmenu=func;
if(!Html_IsOpera)
{
return;
}
if(obj.getAttribute("_cui_scm")=="yes")
{
return;
}
obj.setAttribute("_cui_scm","yes");
Html_AttachEventInternal(obj,"click",ChatUI_SCM_Opera_OnClick);
}
function ChatUI_SCM_Opera_OnClick(event)
{
event=event||window.event;
if(!event.shiftKey)return;
var obj=event.srcElement;
while(obj)
{
if(obj.getAttribute("_cui_scm")=="yes")
break;
obj=obj.parentNode;
}
if(obj)
{
var cm=obj.oncontextmenu;
if(cm)
{
event.cancelBubble=true;
return cm.apply(obj,arguments)
}
}
}
/****************************************************************\
InputBox
\****************************************************************/
function InputBoxElement_RunScript(event)
{
event=event||window.event;
if(CHATUI_DEBUG && event.ctrlKey)
{
var element=event.srcElement||event.target;
eval( element.innerText||element.value );
}
}
function InputBoxElement_ContextMenu(event)
{
event=event||window.event;
if(!Html_FCM(event))return;
var inputbox=this;
if(typeof(InputBoxMenu)!="undefined")
InputBoxMenu.ShowMenuItems(inputbox,event.clientX,event.clientY);
event.returnValue=false;
event.cancelBubble=true;
}
function ChatUI_CreateWinIEInputElement()
{
var div=document.createElement("DIV");
div.contentEditable=true;
div.onkeydown=InputBoxElement_OnKeyDown
div.onkeypress=IEInputBoxElement_OnKeyPress;
div.ondblclick=InputBoxElement_RunScript;
if(UseHookupEventForMsnImages)
{
div.onkeyup=HookupEventForMsnImages;
}
ChatUI_SetContextMenu(div,InputBoxElement_ContextMenu);
return div;
}
function IEInputBoxElement_OnKeyPress()
{
SetIsTyping();
if( (event.keyCode=='13'||event.keyCode=='10') &&!event.shiftKey)
{
//event.returnValue=false;
var inputbox=this;
var text=inputbox.innerText;
if( (/(http|ftp)\:\/\/\S+$/ig).exec(text))
{
event.keyCode=' '.charCodeAt(0);//just let http://url.com/+ENTER don't forgot it's a url.
}
else
{
event.returnValue=false;
}
setTimeout(DoSendMessage,10);
}
}
function ChatUI_CreateInputTextArea()
{
var ta=document.createElement("TEXTAREA");
ta.onkeypress=InputBoxTextArea_OnKeyPress;
ta.ondblclick=InputBoxElement_RunScript;
ChatUI_SetContextMenu(ta,InputBoxElement_ContextMenu);
return ta;
}
function InputBoxTextArea_OnKeyPress(event)
{
event=event||window.event;
SetIsTyping();
if((event.keyCode=='13'||event.keyCode=='10')&&!event.shiftKey)
{
if(Html_IsWinIE)
event.returnValue=false;
else
event.preventDefault();
DoSendMessage();
return false;
}
}
function InputBoxElement_OnKeyDown(event)
{
event=event||window.event;
if(event.keyCode==9)
{
if(Html_IsWinIE)
event.returnValue=false;
else
event.preventDefault();
DoTabNextUser();
return false;
}
}
/****************************************************************\
MSN Images
\****************************************************************/
//the data map the text to the image index
//http://messenger.msn.com/resource/Emoticons.aspx
var msnimagesarr=[
{i:1,t:":)"},
{i:1,t:":-)"},
{i:2,t:":D"},
{i:2,t:":-D"},
{i:3,t:":O"},
{i:3,t:":-O"},
{i:4,t:":P"},
{i:4,t:":-P"},
{i:5,t:";-)"},
{i:5,t:";)"},
{i:6,t:":-("},
{i:6,t:":("},
{i:7,t:":S"},
{i:7,t:":-S"},
{i:8,t:":|"},
{i:8,t:":-|"},
{i:9,t:":'("},
{i:10,t:":$"},
{i:10,t:":-$"},
{i:11,t:"(H)"},
{i:12,t:":-@"},
{i:12,t:":@"},
{i:13,t:"(A)"},
{i:14,t:"(6)"},
{i:15,t:":-#"},
{i:16,t:"8O|"},
{i:17,t:"8-|"},
{i:18,t:"^O)"},
{i:19,t:":-*"},
{i:20,t:"+O("},
{i:21,t:":^)"},
{i:22,t:"*-)"},
{i:23,t:"");
return true;
}
}
}
}
}
/****************************************************************\
Popups
\****************************************************************/
function ChatUI_ShowColorPanel(img)
{
var chat_forecolor=document.createElement("div");
chat_forecolor.id="chat_forecolor";
Html_SetCssText(chat_forecolor,"position:absolute;z-index:888888;display:none;border:solid 0px #A5B6DE;padding:0px;background-color:#ffffff;");
chat_forecolor.onmousedown=new Function("event","(event||window.event).cancelBubble=true;");
document.body.appendChild(chat_forecolor);
var temp_html = '';
var colors;
//ColorsArray defined in settings.js
try{
}
catch(x)
{
ColorsArray="#000000,#993300,#333300,#003300,#003366,#000080,#333399,#333333,";
ColorsArray=ColorsArray+"#800000,#FF6600,#808000,#008000,#008080,#0000FF,#666699,#808080,";
ColorsArray=ColorsArray+"#FF0000,#FF9900,#99CC00,#339966,#33CCCC,#3366FF,#800080,#999999,";
ColorsArray=ColorsArray+"#FF00FF,#FFCC00,#FFFF00,#00FF00,#00FFFF,#00CCFF,#993366,#C0C0C0,";
ColorsArray=ColorsArray+"#FF99CC,#FFCC99,#FFFF99,#CCFFCC,#CCFFFF,#99CCFF,#CC99FF,#FFFFFF";
}
colors=ColorsArray.split(",");
var total = colors.length;
var width = 8;
temp_html += "";
for (var i=0; i";
temp_html += '';
temp_html += ' ';
temp_html += ' | ';
if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
temp_html += "";
}
}
temp_html += "
";
chat_forecolor.innerHTML=temp_html;
chat_forecolor.style.display='block';
var pos=CalcPosition(chat_forecolor,img);
pos.top-=chat_forecolor.firstChild.offsetHeight;
chat_forecolor.style.left=pos.left+"px";
chat_forecolor.style.top=pos.top-3+"px";
chatui_lastcolorimg=img;
Html_AttachEvent(document,"mousedown",ChatUI_ForeColor_OnDocumentMouseDown);
}
function ChatUI_ForeColor_OnDocumentMouseDown()
{
var chat_forecolor=document.getElementById("chat_forecolor");
document.body.removeChild(chat_forecolor);
Html_DetachEvent(document,"mousedown",ChatUI_ForeColor_OnDocumentMouseDown);
}
var chatui_lastcolorimg=null;
function ChatUI_SetForeColor(color)
{
ChatUI_ForeColor_OnDocumentMouseDown();
chatui_lastcolorimg.style.backgroundColor=color;
SetFontColor(color);
_InvokeChatEvent("UICOMMAND",["UICOMMAND","FOCUSINPUT"]);
}
function ChatUI_ShowEmotionPanel(img)
{
var chat_emotion=document.createElement("div");
chat_emotion.id="chat_emotion";
Html_SetCssText(chat_emotion,"position:absolute;z-index:888888;display:none;left:0px;top:0px;width:200px;height:120px;overflow:visible;");
chat_emotion.onmousedown=new Function("event","(event||window.event).cancelBubble=true;");
document.body.appendChild(chat_emotion);
var temp_html = '';
var emotionURL = '';
// var emotions = new Array("emsmile.gif","emteeth.gif","emwink.gif","emsmileo.gif","emsmilep.gif","emsmiled.gif","emangry.gif","emembarrassed.gif",
// "emcrook.gif","emsad.gif","emcry.gif","emdgust.gif","emangel.gif","emlove.gif","emunlove.gif","emmessag.gif",
// "emcat.gif","emdog.gif","emmoon.gif","emstar.gif","emfilm.gif","emnote.gif","emrose.gif","emrosesad.gif",
// "emclock.gif","emlips.gif","emgift.gif","emcake.gif","emphoto.gif","emidea.gif","emtea.gif","emphone.gif",
// "emhug.gif","emhug2.gif","embeer.gif","emcocktl.gif","emmale.gif","emfemale.gif","emthup.gif","emthdown.gif");
var emotions,emotionsArray;
try{
emotionsArray=EmotionsArray;//defined in setting.js
//throw(new Error("TODO:"));//TODO:emotionsArray
}
catch(x)
{
}
if(emotionsArray==null||emotionsArray.Length==0)
{
emotionsArray="emsmile.gif,emteeth.gif,emwink.gif,emsmileo.gif,emsmilep.gif,emsmiled.gif,emangry.gif,emembarrassed.gif,";
emotionsArray=emotionsArray+"emcrook.gif,emsad.gif,emcry.gif,emdgust.gif,emangel.gif,emlove.gif,emunlove.gif,emmessag.gif,";
emotionsArray=emotionsArray+"emcat.gif,emdog.gif,emmoon.gif,emstar.gif,emfilm.gif,emnote.gif,emrose.gif,emrosesad.gif,";
emotionsArray=emotionsArray+"emclock.gif,emlips.gif,emgift.gif,emcake.gif,emphoto.gif,emidea.gif,emtea.gif,emphone.gif,";
emotionsArray=emotionsArray+"emhug.gif,emhug2.gif,embeer.gif,emcocktl.gif,emmale.gif,emfemale.gif,emthup.gif,emthdown.gif";
}
emotions=emotionsArray.split(",");
var total = emotions.length;
var width = 8;
temp_html += "";
for (var i=0; i";
temp_html += ' | ';
if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
temp_html += "";
}
}
temp_html += "
";
chat_emotion.innerHTML=temp_html;
chat_emotion.style.display='block';
var pos=CalcPosition(chat_emotion,img);
pos.top-=chat_emotion.firstChild.offsetHeight;
chat_emotion.style.left=pos.left+"px";
chat_emotion.style.top=pos.top+"px";
Html_AttachEvent(document,"mousedown",ChatUI_Emotion_OnDocumentMouseDown);
}
function ChatUI_Emotion_OnDocumentMouseDown()
{
var chat_emotion=document.getElementById("chat_emotion");
document.body.removeChild(chat_emotion);
Html_DetachEvent(document,"mousedown",ChatUI_Emotion_OnDocumentMouseDown);
}
function ChatUI_InsertEmotion(emotion)
{
ChatUI_Emotion_OnDocumentMouseDown();
_InvokeChatEvent("UICOMMAND",["UICOMMAND","EMOTION",emotion]);
_InvokeChatEvent("UICOMMAND",["UICOMMAND","FOCUSINPUT"]);
}
function ChatUI_InviteIntoPrivate()
{
Desktop.Prompt(handle,TEXT("UI_SpecifyInviteName"),TEXT("UI_MENU_Invite"),"");
function handle(res)
{
if(res)
{
InviteIntoPrivateChat(res);
}
}
}
function ChatUI_ShowAddContact()
{
//OpenWindowWaitReturn(_ChatUI_ShowAddContact_Return,CuteChatUrlBase+"IM_AddContact.aspx","","resizable=1,status=0,menubar=0,"+GetOpenWindowSizeText(577,390));
function OnPrompt(name)
{
if(name)
{
ChatUI_AddContactByName(name)
}
}
Desktop.Prompt(OnPrompt,TEXT("UI_CONTACT_AddContact_subTitle"),TEXT("UI_MENU_AddContact"));
}
function _ChatUI_ShowAddContact_Return()
{
}
function ChatUI_ShowSkinPanel(img)
{
var total = SkinNames.length;
var width = 2;
var chat_skin=document.createElement("div");
chat_skin.id="chat_skin";
Html_SetCssText(chat_skin,"position:absolute;z-index:888888;display:none;border:solid 1px #3162A6;padding:3px;background-color:#EBF1FC;");
chat_skin.onmousedown=new Function("event","(event||window.event).cancelBubble=true;");
document.body.appendChild(chat_skin);
var html="";
html += "";
for (var i=0; i";
var s_name = CuteChatUrlBase+"Skins/"+SkinNames[i]+".gif";
html += ' | ';
if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
html += "";
}
}
html += "
";
chat_skin.innerHTML=html;
chat_skin.style.display='block';
var pos=CalcPosition(chat_skin,img);
pos.top-=chat_skin.firstChild.offsetHeight+6;
chat_skin.style.left=pos.left+"px";
chat_skin.style.top=pos.top+"px";
Html_AttachEvent(document,"mousedown",ChatUI_Skin_OnDocumentMouseDown);
}
function ChatUI_Skin_OnDocumentMouseDown()
{
var chat_skin=document.getElementById("chat_skin");
document.body.removeChild(chat_skin);
Html_DetachEvent(document,"mousedown",ChatUI_Skin_OnDocumentMouseDown);
}
function ChatUI_ChangeSkin(newskin)
{
var found=false;
for(var i=0;i");
text=text.replace(/(\S+:\/\/\S+)/ig,"$1");
text=ChatUI_TranslateHtml(text);
return text;
}
function ChatUI_TranslateHtml(html)
{
if(html==null)return "";
html=html.replace(/\[Emotion=([^\[\]=\s]+)\]/ig,"");
html=html.replace(/\[MsnImage=([^\[\]=\s]+)\]/ig,"");
return html;
}
function ChatUI_ProcessInnerHTML(element)
{
if(!GlobalAllowOutsiteImage)
{
ChatUI_ProcessInnerHTML_RemoveOutsiteImage(element);
}
}
function ChatUI_ProcessInnerHTML_RemoveOutsiteImage(element)
{
if(element.tagName=="IMG")
{
var url=window.location.href;
var pos1=url.indexOf("://");
var pos2=url.indexOf("/",pos1+4);
if(url.substring(0,pos2).toLowerCase()!=element.src.substring(0,pos2).toLowerCase())
{
var link=document.createElement("A");
link.innerHTML=element.src;
link.target="_blank";
link.href=element.src;
element.parentNode.insertBefore(link,element);
element.parentNode.removeChild(element);
}
return;
}
for(var i=0;i19||img.height>19)
{
img.width="19";
img.height="19";
}
p.appendChild(img);
p.appendChild(document.createTextNode(" "));
}
}
if(where=="USERLIST")
{
var vt=GetItemInfo(user.Guid,"VideoTime")||0;
if( new Date().getTime() - vt < 10000 )
{
img.src=CuteChatUrlBase+"Images/camera.png";
if(!UserEquals(user,GetMyInfo()))
{
img.onclick=function()
{
ChatUI_ShowRecieveVideoWindow(GetPlace().Name,GetItemInfo(user.Guid,"VideoName"),user.DisplayName)
}
}
}
}
}
//if(where!="USERLIST"&&ShowTimeStampBeforeMessage){
// p.appendChild(document.createTextNode(" ("+ new Date().toLocaleTimeString() +") "));
//}
var span=document.createElement("SPAN");
if(UserEquals(user,GetMyInfo()))
{
span.className="You";
span.innerHTML=Html_Encode(user.DisplayName);
ChatUI_SetContextMenu(p,new Function("event","if(Html_FCM(event))ChatUI_ShowMyInfoEvent(event);return false;"));
}
else
{
if(IsContact(user))
span.className="User Contact";
else
span.className="User";
span.innerHTML=Html_Encode(user.DisplayName);
p.style.cursor="hand";
p.onclick=new Function("event","ChatUI_SelectUserExp('"+CodeEncode(ChatUI_UserToExp(user))+"',event)");
p.ondblclick=new Function("event","ChatUI_DoUserDefaultActionExp('"+CodeEncode(ChatUI_UserToExp(user))+"',event)");
ChatUI_SetContextMenu(p,new Function("event","if(Html_FCM(event))ChatUI_ShowUserMenuExp('"+CodeEncode(ChatUI_UserToExp(user))+"',event);return false;"));
}
if(user.IsAdmin)
{
span.className="Admin "+span.className;
}
p.appendChild(span);
//TODO: Double check this
if(where=="USERLIST")
{
switch(user.OnlineStatus)
{
case "OFFLINE":
break;
case "SILENCE"://TODO:silence image;
span.innerHTML+=" "+TEXT("UI_USER_Silence");
break;
case "ONLINE":
span.innerHTML+=" "+TEXT("UI_USER_Online");
break;
case "BUSY":
span.innerHTML+=" "+TEXT("UI_USER_Busy");
break;
case "AWAY":
span.innerHTML+=" "+TEXT("UI_USER_Away");
break;
default:
span.innerHTML+=" "+TEXT("UI_USER_"+user.OnlineStatus);
break;
}
if(user.Level!="Normal"||user.IsAdmin)
{
var img=document.createElement("IMG");
if(user.IsAdmin)
{
img.src=CuteChatUrlBase+"Images/moderator.png";
}
else
{
if(user.Level=="Silence")img.src=CuteChatUrlBase+"Images/silence.gif";
if(user.Level=="VIP")img.src=CuteChatUrlBase+"Images/VIP.gif";
if(user.Level=="Speaker")img.src=CuteChatUrlBase+"Images/speaker.gif";
}
if(img.src)
{
img.align='absmiddle';
if(img.width>19||img.height>19)
{
img.width="19";
img.height="19";
}
p.appendChild(img);
p.appendChild(document.createTextNode(" "));
}
}
}
div.appendChild(p);
}
function ChatUI_AppendInstantUserMessage(div,msg)
{
var className="UserMessage";
var user=msg.Sender;
var table=window.document.createElement("TABLE");
table.border=0;table.cellSpacing=0;table.cellPadding=1;
var tr=table.insertRow(-1);
var td=tr.insertCell(-1);
var td2=tr.insertCell(-1);
var span=document.createElement("SPAN");
span.innerHTML=Html_Encode(user.DisplayName);
td.appendChild(span);
td.width="100%";
td.appendChild(document.createTextNode(" "+TEXT("Says")));
//if(msg.Sender.IsAgent)
//{
// td.className=td2.className="OperatorMessage";
//}
if(UserEquals(user,GetMyInfo()))
{
td.className=td2.className="You";
}
else
{
td.className=td2.className="User";
}
if(ShowTimeStampWebMessenger && msg.ServerTime)
{
if(GetLocation()=="Support")
td2.style.cssText="text-align:right;width:80;white-space:nowrap;font: normal 8pt Arial;color:#999999";
else
td2.style.cssText="text-align:right;width:80;white-space:nowrap;font: normal 8pt Arial;";
var span2=document.createElement("SPAN");
span2.innerHTML=ChatUI_FormatTime(msg.ServerTime)+" ";
span2.style.float="right";
td2.appendChild(span2);
}
tr=table.insertRow(-1);
td=tr.insertCell(-1);
td.style.padding="4px";
td.style.paddingLeft="10px";
if(msg.Html)
{
td.innerHTML=ChatUI_TranslateHtml(msg.Html);
}
else
{
td.innerHTML=ChatUI_TranslateText(msg.Text);
}
if(UserEquals(msg.Sender,GetMyInfo()))
{
className+=" MyMessage";
}
if(msg.Sender.IsAgent)
{
className+=" OperatorMessage";
}
if(msg.Offline)
{
className+=" OfflineMessage";
}
td.className=className;
td.colSpan=2;
ChatUI_ProcessInnerHTML(td);
if(msg.Font)
{
if(msg.Font.Bold)td.style.fontWeight='bold';
if(msg.Font.Italic)td.style.fontStyle='italic';
if(msg.Font.Underline)td.style.textDecoration='underline';
if(msg.Font.FontName)td.style.fontFamily=msg.Font.FontName;
if(msg.Font.FontSize)td.style.fontSize=msg.Font.FontSize;
if(msg.Font.FontColor)td.style.color=msg.Font.FontColor;
}
div.appendChild(table);
}
function ChatUI_AppendMessage(div,msg,mode)
{
ChatUI_AppendMessage_Core(div,msg,mode);
var images=[];
function FindNodes(node)
{
if(node.nodeName=="IMG")
images.push(node);
var l=node.childNodes.length;
for(var i=0;i Instant Chat
if(mode=="INSTANTMAIN" || mode=="INSTANTCHAT")
{
if(mode=="INSTANTMAIN" && msg.Sender.DisplayName==GetMyInfo().DisplayName )
{
td.appendChild(document.createTextNode(TEXT("MSG_TO")));
ChatUI_AppendUser(td,msg.Target,mode)
}
}
else
{
if(msg.Whisper)
td.appendChild(document.createTextNode(TEXT("WHISPER_TO")));
else
td.appendChild(document.createTextNode(TEXT("MSG_TO")));
ChatUI_AppendUser(td,msg.Target,mode)
}
}
}
td.appendChild(document.createTextNode(": "));
td=tr.insertCell(-1);
td.style.verticalAlign="top";
if(msg.Html)
td.innerHTML=ChatUI_TranslateHtml(msg.Html);
else
td.innerHTML=ChatUI_TranslateText(msg.Text);
ChatUI_ProcessInnerHTML(td);
if(msg.Font)
{
if(msg.Font.Bold)td.style.fontWeight='bold';
if(msg.Font.Italic)td.style.fontStyle='italic';
if(msg.Font.Underline)td.style.textDecoration='underline';
if(msg.Font.FontName)td.style.fontFamily=msg.Font.FontName;
if(msg.Font.FontSize)td.style.fontSize=msg.Font.FontSize;
if(msg.Font.FontColor)td.style.color=msg.Font.FontColor;
}
table.className=className;
div.appendChild(table);
break;
case "ANNOUNCEMENT":
case "SYS_INFO":
case "SYS_ERROR":
var span=document.createElement("span");
if(msg.Html)
{
span.innerHTML=msg.Html;
}
else
{
var text=window["TEXT_SYS_"+msg.Text];
if(!text)
{
text=ChatUI_TranslateText(msg.Text);
}
else if(msg.Arguments)
{
for(var i=1;i=0;i--)
{
coll.item(i).parentNode.removeChild(coll.item(i));
}
var win;
try
{
var d=new Date();
var ds=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+"--"+d.getHours()+"-"+d.getMinutes();
win=open(CuteChatUrlBase+"SaveTemplate.aspx/ChatLog"+ds+".htm","CCS"+new Date().getTime()
,"resizable=1,menubar=1,toolbar=0,statusbar=0,width=1,height=1");
setTimeout(TestDocumentReady,1);
}
catch(x)
{
alert(x.message);
}
function TestDocumentReady()
{
if(win.closed)return;
if(win.document==null||win.document.getElementById("chat_messagelist")==null)
{
setTimeout(TestDocumentReady,1);
return;
}
win.document.getElementById("chat_messagelist").innerHTML=target.innerHTML;
setTimeout(Rewrite,1);
}
function Rewrite()
{
if(Html_IsWinIE)
{
win.execScript(RewriteInNewWindow+"");//copy script into win
win.execScript("setTimeout(RewriteInNewWindow,1);");
}
else
{
var form1=win.document.getElementById("form1");
var chat_messagelist=win.document.getElementById("chat_messagelist")
form1.input1.value=chat_messagelist.innerHTML;
form1.submit();
}
}
function RewriteInNewWindow()
{
var html=document.documentElement.outerHTML;
document.open("text/html");
document.write(html);
document.close();
document.execCommand("SaveAs",true,null);
top.close();
}
}
/****************************************************************\
Manage the IM Conversitions
\****************************************************************/
var CHATUI_COOKIETIMEOUT=3;
function ChatUI_IMDeclareMainForm()
{
if(GetCookie("CuteChatIMMainForm")=="Activate")
{
window.focus();
}
SetCookie("CuteChatIMMainForm","Here",CHATUI_COOKIETIMEOUT);
}
function ChatUI_IMHasMainForm()
{
return GetCookie("CuteChatIMMainForm");
}
function ChatUI_IMActivateMainForm()
{
if(GetCookie("CuteChatIMMainForm"))//Here or Activate
{
SetCookie("CuteChatIMMainForm","Activate",CHATUI_COOKIETIMEOUT);
}
}
function ChatUI_IMOpenMainForm() //need event to prevent popup blocker
{
if(GetCookie("CuteChatIMMainForm"))//Here or Activate
{
SetCookie("CuteChatIMMainForm","Activate",CHATUI_COOKIETIMEOUT);
return true;
}
else
{
var url=__cc_urlbase+"Messenger.aspx?_t"+(new Date().getTime());
var win;
try
{
win=window.open(url,"",'status=1,width=300,height=500,resizable=1');
}
catch(x)
{
}
if(win==null)
{
throw(new Error(TEXT("UI_PopupBlocked")));
}
}
}
function ChatUI_IMUnloadMainForm()
{
SetCookie("CuteChatIMMainForm","",-1);
}
//By Cookie
function ChatUI_IMCheckCookie()
{
setTimeout(ChatUI_IMCheckCookie,500);
_InvokeChatEvent("IMCOOKIE",["IMCOOKIE","DOUPDATE"]);
_InvokeChatEvent("CONVERSATION",["CONVERSATION","RELIST"]);
}
setTimeout(ChatUI_IMCheckCookie,500);
/****************************************************************\
Convert The Event To Message..
\****************************************************************/
var _connectionReadyCount=0;
var _retryConnectionTimes=0;
function ChatUI_HANDLE_EVENT_CONNECTION(name,type,info1,info2)
{
var msghtml=null;
switch(type)
{
case "CONNECTING":
if(_retryConnectionTimes==0)
msghtml=TEXT("UI_CONNECTION_CONNECTING");
break;
case "ERROR":
_retryConnectionTimes++;
if(_retryConnectionTimes<5)
{
setTimeout(Connect,100);
}
else
{
_retryConnectionTimes=0;
msghtml=TEXT("UI_CONNECTION_ERROR",info1);
}
break;
case "READY":
_connectionReadyCount++;
if(_retryConnectionTimes==0)
msghtml=TEXT("UI_CONNECTION_READY");
_retryConnectionTimes=0;
break;
case "CANCELLED":
msghtml=TEXT("UI_CONNECTION_CANCELLED");
break;
case "NOTENABLE":
msghtml=TEXT("UI_CONNECTION_NOTENABLE");
break;
case "NEEDLOGIN":
msghtml=TEXT("UI_CONNECTION_NEEDLOGIN");
Desktop.Alert(null,TEXT("UI_CONNECTION_NEEDLOGIN"),TEXT("UI_ALERT"));
break;
case "NEEDNAME":
Desktop.Prompt(ChatUI_HANDLE_EVENT_CONNECTION_NAME,TEXT("UI_CONNECTION_NeedName_Message")+(info1?(" : ("+info1+")"):""),TEXT("UI_CONNECTION_NeedName_Title"));
break;
case "KICK":
msghtml=TEXT("UI_CONNECTION_Kick");
break;
case "LOCKED":
msghtml=TEXT("UI_CONNECTION_Locked");
break;
case "REACHMAX":
msghtml=TEXT("UI_CONNECTION_ReachMax");
break;
case "NEEDPASSWORD":
msghtml=TEXT("UI_CONNECTION_NeedPassword");
Desktop.Prompt(ChatUI_HANDLE_EVENT_CONNECTION_PASSWORD,TEXT("UI_CONNECTION_NeedPassword_Message"),TEXT("UI_CONNECTION_NeedPassword_Title"));
break;
case "DISCONNECT":
msghtml=TEXT("UI_CONNECTION_Disconnect");
break;
case "KICK":
msghtml=TEXT("UI_CONNECTION_KICK");
break;
case "REJECTED":
msghtml=TEXT("UI_CONNECTION_REJECTED");
break;
case "REMOVED":
msghtml=TEXT("UI_CONNECTION_REMOVED");
Desktop.Confirm(function(res){if(res)Connect()},msghtml,null,TEXT("UI_MENU_Connect"),TEXT("Cancel"));
break;
case "NOCONNECTION":
msghtml=TEXT("UI_CONNECTION_NOCONNECTION");
setTimeout(Connect,100);
break;
default:
msghtml=TEXT("UI_CONNECTION_"+type);
break;
}
if(msghtml)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="Connection";
msg.Html=""+msghtml;
FireMessage(msg);
}
ChatUI_FocusWindow();
}
function ChatUI_HANDLE_EVENT_CONNECTION_NAME(name)
{
if(name==null)return;
try
{
SetGuestName(name);
}
catch(x)
{
//TODO:OK, the name is wrong , tell the user type the name again
Desktop.Prompt(ChatUI_HANDLE_EVENT_CONNECTION_NAME,TEXT("UI_CONNECTION_NeedName_Message"),TEXT("UI_CONNECTION_NeedName_Title")+":"+x.message);
return;
}
Connect();
}
function ChatUI_HANDLE_EVENT_CONNECTION_PASSWORD(password)
{
if(password==null)return;
SetPassword(password);
Connect();
}
function ChatUI_HANDLE_EVENT_USER(name,type,user,info2,info3)
{
var showjoinleavemsg=ShowJoinLeaveMessage;
if(GetLocation()!="Lobby")showjoinleavemsg=true;
var msgtext=null;
switch(type)
{
case "ADDED":
if(UserEquals(GetMyInfo(),user))
{
if(!user.Moderated)
{
Desktop.Alert(null,TEXT("UI_AdminLockRoom"),"Moderated");
}
return;
}
if(chatvars.connectedtime&&new Date().getTime()-chatvars.connectedtime>3000)
{
if(showjoinleavemsg)
{
ChatUI_PlaySound("ChatJoin");
msgtext=TEXT("UI_USER_"+type,user.DisplayName);
}
}
if(!user.Moderated)
{
//if I am moderator
if(GetMyInfo().IsModerator)
{
function HandleModerateUserJoin(res)
{
if(res)
{
AdminAcceptUser(user);
}
else
{
AdminRejectUser(user);
}
}
Desktop.Confirm(HandleModerateUserJoin,TEXT("UI_USER_JOIN_MODERATE",user.DisplayName)
,user.DisplayName);
}
}
break;
case "REMOVED":
if(showjoinleavemsg)
{
ChatUI_PlaySound("Online");
msgtext=TEXT("UI_USER_"+type+"_"+user.RemoveReason,user.DisplayName);
}
break;
case "UPDATED":
break;
case "RENAME":
//info2 - newname
msgtext=TEXT("UI_USER_"+type,user.DisplayName,info2);
break;
}
if(msgtext)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="System";
msg.Text=msgtext;
FireMessage(msg);
}
}
function ChatUI_HANDLE_EVENT_RAWSTCMSG(name,type,info1,info2)
{
var msgtext=null;
switch(type)
{
case "CONTACT_ADDED":
msgtext=TEXT("UI_CONTACT_ADDED",info1[0]);
break;
case "CONTACT_REMOVED":
msgtext=TEXT("UI_CONTACT_REMOVED",info1[0]);
break;
case "IGNORE_ADDED":
msgtext=TEXT("UI_IGNORE_ADDED",info1[0]);
break;
case "IGNORE_REMOVED":
msgtext=TEXT("UI_IGNORE_REMOVED",info1[0]);
break;
case "PLACE_AUTOAWAYMINUTE":
CHATUI_AUTOAWAYTIMEOUT=parseInt(info1[0])*60
break;
case "SYS_ALERT_MESSAGE":
msgtext=TEXT(info1[0],info1[1]);
break;
}
if(msgtext)
{
Desktop.Alert(null,msgtext);
}
}
function ChatUI_HANDLE_EVENT_MESSAGE(name,type,msg,emotion)
{
if(msg.Sender && IsBlock(msg.Sender))return;
if(type=="DOEMOTE")
{
switch(emotion)
{
case "BUZZ":
if(GetLocation()=="Support")
{
ChatUI_PlayBuzz();
return;
}
//othercase processed in messenger code.
break;
}
}
if(UserEquals(GetMyInfo(),msg.Sender))return;
if(msg.ServerTime)
{
var time=msg.ServerTime.getTime();
if(time+120000 > new Date().getTime())
{
ChatUI_PlaySound("type");
}
}
if(msg.Type!="LOCAL" && !IsMessenger())
{
ChatUI_FocusWindow();
}
}
function ChatUI_HANDLE_EVENT_ITEM(evt,msgid,newitem,olditem)
{
if(newitem.Type=="PRIVATEINVITE" && msgid=="ADDED")
{
function DoAccept()
{
AcceptPrivateChat(newitem)
var placename=newitem.Args[3];
OpenWindowAsync(null,CuteChatUrlBase+"Channel.aspx?Place="+placename,"","status=0,width=560,height=400,resizable=1");
}
function HandleInvite(res)
{
if(res)
{
DoAccept();
}
else
{
RejectPrivateChat(newitem)
}
}
var userid=newitem.Args[4];
if(userid==GetMyInfo().UserId)
{
try
{
DoAccept();
return;
}
catch(x)
{
//blocked.
}
}
else
{
var user=GetUserById(userid);
if(user && IsBlock(user))
{
RejectPrivateChat(newitem)
return;
}
}
Desktop.Confirm(HandleInvite,TEXT("UI_INVITEPRIVATECHAT",newitem.Args[5]),TEXT("UI_InvitePrivate"))
}
}
function ChatUI_HANDLE_EVENT_PLACE(name,type,newplace,oldplace)
{
if(oldplace==null)
{
function ShowMessageLater()
{
if(newplace.Locked)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="System";
msg.Text=TEXT("UI_AdminLockRoom");
FireMessage(msg);
}
if(newplace.ModerateMode)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="System";
msg.Text=TEXT("UI_AdminModerateModeEntering");
FireMessage(msg);
}
}
setTimeout(ShowMessageLater,1000);
}
else
{
if(newplace.Locked!=oldplace.Locked)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="System";
if(newplace.Locked)
msg.Text=TEXT("UI_AdminLockRoom");
else
msg.Text=TEXT("UI_AdminUnLockRoom");
FireMessage(msg);
}
if(newplace.ModerateMode!=oldplace.ModerateMode)
{
var msg={};
msg.Type="LOCAL";
msg.MessageCss="System";
if(newplace.ModerateMode)
msg.Text=TEXT("UI_AdminModerateModeStart");
else
msg.Text=TEXT("UI_AdminModerateModeEnd");
FireMessage(msg);
}
}
}
function ChatUI_HANDLE_EVENT_MYINFO(name,type)
{
if(type=="UPDATED")
{
if(GetMyInfo().IsAnonymous)
{
SetCookie("CCGuestName",GetMyInfo().DisplayName);
}
}
}
AttachChatEvent("ITEM",ChatUI_HANDLE_EVENT_ITEM);
AttachChatEvent("CONNECTION",ChatUI_HANDLE_EVENT_CONNECTION);
AttachChatEvent("MESSAGE",ChatUI_HANDLE_EVENT_MESSAGE);
AttachChatEvent("USER",ChatUI_HANDLE_EVENT_USER);
AttachChatEvent("RAWSTCMSG",ChatUI_HANDLE_EVENT_RAWSTCMSG);
AttachChatEvent("PLACE",ChatUI_HANDLE_EVENT_PLACE);
AttachChatEvent("MYINFO",ChatUI_HANDLE_EVENT_MYINFO);
if(GetCookie("CCGuestName"))
{
//SetGuestName(GetCookie("CCGuestName"));
chatclient.guestname=GetCookie("CCGuestName")
}
//
function ChatUI_AddContactByName(username)
{
if(!IsConnected())return;
var message=JoinToMsg("USER_APPCOMMAND",null,["ADDCONTACTBYNAME",username]);
PushCTSMessage(message);
}
var _lastActiveTime=new Date().getTime();
var _lastIsAutoAway=false;
function ChatUI_HandleDocEvent()
{
_lastActiveTime=new Date().getTime();
var autoRestoreOnline=true;
var myinfo=GetMyInfo();
if(myinfo==null)return;
if(_lastIsAutoAway && autoRestoreOnline)
{
if(myinfo.OnlineStatus=="AWAY")
{
SetOnlineStatus("ONLINE");
}
}
_lastIsAutoAway=false;
}
function CheckAway()
{
//TODO:myinfo.PrivateProperties["AutoAwayTimeout"]
if(!IsConnected())
{
_lastActiveTime=new Date().getTime();
return;
}
var span=new Date().getTime()-_lastActiveTime
if(span'
+''
+''
+'';
data.flash=ChatUI_GetFlashObject(data.element.firstChild);
setTimeout(function()
{
data.flash.SetVariable("FlashChatServer",ChatUI_GetVideoUrl(channel));
data.flash.SetVariable("VideoName",vn);
},500)
cc_videomap[vn]=data;
data.onrelease=function()
{
if(data.targets)
{
for(var i=0;i'
+''
+''
+''
+(winmode?"":(''));
data.flash=ChatUI_GetFlashObject(data.element.firstChild);
setTimeout(function()
{
data.flash.SetVariable("FlashChatServer",ChatUI_GetVideoUrl(channel));
data.flash.SetVariable("VideoName",vn);
},500)
if(!winmode)
{
data.element.onmousedown=function(event)
{
event=window.event||event;
if(event.button!=1)return;
data.element.onmousedown=new Function("","");
data.onrelease=null;
ChatUI_StopRecieveVideo(vn);
var img=document.createElement("IMG");
img.src=CuteChatUrlBase+"Images/webcam.png";
img.style.margin=parseInt((width-48)/2)+"px";
container.appendChild(img);
data=ChatUI_ShowRecieveVideoWindow(channel,vn,title,function()
{
if(onrelease)onrelease();
container.removeChild(img);
});
}
}
cc_videomap[vn]=data;
return data;
}
function ChatUI_ShowRecieveVideoWindow(channel,vn,title,onrelease)
{
var data=cc_videomap[vn];
if(data)return;
var container;
var win=new CuteWebUI.HTML.Window({
onresize:function()
{
if(!data)return;
data.element.style.width=container.style.width
data.element.style.height=container.style.height
data.element.firstChild.style.width=container.style.width
data.element.firstChild.style.height=container.style.height
}
,
onclose:function()
{
if(!data)return;
data.disposed=true;
cc_videomap[vn]=null;
ChatUI_DisposeVideoObject(data);
if(onrelease)onrelease();
}
});
container=win.GetContentElement();
win.SetTitle(title);
win.SetWidth(350);
win.SetHeight(290);
//alert([container.offsetWidth,container.offsetHeight])
data=ChatUI_RecieveVideo(channel,vn,title,container,container.offsetWidth,container.offsetHeight,function(){
win.Close();
},true);
}
function ChatUI_StopPublishVideo(messengerTarget)
{
if(messengerTarget)
{
var vn=ChatUI_GetVideoName("Unique");
var data=cc_videomap[vn];
if(data)
{
if(data.targets)
{
for(var i=0;i5000)
{
data.notifyalivetime=time;
if(data.targets)
{
for(var i=0;i