var CHATUI_DEBUG=false; var CHATUI_MAX_MESSAGE_ITEM_COUNT=500; var chatui_random=__cc_version; if(CHATUI_DEBUG)chatui_random=Math.random(); function LoadSkinClasses(skin,layout) { _SL_ParseXml(_SL_LoadXmlDocument(__cc_urlbase+"Skins/"+SkinName+"/"+layout),null); } function LoadChatClasses(url) { var lower=url.toLowerCase(); if(lower.substr(0,1)!="/"&&lower.substr(0,4)!="http") { url=__cc_urlbase+url } return _SL_LoadXmlDocument(url); } function m_over(element) { element.className='buttonover'; } function m_out(element) { element.className='button'; } function ChatUI_ShowHelp() { OpenWindowAsync(null,"Help/"); } function ChatUI_ShowMessengerHelp() { OpenWindowAsync(null,"messenger-user-guide/"); } function HelpSplashCommandHandler() { //TODO:change the help text var msg={}; msg.MessageType="LOCAL"; msg.MessageText="SUPPORT COMMANDS"; for(var key in CHATUI_SPLASHCOMMANDS) { msg.MessageText+="\r\n /"+key; } _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",msg]); return true; } var CHATUI_SPLASHCOMMANDS= { "HELP":HelpSplashCommandHandler , "HELPURL":function(){ChatUI_ShowHelp("COMMAND");return true;} , "ADMIN":AdminSplashCommandHandler , "AVATAR":function(){ChatUI_ShowAvatarDialog();return true;} , "AVATARS":function(){ChatUI_ShowAvatarDialog();return true;} , "DISCONNECT":function(){Disconnect();return true;} , "CONNECT":function(){Connect();return true;} , "QUIT":function(){Disconnect();if(window.opener){window.close()}else{ChatUI_QuitRedirect()};return true;} , "MSG":function(name){ if(name){InvitePrivateChat(name);return true;}else{return false;} } , "INVITE":function(name){ if(name){InviteIntoPrivate(name);return true;}else{return false;} } , "HELLO"://sample { Arg0:"%ME Say Hello To Every Body!!" , Arg1:"%ME Say Hello To {0}" , Arg2:function() { var args=new Array(); for(var i=0;inew Date().getTime()) return; _lastsoundplaytime=new Date().getTime(); //TODO: FireFox doesn't work.. var bgsound=document.createElement("BGSOUND"); document.body.appendChild(bgsound); bgsound.loop=1; bgsound.src=soundfile; //remove it 5 second later function RemoveBGSound() { bgsound.parentNode.removeChild(bgsound); } setTimeout(RemoveBGSound,5000); } function ChatUI_SetEnableSound(enable) { enable=_SL_ToBoolean(enable); if(enable) { SetCookie("CCNoSound","false",-1); } else { SetCookie("CCNoSound","true",3600*24*365); } } function ChatUI_GetEnableSound() { var v=GetCookie("CCNoSound"); if(v=="true") return false; return true; //default allow sound.. } function ChatUI_FocusWindow() { if( GetWindowIsFocus() ) return; if( ! ChatUI_GetAutoFocus() ) return; //alert(GetStackTrace()); FocusWindow(); } function ChatUI_SetAutoFocus(enable) { enable=_SL_ToBoolean(enable); if(enable) { SetCookie("CCNoFocus","false",-1); } else { SetCookie("CCNoFocus","true",3600*24*365); } } function ChatUI_GetAutoFocus() { var v=GetCookie("CCNoFocus"); if(v=="true") return false; return true; //default allow sound.. } var chatui_sendmsgtimes=[]; var chatui_floodmsgsend=false; function ChatUI_CheckFloodControl() { var count = 5; var maxms = 10 * 1000; if(chatui_sendmsgtimes.length>=count) { var timespan=new Date().getTime()-chatui_sendmsgtimes[chatui_sendmsgtimes.length-count]; if(timespan < maxms) { if(!chatui_floodmsgsend) { var floodmsg={}; floodmsg.MessageType="LOCAL"; floodmsg.MessageText=TEXT("UI_FloodControlMessage"); _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",floodmsg]); 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; } 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 sended=SendEmotion(text); if(sended) { chatui_sendmsgtimes[chatui_sendmsgtimes.length]=new Date().getTime(); } return sended; } function ChatUI_HandleSplashCommand(text) { var arr=text.split(/\s+/g); var cmd=CHATUI_SPLASHCOMMANDS[arr[0].toUpperCase()]; if(cmd==null) { Desktop.Alert(null,TEXT("UI_UnknownSplashCommand",arr[0])); return false; } arr.shift();//remove first //remove blank string 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;j"); 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 1px #3162A6;padding:3px;background-color:#ffffff;"); chat_forecolor.onmousedown=new Function("event","(event||window.event).cancelBubble=true;"); document.body.appendChild(chat_forecolor); var temp_html = ''; var colors = new Array("#000000","#993300","#333300","#003300","#003366","#000080","#333399","#333333", "#800000","#FF6600","#808000","#008000","#008080","#0000FF","#666699","#808080", "#FF0000","#FF9900","#99CC00","#339966","#33CCCC","#3366FF","#800080","#999999", "#FF00FF","#FFCC00","#FFFF00","#00FF00","#00FFFF","#00CCFF","#993366","#C0C0C0", "#FF99CC","#FFCC99","#FFFF99","#CCFFCC","#CCFFFF","#99CCFF","#CC99FF","#FFFFFF"); var total = colors.length; var width = 8; temp_html += ""; for (var i=0; i'; 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; chat_forecolor.style.top=pos.top-8; 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 total = emotions.length; var width = 8; temp_html += ""; for (var i=0; i'; 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; chat_emotion.style.top=pos.top; 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"),"Invite",""); function handle(res) { if(res) { InviteIntoPrivate(res); } } } function ChatUI_ShowAddContact() { //TODO: OpenWindowWaitReturn(_ChatUI_ShowAddContact_Return,CuteChatUrlBase+"IM_AddContact.aspx","" ,"resizable=1,status=0,menubar=0,"+GetOpenWindowSizeText(577,390)); } 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'; 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; chat_skin.style.top=pos.top; 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) { ChatUI_Skin_OnDocumentMouseDown(); 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_ContactToExp(contact) { var exp=contact.UserId+":"+contact.DisplayName; if(!chatvars._ui_contactcache)chatvars._ui_contactcache={}; chatvars._ui_contactcache[exp]=contact; return exp; } function ChatUI_ContactFromExp(exp) { var pos=exp.indexOf(":"); var userid=parseInt(exp.substr(0,pos)); var username=exp.substring(pos+1); //return the data from Chat.js as much as possible var contacts=GetContactArrary(); for(var i=0;i19||img.height>19) { img.width="19"; img.height="19"; } p.appendChild(img); p.appendChild(document.createTextNode(" ")); } } 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)")); } 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);")); } if(user.IsAdmin) { span.className="Admin "+span.className; } //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; } } p.appendChild(span); div.appendChild(p); } function ChatUI_AppendMessage(div,msg,mode) { //mode - GENERAL,INSTANTMAIN,INSTANTCHAT switch(msg.MessageType) { case "EMOTION": var className="EmotionMessage"; 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); if(msg.Sender.DisplayName==GetMyInfo().DisplayName) { className+=" MyMessage"; } ChatUI_AppendUser(td,msg.Sender); if(mode=="INSTANTMAIN" && msg.Sender.DisplayName==GetMyInfo().DisplayName ) { td.appendChild(document.createTextNode(TEXT("MSG_TO"))); ChatUI_AppendUser(td,msg.ToUser) } td.appendChild(document.createTextNode(" - ")); td=tr.insertCell(-1); td.innerHTML=Html_Encode(msg.MessageText); table.className=className; div.appendChild(table); break; case "USER": var className="UserMessage"; if(msg.Whisper&&mode=="GENERAL") className="WhisperUserMessage"; 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); if(msg.Sender.DisplayName==GetMyInfo().DisplayName) { className+=" MyMessage"; } if(UserToUser(msg.Sender).IsOperator) { className+=" OperatorMessage"; } ChatUI_AppendUser(td,msg.Sender); if(msg.ToUser&&msg.ToUser.DisplayName) { //if(GetChannel().ChannelId!=0)//ChannelId==0 -> 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.ToUser) } } else { if(msg.Whisper) td.appendChild(document.createTextNode(TEXT("WHISPER_TO"))); else td.appendChild(document.createTextNode(TEXT("MSG_TO"))); ChatUI_AppendUser(td,msg.ToUser) } } td.appendChild(document.createTextNode(": ")); td=tr.insertCell(-1); if(msg.MessageHtml) td.innerHTML=ChatUI_TranslateHtml(msg.MessageHtml); else td.innerHTML=ChatUI_TranslateText(msg.MessageText); 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 "SYSTEM": var span=document.createElement("span"); if(msg.MessageHtml) span.innerHTML=msg.MessageHtml; else span.innerHTML=ChatUI_TranslateText(msg.MessageText); span.className="System" div.appendChild(span); break; case "LOCAL": //for example - ChatUI_SendMessageWithFloodControl var span=document.createElement("span"); if(msg.MessageHtml) span.innerHTML=msg.MessageHtml; else span.innerHTML=ChatUI_TranslateText(msg.MessageText); if(msg.MessageCss) span.className=msg.MessageCss; div.appendChild(span); break; default: var span=document.createElement("span"); span.innerHTML=msg.MessageType+" : "+msg.MessageHtml||Html_Encode(msg.MessageText); div.appendChild(span); break; } if( (!GetWindowIsFocus()) && ChatUI_GetAutoFocus()) { ChatUI_PlaySound("sound/alert.wav"); ChatUI_FocusWindow(); } } var ConnectionRetryCount=0; /****************************************************************\ Convert The Event To Message.. \****************************************************************/ function ChatUI_HANDLE_EVENT_CONNECTION(name,type,info1,info2) { var msghtml=null; switch(type) { case "CONNECTING": if(ConnectionRetryCount==0) msghtml=TEXT("UI_CONNECTION_Connecting"); break; case "ERROR": ConnectionRetryCount++; if(ConnectionRetryCount<10) { setTimeout(Connect,100); } else { ConnectionRetryCount=0; msghtml=TEXT("UI_CONNECTION_Error",info1); } break; case "READY": if(ConnectionRetryCount==0) msghtml=TEXT("UI_CONNECTION_Ready"); break; case "CANCELLED": msghtml=TEXT("UI_CONNECTION_Cacelled"); break; case "NOTENABLE": msghtml=TEXT("UI_CONNECTION_NotEnable"); break; case "NOTLOGIN": //Michael Khalili edit for an html prompt with more specific info 11/17/2008 msghtml="Login to join the chat
No account? Register new account" Desktop.Alert(null,msghtml,""); break; // msghtml=TEXT("UI_CONNECTION_NotLogin"); // Desktop.Alert(null,TEXT("UI_CONNECTION_NotLogin"),""); // break; case "NEEDNAME": // msghtml=TEXT("UI_CONNECTION_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; } if(msghtml) { var msg={}; msg.MessageType="LOCAL"; msg.MessageCss="Connection"; msg.MessageHtml=msghtml; _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",msg]); } } 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) { var msghtml=null; switch(type) { case "JOIN": case "LEAVE": case "KICK": case "DROP": ChatUI_PlaySound("Sound/online.wav"); ChatUI_FocusWindow(); //UI_USER_JOIN //UI_USER_LEAVE //UI_USER_KICK //UI_USER_DROP msghtml=TEXT("UI_USER_"+type,user.DisplayName); break; case "UPDATE": break; } if(msghtml) { var msg={}; msg.MessageType="LOCAL"; msg.MessageCss="User"; msg.MessageHtml=msghtml; _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",msg]); } } function ChatUI_HANDLE_EVENT_CONTACT(name,type,contact,info2) { var msghtml=null; switch(type) { case "JOIN": case "LEAVE": case "KICK": case "DROP": break; case "UPDATE": break; } if(msghtml) { var msg={}; msg.MessageType="LOCAL"; msg.MessageCss="Contact"; msg.MessageHtml=msghtml; _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",msg]); } } function ChatUI_HANDLE_EVENT_COMMAND(name,type,info1,info2) { switch(type) { case "NEW": ChatUI_HandleServerCommand(info1); break; } } function ChatUI_HandleServerCommand(cmd) { _Trace("COMMAND "+cmd.Name+":"+cmd.Arguments); switch(cmd.Name) { case "INVITEPRIVATECHAT": Desktop.Confirm(ChatUI_InvitePrivateChatConfirm,TEXT("UI_INVITEPRIVATECHAT",cmd.Arguments[0])); break; case "PRIVATECHATREADY": ChatUI_ShowPrivateChatWindow(cmd); break; case "SENDFILE": var sendername=cmd.Arguments[0]; var fileid=cmd.Arguments[1]; var downloadid=cmd.Arguments[2]; var filename=cmd.Arguments[3]; var filesize=cmd.Arguments[4]; filesize=Math.floor(filesize/1024)+"KB"; var msg={}; msg.MessageType="LOCAL"; msg.MessageCss="SendFile"; msg.MessageHtml=Html_Encode(sendername) +" has uploaded a new file : "+Html_Encode(filename)+" ("+filesize+") "; _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",msg]); break; } } function ChatUI_InvitePrivateChatConfirm(ok) { if(ok) AcceptPrivateChat(); else RejectCurrentCommand(); } function ChatUI_ShowPrivateChatWindow(cmd) { var channelid=cmd.Arguments[0]; var locationid=cmd.Arguments[1]; function Show() { try { var win=window.open(CuteChatUrlBase+"CH_MainForm.Aspx?Location=Private&LocationId="+locationid,null,"status=1,width=560,height=400,resizable=1"); if(win==null)throw(new Error("blocked")); } catch(x) { ChatUI_PlaySound("sound/alert.wav"); ChatUI_FocusWindow(); Desktop.Alert(Show,TEXT("UI_WindowBlocked")); } } Show(); } function ChatUI_HANDLE_EVENT_SENDMESSAGE(name,type,msgitem) { switch(type) { case "SENDASOFFLINE": var localmsg={}; localmsg.MessageType="LOCAL"; localmsg.MessageText=TEXT("UI_SendAsOffline"); _InvokeChatEvent("MESSAGE",["MESSAGE","NEW",localmsg]); break; } } AttachChatEvent("CONNECTION",ChatUI_HANDLE_EVENT_CONNECTION); AttachChatEvent("USER",ChatUI_HANDLE_EVENT_USER); AttachChatEvent("CONTACT",ChatUI_HANDLE_EVENT_CONTACT); AttachChatEvent("COMMAND",ChatUI_HANDLE_EVENT_COMMAND); AttachChatEvent("SENDMESSAGE",ChatUI_HANDLE_EVENT_SENDMESSAGE); /****************************************************************\ Manage the IM Conversitions \****************************************************************/ function ChatUI_IMOpenConversationExp(exp) { var contact=ChatUI_ContactFromExp(exp); if(contact==null)return; ChatUI_IMOpenConversation(contact.UserId,contact.DisplayName); } 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+"IM_MainForm.Aspx?_t"+(new Date().getTime()); var win; try { win=window.open(url,"",'status=1,width=260,height=450,resizable=1'); } catch(x) { } if(win==null) { throw(new Error(TEXT("UI_PopupBlocked"))); } } } function ChatUI_IMUnloadMainForm() { SetCookie("CuteChatIMMainForm","",-1); } function ChatUI_IMDeclareConversation(userid,username) { userid=parseInt(userid)||0; var key="CuteChatIMChatForm"+(userid?("_"+userid):("-"+escape(username))); if(GetCookie(key)=="Activate") { window.focus(); } SetCookie(key,"Here",CHATUI_COOKIETIMEOUT); } function ChatUI_IMHasConversation(userid,username) { userid=parseInt(userid)||0; var key="CuteChatIMChatForm"+(userid?("_"+userid):("-"+escape(username))); return GetCookie(key); } function ChatUI_IMActivateConversation(userid,username) { userid=parseInt(userid)||0; var key="CuteChatIMChatForm"+(userid?("_"+userid):("-"+escape(username))); if(GetCookie(key)) { SetCookie(key,"Activate",CHATUI_COOKIETIMEOUT); } } function ChatUI_IMOpenConversation(userid,username) { userid=parseInt(userid)||0; var key="CuteChatIMChatForm"+(userid?("_"+userid):("-"+escape(username))); if(GetCookie(key)) { SetCookie(key,"Activate",CHATUI_COOKIETIMEOUT); } else { var url=__cc_urlbase+"IM_ChatForm.Aspx?UserId="+userid+"&DisplayName="+escape(username)+"&_t"+(new Date().getTime()); var win; try { win=window.open(url,"conversation"+userid,'status=1,width=560,height=400,resizable=1'); } catch(x) { } if(win==null) { throw(new Error(TEXT("UI_PopupBlocked"))); } } } function ChatUI_IMUnloadConversation(userid,username) { userid=parseInt(userid)||0; var key="CuteChatIMChatForm"+(userid?("_"+userid):("-"+escape(username))); SetCookie(key,"Unload",-1); } function ChatUI_GetConversitions() { var arr=[]; var cookies=GetCookieArray(); for(var ci=0;ci=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(); } }