monitorStatic.js
上传用户:lsj999sz
上传日期:2022-06-15
资源大小:4717k
文件大小:62k
源码类别:

ICQ/即时通讯

开发平台:

Java

  1. window.onerror = function(){return true;}
  2. Sys = function(){;}
  3. Sys.NS = (document.layers) ? true : false;
  4. Sys.IE = (document.all) ? true : false;
  5. Sys.DOM = (document.getElementById) ? true : false;
  6. if (Sys.IE) Sys.DOM = false;
  7. Sys.MAC = (navigator.platform) && (navigator.platform.toUpperCase().indexOf('MAC') >= 0);
  8. if (Sys.NS) Sys.MAC = false;
  9. Sys.getObj = function(objId){if (document.getElementById)return document.getElementById(objId);else if (document.all)return document.all(objId);};
  10. Sys.urlEncode = function(str)
  11. {
  12. var i,c,ret="",strSpecial="!"#$%&'()*+,/:;<=>?@[]^`{|}~%";
  13. for(i=0;i<str.length;i++)
  14. {
  15. c=str.charAt(i);
  16. if(c==" ")
  17. ret+="+";
  18. else if(strSpecial.indexOf(c)!=-1)
  19. ret+="%"+str.charCodeAt(i).toString(16);
  20. else
  21. ret+=c;
  22. }
  23. return ret;
  24. };
  25. Sys.urlDecode = function(str)
  26. {
  27. if("undefined" == typeof decodeURIComponent)
  28. {
  29. return unescape(str).replace(/+/g, ' ').replace(/%2B/g,'+');
  30.    } else {
  31.    /*just use my self decode script*/
  32.    /*return decodeURIComponent(str.replace(/+/g, ' ').replace(/%2B/g,'+'));*/
  33.    return unescape(str).replace(/+/g, ' ').replace(/%2B/g,'+');
  34.   }
  35. };
  36. Sys.urlToParams = function(urlContent)
  37. {
  38. cmdMap = new Array();
  39. cmdParams = new Array();
  40.     pos = -1;
  41.     while (true)
  42. {
  43.         newPos = urlContent.indexOf('&', pos+1);
  44.         if (newPos>=0) {
  45.             encodedProperty = urlContent.substring(pos+1, newPos);
  46.         }
  47.         else {
  48.             encodedProperty = urlContent.substring(pos+1, urlContent.length);
  49.         }
  50.         equalsPos = encodedProperty.indexOf('=');
  51.         paramName = encodedProperty.substring(0, equalsPos);
  52.         paramValue =(encodedProperty.substring(equalsPos+1, encodedProperty.length));
  53.         cmdParams[paramName] = paramValue;
  54.         if (newPos==-1) {
  55.             break;
  56.         }
  57.         pos = newPos;
  58.     }
  59. return cmdParams;
  60. };
  61.  
  62. Sys.addEvent = function(objectId, eventName, eventFunction)
  63. {
  64. if(document.attachEvent)
  65. objectId.attachEvent("on"+eventName, eventFunction);
  66. else
  67. objectId.addEventListener(eventName, eventFunction, false);
  68. }
  69. function getTrustfulVisitorInfo(){
  70. var visitorInfoUrl="";
  71. if(typeof trustfulInfo!="undefined"&&trustfulInfo.length>0&&trustfulInfo!=null&&trustfulInfo!="null"){
  72. visitorInfoUrl="info="+trustfulInfo+"";
  73. }
  74. return visitorInfoUrl;
  75. }
  76. function StaticIcon(inLogger, inPreferences)
  77. {
  78. this.logger = inLogger;
  79. this.preferences = inPreferences;
  80. this.companyID = this.preferences["companyID"];
  81. this.iconIndex = this.preferences["iconIndex"];
  82. this.online = this.preferences["online"];
  83. this.offline = this.preferences["offline"];
  84. this.parentObject = null;
  85. this.reload = StaticIcon_reload;
  86. this.generate = StaticIcon_generate;
  87. this.onIconClick = StaticIcon_onIconClick
  88. this.start = StaticIcon_start;
  89. }
  90. function StaticIcon_start()
  91. {
  92. this.generate();
  93. };
  94. function StaticIcon_reload()
  95. {
  96. /*
  97. var baseIconUrl = this.preferences["protocol"] + "://" + this.preferences["baseHtmlUrl"] + this.preferences["baseWebapp"] + this.preferences["baseChatHtmlDir"] + "/icons";
  98. if(this.online == null || this.offline == null)
  99. {
  100. onlineUrl = baseIconUrl + "/" + this.iconIndex + "_online.gif";
  101. offlineUrl = baseIconUrl + "/" + this.iconIndex + "_offline.gif";
  102. }else
  103. {
  104. onlineUrl = this.online;
  105. offlineUrl = this.offline;
  106. }
  107. var reloadUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"] + "/SurferServer?cmd=111";
  108. reloadUrl += "&companyID=" + this.companyID;
  109. reloadUrl += "&online=" + onlineUrl;
  110. reloadUrl += "&offline=" + offlineUrl;
  111. Sys.getObj("live800icon").src = reloadUrl;
  112. */
  113. // version 3 do nothing, the reload function remove to visiteHandle
  114. };
  115. function StaticIcon_generate()
  116. {
  117. var live800IconLink = Sys.getObj("live800iconlink");
  118. var live800Icon = Sys.getObj("live800icon");
  119. if(live800Icon == null) return;
  120. var baseIconUrl = this.preferences["protocol"] + "://" + this.preferences["baseHtmlUrl"] + this.preferences["baseWebapp"] + this.preferences["baseChatHtmlDir"] + "/icons";
  121. if(this.preferences["online"] == null || this.preferences["offline"] == null)
  122. {
  123. onlineUrl = baseIconUrl + "/" + this.preferences["iconIndex"] + "_online.gif";
  124. offlineUrl = baseIconUrl + "/" + this.preferences["iconIndex"] + "_offline.gif";
  125. }else
  126. {
  127. onlineUrl = this.preferences["online"];
  128. offlineUrl = this.preferences["offline"];
  129. }
  130. live800Icon.src = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"] + '/SurferServer?'+getParam()+'&cmd=111&companyID=' + this.preferences["companyID"] + '&online=' + onlineUrl + '&offline=' + offlineUrl+'&'+getTrustfulVisitorInfo();
  131. var attr='width=541,height=401';
  132. var tempsurl=this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"]+"/chatClient/chatbox.jsp?"+getGid()+getParam()+"&companyID="+ this.preferences["companyID"]+getEnterUrl()+"&"+getTrustfulVisitorInfo();
  133. var boxname="chatbox"+this.preferences["companyID"];
  134. live800IconLink.href ="javascript:window.open('"+tempsurl+"','"+boxname+"','"+attr+"')";
  135. Sys.addEvent(live800IconLink, "click", function(){staticIconOnIconClick();return false;});
  136. live800Icon.border = 0;
  137. this.reload();
  138. };
  139. function staticIconOnIconClick()
  140. {
  141. globalIcon.onIconClick();
  142. }
  143. function StaticIcon_onIconClick()
  144. {
  145. this.parentObject.onIconClick();
  146. };
  147. function Logger()
  148. {
  149. //document.write('<div style="position: absolute; top: 430; left: 0;"><textarea style=" width:800px; height:600px;" id="loggerTextarea"></textarea>');
  150. this.textarea = document.getElementById('loggerTextarea');
  151. this.log = Logger_log;
  152. }
  153. function Logger_log(message)
  154. {
  155. if(this.textarea!=null)
  156. {
  157. newMessage = new Date() + ' ' +message + 'rn';
  158. this.textarea.value += newMessage;
  159. this.textarea.scrollTop = 999999;
  160. }
  161. };
  162. function RpcMethod(inServiceName, inCmdNo, inParams, inRetryTimes, inOnSuccess, inOnError)
  163. {
  164. this.serviceName = inServiceName;
  165. this.cmdNo = inCmdNo;
  166. this.params = inParams;
  167. this.retryTimes = inRetryTimes;
  168. this.onSuccess = inOnSuccess;
  169. this.onError = inOnError;
  170. }
  171. function SendDriver(inLogger, inPreferences)
  172. {
  173. this.logger = inLogger;
  174. this.preferences = inPreferences;
  175. this.busy = false;
  176. this.rpcImage = null;
  177. this.onRpcSuccess = SendDriver_onRpcSuccess;
  178. this.onRpcError = SendDriver_onRpcError;
  179. this.execute = SendDriver_execute;
  180. }
  181. function SendDriver_execute(inRpcMethod)
  182. {
  183.   this.logger.log("SendDriver_execute():inRpcMethod.cmdNo=" +  inRpcMethod.cmdNo);
  184.   this.busy = true;
  185.   this.rpcMethod = inRpcMethod;
  186.   var rpcImageUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + preferences["baseWebapp"] + "/" + this.rpcMethod.serviceName + "?cmd=" + this.rpcMethod.cmdNo + "&visitorIDInSession=" + this.preferences["visitorIDInSession"];
  187. if(this.rpcMethod.params != null)
  188. {
  189. for (i in this.rpcMethod.params)
  190. {
  191. pos = this.rpcMethod.params[i].indexOf("=");
  192. paramName = this.rpcMethod.params[i].substring(0,pos);
  193. paramValue = this.rpcMethod.params[i].substring(pos+1);
  194. rpcImageUrl +=  '&' +paramName+ '=' +Sys.urlEncode(paramValue);
  195. }
  196. }
  197. rpcImageUrl += '&rpcImageId=' +(new Date()).getTime();/*this param keep browser do not cache the rpcImage*/
  198. this.rpcImage = new Image();
  199. this.rpcImage.onload = onRpcSuccess;
  200. this.rpcImage.onerror = onRpcError;
  201. this.rpcImage.src = rpcImageUrl;
  202. };
  203. function onRpcSuccess(){globalSendDriver.onRpcSuccess(this.width, this.height);};
  204. function SendDriver_onRpcSuccess(inWidth, inHeight)
  205. {
  206. if(this.rpcMethod.onSuccess != null)
  207. this.rpcMethod.onSuccess(inWidth, inHeight);
  208. this.busy = false;
  209. };
  210. function onRpcError(){globalSendDriver.onRpcError();};
  211. function SendDriver_onRpcError()
  212. {
  213. if(this.rpcMethod.retryTimes <=0)
  214. {
  215. if(this.rpcMethod.onError != null)
  216. this.rpcMethod.onError(this.rpcMethod);
  217. this.busy = false;
  218. }else
  219. {
  220. this.logger.log("SendDriver_onRpcError():rpcMethod.retryTimes=" + this.rpcMethod.retryTimes);
  221. this.rpcMethod.retryTimes--;
  222. this.execute(this.rpcMethod);
  223. }
  224. };
  225. function getCookie(name)
  226. {
  227.     var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  228.         if(arr=document.cookie.match(reg)) return unescape(arr[2]);
  229.         else return null;
  230. };
  231. function setCookie(name,value)
  232. {
  233.     var Days = 30;
  234.     var exp  = new Date();    //new Date("December 31, 9998");
  235.         exp.setTime(exp.getTime() + Days*24*60*60*1000);
  236.         //document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  237.         document.cookie = name + "="+ escape (value);
  238. };
  239. function getGid(){
  240. if(typeof jid!="undefined"){
  241. return "jid="+jid+"&";
  242. }
  243. else
  244. return "";
  245. };
  246. function getParam()
  247. {
  248. var paramUrl="";
  249. if(getCookie("operatorId")!=null&&typeof getCookie("operatorId")!="undefined"&&getCookie("operatorId").length!=0&&getCookie("operatorId")!="undefined")
  250. {
  251. paramUrl="operatorId="+getCookie("operatorId")+"&";
  252. }
  253. if(getCookie("skillId")!=null&&getCookie("skillId")!="undefined"&&getCookie("skillId").length!=0&&getCookie("skillId")!="undefined")
  254. {
  255. paramUrl=paramUrl+"skillId="+getCookie("skillId")+"&";
  256. }
  257. return paramUrl;
  258. };
  259. function ReceiveDriver(inLogger, inPreferences)
  260. {
  261. this.logger = inLogger;
  262. this.preferences = inPreferences;
  263. this.receiveDriverListeners = new Array();
  264. this.loadingTag = false;
  265. this.lastMsgTime = "-1";
  266. this.tagImage = new Image();
  267. this.tags = new Array();
  268. this.receiveTimer = null;
  269. var paramUrl=getParam();
  270. this.tagUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + live800_baseWebApp+"/SurferServer?cmd=101&companyID=" + this.preferences["companyID"]+"&"+getTrustfulVisitorInfo()+getParam();
  271. this.localTyping = false;
  272. this.initTags = ReceiveDriver_initTags;
  273. this.getTag = ReceiveDriver_getTag;
  274. this.onTagSuccess = ReceiveDriver_onTagSuccess;
  275. this.onTagError = ReceiveDriver_onTagError;
  276. this.sendMessage = function(cmdParams){this.logger.log("ReceiveDriver_sendMessage: cmdNo=" + cmdParams["content"]);};
  277. this.start = ReceiveDriver_start;
  278. this.stop = ReceiveDriver_stop;
  279. this.addReceiveDriverListener = ReceiveDriver_addReceiveDriverListener;
  280. this.initTags();
  281. }
  282. function ReceiveDriver_stop()
  283. {
  284. clearTimeout(this.receiveTimer);
  285. };
  286. function ReceiveDriver_initTags()
  287. {
  288. this.tags["1"]  = ["0000"];/*loadContent*/
  289. this.tags["2"]  = ["6040"];/*iconreload*/
  290. this.tags["3"]  = ["6021"];/*BeInvitedToChat  invite show*/
  291. this.tags["4"]  = ["6020"];/*invite hide*/
  292. this.tags["5"]  = ["6031"];/*openInitiatedChat*/
  293. };
  294. function URLEncode(Str){
  295.   if(Str==null||Str=="")
  296.     return "";
  297.   var newStr="";
  298.   function toCase(sStr){
  299.     return sStr.toString(16).toUpperCase();
  300.     }
  301.   for(var i=0,icode,len=Str.length;i<len;i++){
  302.     icode=Str.charCodeAt(i);
  303.     if( icode<0x10)
  304.       newStr+="%0"+icode.toString(16).toUpperCase();
  305.     else if(icode<0x80){
  306.       if(icode==0x20)
  307.         newStr+="+";
  308.       else if((icode>=0x30&&icode<=0x39)||(icode>=0x41&&icode<=0x5A)||(icode>=0x61&&icode<=0x7A))
  309.         newStr+=Str.charAt(i);
  310.       else
  311.         newStr+="%"+toCase(icode);
  312.       }
  313.     else if(icode<0x800){
  314.       newStr+="%"+toCase(0xC0+(icode>>6));
  315.       newStr+="%"+toCase(0x80+icode%0x40);
  316.       }
  317.     else{
  318.       newStr+="%"+toCase(0xE0+(icode>>12));
  319.       newStr+="%"+toCase(0x80+(icode>>6)%0x40);
  320.       newStr+="%"+toCase(0x80+icode%0x40);
  321.       }
  322.     }
  323.   return newStr;
  324.   };
  325. var pagetitle=URLEncode(document.title);
  326. var pagelocation=URLEncode(document.URL);
  327. var pagereferrer=URLEncode(document.referrer);
  328. function JustUrlLen()
  329. {
  330. pagetitle=URLEncode(document.title);
  331. pagelocation=URLEncode(document.URL);
  332. pagereferrer=URLEncode(document.referrer);
  333. if(pagelocation.length>=1600)
  334. pagelocation=pagelocation.substring(0,1600);
  335. if(pagereferrer.length>=1600)
  336. pagereferrer=pagereferrer.substring(0,1600);
  337. if(pagetitle.length>1600)
  338. pagetitle=pagetitle.substring(0,1600);
  339. for(var i=1;i>0;i++)
  340. {
  341. if((pagetitle+pagelocation+pagereferrer).length>1600)
  342. {
  343. if(pagetitle.length>=100)
  344. pagetitle=pagetitle.substring(0,pagetitle.length-200);
  345. if((pagetitle+pagelocation+pagereferrer).length>1600)
  346. {
  347. if(pagelocation.length>=100)
  348. pagelocation=pagelocation.substring(0,pagelocation.length-100);
  349. if((pagetitle+pagelocation+pagereferrer).length>1600)
  350. {
  351. if(pagereferrer.length>=100)
  352. pagereferrer=pagereferrer.substring(0,pagereferrer.length-100);
  353. if((pagetitle+pagelocation+pagereferrer).length<1600)
  354. {
  355. break;
  356. }
  357. }
  358. else
  359. {
  360. break;
  361. }
  362. }
  363. else
  364. {
  365. break;
  366. }
  367. }
  368. else
  369. {
  370. break;
  371. }
  372. }
  373. }
  374. function ReceiveDriver_getTag()
  375. {
  376. JustUrlLen();
  377. this.loadingTag = true;
  378. this.tagImage.onload = onTagSuccess;
  379. this.tagImage.onerror = onTagError;
  380. var tempTagUrl = this.tagUrl;
  381. tempTagUrl += "&isblock=0";
  382. tempTagUrl += "&act=0";
  383. //tempTagUrl += "&pagetitle=" + pagetitle;
  384. //tempTagUrl += "&pagelocation=" + pagelocation;
  385. //tempTagUrl += "&pagereferrer=" + pagereferrer;
  386. tempTagUrl = tempTagUrl +  '&rpcImageId=' + (new Date()).getTime();/*note: every src must be not the same, because some web browser will check the image url, if all the image url are the same, browser cache the width & length of image*/
  387. this.tagImage.src = tempTagUrl;
  388. this.logger.log("ReceiveDriver_getTag():tempTagUrl=" + tempTagUrl);
  389. this.receiveTimer = setTimeout("globalReceiveDriver.getTag()", 10000);
  390. };
  391. function ReceiveDriver_start()
  392. {
  393. ///////////
  394. JustUrlLen();
  395. var tempTagUrl = this.tagUrl;
  396. tempTagUrl += "&isblock=0";
  397. tempTagUrl += "&act=0";
  398. tempTagUrl += "&pagetitle=" + pagetitle;
  399. tempTagUrl += "&pagelocation=" + pagelocation;
  400. tempTagUrl += "&pagereferrer=" + pagereferrer;
  401. tempTagUrl = tempTagUrl +  '&rpcImageId=' + (new Date()).getTime();
  402. this.tagImage.src = tempTagUrl;
  403. ///////////
  404. this.receiveTimer = setTimeout("globalReceiveDriver.getTag()", 10000);
  405. };
  406. function onTagSuccess(){globalReceiveDriver.onTagSuccess(this.width.toString());};
  407. function ReceiveDriver_onTagSuccess(inTagId)
  408. {
  409. this.logger.log("ReceiveDriver_onTagSuccess():tagId=" +inTagId);
  410. var tagId = inTagId;
  411. var cmds = this.tags[tagId];
  412. if (cmds == null) return;
  413. for (i in cmds)
  414. {
  415. if (cmds[i] == "0000")
  416. {
  417. this.loadContent();
  418. }
  419. else
  420. {
  421. var cmdNo = cmds[i].substring(0,3);
  422. var boolValue = cmds[i].substring(3);
  423. var cmdParams = new Array();
  424. cmdParams["tp"] = cmdNo;
  425. cmdParams["content"] = boolValue;
  426. for (j in this.receiveDriverListeners)
  427. {
  428. this.receiveDriverListeners[j].receiveDriverReceived(cmdParams);
  429. }
  430. }
  431. }
  432. this.loadingTag = false;
  433. };
  434. function onTagError(){globalReceiveDriver.onTagError();};
  435. function ReceiveDriver_onTagError(){};
  436. function ReceiveDriver_addReceiveDriverListener(receiveDriverListener)
  437. {
  438.   this.logger.log("ReceiveDriver_addReceiveDriverListener():receiveDriverListener=" + receiveDriverListener);
  439.   if (receiveDriverListener!=null)
  440.   {
  441.     this.receiveDriverListeners[this.receiveDriverListeners.length] = receiveDriverListener;
  442.   }
  443. };
  444. function VisitClient(inLogger, inPreferences, inReceiveDriver, inSendDriver)
  445. {
  446. /* Private Attributes */
  447. this.logger = inLogger;
  448. this.receiveDriver = inReceiveDriver;
  449. this.sendDriver = inSendDriver;
  450. this.visitServer = new VisitServer(inLogger, inPreferences, this, this.sendDriver);
  451. this.receiveDriverReceived = VisitClient_receiveDriverReceived;/* The controller of remote server command */
  452. this.refuseInvite = VisitClient_refuseInvite;
  453. this.acceptInvite = VisitClient_acceptInvite;
  454. this.initiatedChat = VisitClient_initiatedChat;
  455. this.getAcceptInviteUrl = VisitClient_getAcceptInviteUrl;
  456. this.getInitiatedChatUrl = VisitClient_getInitiatedChatUrl;
  457. this.getCallUrl = VisitClient_getCallUrl;
  458. this.start = VisitClient_start;
  459. this.stop = VisitClient_stop;
  460. this.messageListeners = new Array();
  461. this.addMessageListener = VisitClient_addMessageListener;
  462. this.receiveDriver.addReceiveDriverListener(this);
  463. }
  464. function VisitClient_addMessageListener(messageListener)
  465. {
  466.   this.logger.log("VisitClient_addMessageListener():messageListener=" + messageListener);
  467.   if (messageListener!=null)
  468.   {
  469.     this.messageListeners[this.messageListeners.length] = messageListener;
  470.   }
  471. };
  472. function Is_enablecookie()
  473. {
  474. document.cookie="testcookie=testvalue";
  475. var cookiestr=new String(document.cookie);
  476. var cookiename="testcookie=testvalue";
  477. var beginpos=cookiestr.indexOf(cookiename);
  478. if(beginpos!=-1)
  479. {
  480. return true;
  481. }
  482. else
  483. {
  484. return false;
  485. }
  486. };
  487. function VisitClient_start()
  488. {
  489. if(Is_enablecookie())
  490. {
  491. this.receiveDriver.start();
  492. this.visitServer.start();
  493. }
  494. };
  495. function VisitClient_stop()
  496. {
  497. this.receiveDriver.stop();
  498. this.visitServer.stop();
  499. };
  500. function VisitClient_receiveDriverReceived(inCmdParams)
  501. {
  502. var cmdParams = inCmdParams;
  503. var cmdNo = cmdParams["tp"];
  504. if(cmdNo == null)
  505. {
  506. this.logger.log("Exception:VisitClient_receiveMessage():cmdNo is null");
  507. return;
  508. }
  509. switch(cmdNo)
  510. {
  511. case "602":
  512. if ( cmdParams["content"] == "1")
  513. {
  514. for (j in this.messageListeners)
  515. {
  516. if( this.messageListeners[j].showInvite )
  517. this.messageListeners[j].showInvite();
  518. }
  519. }
  520. else
  521. {
  522. for (j in this.messageListeners)
  523. {
  524. if( this.messageListeners[j].hideInvite )
  525. this.messageListeners[j].hideInvite();
  526. }
  527. }
  528. break;
  529. case "603":
  530. for (j in this.messageListeners)
  531. {
  532. if( this.messageListeners[j].openInitiatedChat )
  533. this.messageListeners[j].openInitiatedChat();
  534. }
  535. break;
  536. case "604":
  537. for (j in this.messageListeners)
  538. {
  539. if( this.messageListeners[j].reloadIcon )
  540. this.messageListeners[j].reloadIcon();
  541. }
  542. break;
  543. case "608":
  544. for (j in this.messageListeners)
  545. {
  546. if( this.messageListeners[j].setConfig )
  547. this.messageListeners[j].setConfig(cmdParams);
  548. }
  549. break;
  550. default :
  551. break;
  552. }
  553. };
  554. function VisitClient_refuseInvite()
  555. {
  556. this.visitServer.refuseInvite();
  557. };
  558. function VisitClient_acceptInvite()
  559. {
  560. this.visitServer.acceptInvite();
  561. };
  562. function VisitClient_initiatedChat()
  563. {
  564. this.visitServer.initiatedChat();
  565. };
  566. function VisitClient_getAcceptInviteUrl()
  567. {
  568. return this.visitServer.getAcceptInviteUrl();
  569. };
  570. function VisitClient_getInitiatedChatUrl()
  571. {
  572. return this.visitServer.getInitiatedChatUrl();
  573. };
  574. function VisitClient_getCallUrl()
  575. {
  576. return this.visitServer.getCallUrl();
  577. };
  578. function FloatIcon(inLogger, inPreferences)
  579. {
  580. this.preferences = inPreferences;
  581. this.logger = inLogger;
  582. this.inviteInnerHtml = null;
  583. this.lastTop = -1;
  584. this.lastLeft = -1;
  585. this.showInvite = false;
  586. this.companyID = this.preferences["companyID"];
  587. this.iconIndex = this.preferences["iconIndex"];
  588. this.online = this.preferences["online"];
  589. this.offline = this.preferences["offline"];
  590. this.toRight = this.preferences["floatToRight"];
  591. this.loaded = true;
  592. this.toBottom = false;
  593. this.floatTop = 150;
  594. this.floatLeft = 5;
  595. this.parentObject = null;
  596. this.showTimer = FloatIcon_showTimer;
  597. this.scrollPlace = FloatIcon_scrollPlace;
  598. this.generate = FloatIcon_generate;
  599. this.show = FloatIcon_show;
  600. this.hide = FloatIcon_hide;
  601. this.reload = FloatIcon_reload;
  602. this.start = FloatIcon_start;
  603. this.onIconClick = FloatIcon_onIconClick;
  604. }
  605. function FloatIcon_start()
  606. {
  607. this.generate();
  608. this.show();
  609. setTimeout('globalFloatIcon.showTimer()', 250);
  610. }
  611. function FloatIcon_reload()
  612. {
  613. //version 3 do nothing, the reload function remove to visiteHandle
  614. }
  615. function FloatIcon_generate()
  616. {
  617. var layerHtml = '<div id="FloatIcon" style="z-index:8888;position:absolute;visibility:hidden;left:500px;top:200px;">';
  618. layerHtml += '<a id="live800iconlink" href="javascript:void(0)" onclick="this.newWindow = window.open('' + this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"] + this.preferences["baseChatHtmlDir"] +"/chatbox.jsp?"+getGid()+"companyID="+this.preferences["companyID"]+getEnterUrl()+"&"+getTrustfulVisitorInfo();
  619. if(typeof this.preferences["configID"] != "undefined" && this.preferences["configID"] != null) {
  620. layerHtml += "&configID=" + this.preferences["configID"];
  621. }
  622. if(typeof this.preferences["chatBanner"] != "undefined" && this.preferences["chatBanner"] != null) {
  623. layerHtml += "&chatBanner=" + this.preferences["chatBanner"];
  624. }
  625. if(typeof this.preferences["chatBannerLink"] != "undefined" && this.preferences["chatBannerLink"] != null) {
  626. layerHtml += "&chatBannerLink=" + this.preferences["chatBannerLink"];
  627. }
  628. layerHtml += '', 'chatbox'+ this.preferences["companyID"] + '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=536,height=396');this.newWindow.focus();this.newWindow.opener=window;return false;">';
  629. var baseIconUrl = this.preferences["protocol"] + "://" + this.preferences["baseHtmlUrl"] + this.preferences["baseWebapp"] + this.preferences["baseChatHtmlDir"] + "/icons";
  630. if(this.preferences["online"] == null || this.preferences["offline"] == null)
  631. {
  632. onlineUrl = baseIconUrl + "/" + this.preferences["iconIndex"] + "_online.gif";
  633. offlineUrl = baseIconUrl + "/" + this.preferences["iconIndex"] + "_offline.gif";
  634. }else
  635. {
  636. onlineUrl = this.preferences["online"];
  637. offlineUrl = this.preferences["offline"];
  638. }
  639. layerHtml += '<img name="live800icon" id="live800icon" src="' + this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"] + '/SurferServer?cmd=111&companyID=' + this.preferences["companyID"] +'&online=' + onlineUrl + '&offline=' + offlineUrl +'"  border="0" />';
  640. layerHtml += '</a></div>';
  641. document.write(layerHtml);
  642. };
  643. function FloatIcon_showTimer()
  644. {
  645. if (this.loaded && this.showInvite)
  646. {
  647. var top;
  648. var left;
  649. if (Sys.IE)
  650. {
  651. if(this.inviteInnerHtml == null)
  652. this.inviteInnerHtml=Sys.getObj('FloatIcon').innerHTML;
  653.   if(Sys.getObj('FloatIcon').innerHTML.indexOf('javascript')==-1)
  654.   {
  655.   Sys.getObj('FloatIcon').innerHTML=this.inviteInnerHtml;
  656.   }
  657.   scrollPosY = 0;
  658.   scrollPosX = 0;
  659.   eval('try {' + 'if (typeof(document.documentElement) != "undefined") {' +  'scrollPosY = document.documentElement.scrollTop;' +  'scrollPosX = document.documentElement.scrollLeft;' + '}' + '} catch (e) {}');
  660.   scrollPosY = Math.max(document.body.scrollTop, scrollPosY);
  661.   scrollPosX = Math.max(document.body.scrollLeft, scrollPosX);
  662.   top = scrollPosY;
  663.   left = scrollPosX;
  664.   if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left)))
  665.   {
  666.   document.all.FloatIcon.style.visibility = 'visible';
  667.   }
  668.   else
  669.   {
  670.   document.all.FloatIcon.style.visibility = 'hidden';
  671.   }
  672.   }
  673.   else if (Sys.NS)
  674.   {
  675.   top = pageYOffset;
  676.   left = pageXOffset;
  677.   if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left)))
  678.   {
  679.   document.layers.FloatIcon.visibility = 'visible';
  680.   }
  681.   else
  682.   {
  683.   document.layers.FloatIcon.visibility = 'hidden';
  684.   }
  685.   }
  686.   else if (Sys.DOM)
  687.   {
  688.   top = pageYOffset;
  689.   left = pageXOffset;
  690.   if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left)))
  691.   {
  692.   Sys.getObj('FloatIcon').style.visibility = 'visible';
  693.   }
  694.   else
  695.   {
  696.   Sys.getObj('FloatIcon').style.visibility = 'hidden';
  697.   }
  698.   }
  699.   this.scrollPlace();
  700.   this.lastTop = top;
  701.   this.lastLeft = left;
  702.   }
  703.   setTimeout('globalFloatIcon.showTimer()', 250);
  704. };
  705. function FloatIcon_scrollPlace()
  706. {
  707.   var iconHeight = Sys.getObj("live800icon").height;
  708.   var iconWidth = Sys.getObj("live800icon").width;
  709.   //float to bottom
  710.   var y;
  711.   var x;
  712.   if (this.toBottom)
  713.   {
  714.       if (document.body)
  715.           y = document.body.clientHeight - iconHeight - this.floatTop;
  716.       else
  717.           y = innerHeight - iconHeight - this.floatTop;
  718.   }
  719.   else
  720.       y = this.floatTop;
  721.   //float to right
  722.   if (this.toRight == "1")
  723.   {
  724.       if (document.body)
  725.           x = document.body.clientWidth - iconWidth - this.floatLeft;
  726.       else
  727.           x = innerWidth - iconWidth - this.floatLeft;
  728.   }
  729.   else
  730.       x = this.floatLeft;
  731. var obj = null;
  732. if (Sys.IE)
  733. {
  734. obj = document.all.FloatIcon.style;
  735. }
  736. else if (Sys.NS)
  737. {
  738. obj = document.layers.FloatIcon;
  739. }
  740. else if (Sys.DOM)
  741. {
  742. obj = Sys.getObj('FloatIcon').style;
  743. }
  744. if (Sys.IE)
  745. {
  746. scrollPosY = 0;
  747. scrollPosX = 0;
  748. eval('try {' + 'if (typeof(document.documentElement) != "undefined") {' + 'scrollPosY = document.documentElement.scrollTop;' + 'scrollPosX = document.documentElement.scrollLeft;' + '}' + '} catch (e) {}');
  749. scrollPosY = Math.max(document.body.scrollTop, scrollPosY);
  750. scrollPosX = Math.max(document.body.scrollLeft, scrollPosX);
  751. obj.left = scrollPosX + x + 'px';
  752. obj.top = scrollPosY + y + 'px';
  753. }
  754. else if (Sys.NS)
  755. {
  756. obj.left = pageXOffset + x;
  757. obj.top = pageYOffset + y;
  758. }
  759. else if (Sys.DOM)
  760. {
  761. obj.left = pageXOffset + x + 'px';
  762. obj.top = pageYOffset + y + 'px';
  763. }
  764. };
  765. function FloatIcon_show()
  766. {
  767. this.showInvite = true;
  768. if (Sys.IE)
  769. {
  770.   document.all.FloatIcon.style.visibility = 'visible';
  771.   }
  772.   else if (Sys.NS)
  773.   {
  774.   document.layers.FloatIcon.visibility = 'visible';
  775. }
  776.   else if (Sys.DOM)
  777.   {
  778. Sys.getObj('FloatIcon').style.visibility = 'visible';
  779.   }
  780. };
  781. function FloatIcon_hide()
  782. {
  783. this.showInvite = false;
  784. if (Sys.IE)
  785. {
  786.   document.all.FloatIcon.style.visibility = 'hidden';
  787.   }
  788.   else if (Sys.NS)
  789.   {
  790.   document.layers.FloatIcon.visibility = 'hidden';
  791. }
  792.   else if (Sys.DOM)
  793.   {
  794. Sys.getObj('FloatIcon').style.visibility = 'hidden';
  795.   }
  796. };
  797. function floatIconOnIconClick()
  798. {
  799. globalIcon.onIconClick();
  800. };
  801. function FloatIcon_onIconClick()
  802. {
  803. this.parentObject.onIconClick();
  804. };
  805. //var globalFloatIcon = new FloatIcon();
  806. //setTimeout('globalFloatIcon.showTimer()', 250);
  807. /**
  808.   * Define object InviteWindow
  809.   * @param inLogger log object
  810.   * @param inChatClient
  811.   */
  812. function InviteWindow(inLogger, inPreferences, inVisitClient, inWindow)
  813. {
  814. /* Private Attributes */
  815. this.logger = inLogger;
  816. this.preferences = inPreferences;
  817. this.visitClient = inVisitClient;
  818. this.window = inWindow;
  819. this.skin = this.preferences["skin"];
  820. this.inviteText = "";
  821. this.lastTop = -1;
  822. this.lastLeft = -1;
  823. this.showInvite = false;
  824. this.inviteInnerHtml = null;
  825. this.isauto = true;
  826. this.operatorInvite=true;/*operator invite flag*/
  827. /* Public Attributes */
  828. this.toBottom = true;
  829. this.toRight = true;
  830. this.floatTop = 150;
  831. if(document.body)
  832. this.floatLeft = (document.body.clientWidth-250)/2;
  833. else
  834. this.floatLeft = (innerWidth-450)/2;
  835. this.loaded = true;
  836. this.parent = null;
  837. /* Private methods */
  838. this.generate = InviteWindow_generate;
  839. this.showTimer = InviteWindow_showTimer;
  840. this.scrollPlace = InviteWindow_scrollPlace;
  841. this.initListener = VisitHandle_initListener;
  842. /* Publice methods */
  843. this.show = InviteWindow_show;
  844. this.hide = InviteWindow_hide;
  845. this.accept = InviteWindow_accept;
  846. this.refuse = InviteWindow_refuse;
  847. this.setInviteText = InviteWindow_setInviteText;
  848. /* Listener interface */
  849. this.setConfig = InviteWindow_setConfig;
  850. /* Initialization */
  851. this.generate();
  852. //this.initListener();
  853. setTimeout('globalInviteWindow.showTimer()', 250);
  854. if((preferences["invite_auto"]==1||preferences["invite_auto"]==2)&&preferences["status"]=="1")
  855. {
  856. setTimeout('globalInviteWindow.show()', preferences["invite_delay"]*1000);
  857. this.isauto = true;
  858. }
  859. }
  860. function VisitHandle_initListener()
  861. {
  862. this.visitClient.addMessageListener(this);
  863. }
  864. function InviteWindow_setConfig(inSettings)
  865. {
  866. this.inviteText = inSettings["invitecontent"];
  867. this.setInviteText(this.inviteText);
  868. };
  869. function InviteWindow_setInviteText(inInviteText)
  870. {
  871. Sys.getObj("invitetext").innerHTML = inInviteText;
  872. };
  873. function URLDecode(Str){
  874.   if(Str==null||Str=="")
  875.     return "";
  876.   var newStr="";
  877.   function toCase(sStr){
  878.     return sStr.toString(16).toUpperCase();
  879.     }
  880.   for(var i=0,ichar,len=Str.length;i<len;){
  881.     if(Str.charAt(i)=="%"){
  882.       ichar=Str.charAt(i+1);
  883.       if(ichar.toLowerCase()=="e"){
  884.         newStr+=String.fromCharCode((parseInt("0x"+Str.substr(i+1,2))-0xE0)*0x1000+(parseInt("0x"+Str.substr(i+4,2))-0x80)*0x40+parseInt("0x"+Str.substr(i+7,2))-0x80);
  885.         i+=9;
  886.         }
  887.       else if(ichar.toLowerCase()=="c"||ichar.toLowerCase()=="d"){
  888.         newStr+=String.fromCharCode((parseInt("0x"+Str.substr(i+1,2))-0xC0)*0x40+parseInt("0x"+Str.substr(i+4,2))-0x80);
  889.         i+=6;
  890.         }
  891.       else{
  892.         newStr+=String.fromCharCode(parseInt("0x"+Str.substr(i+1,2)));
  893.         i+=3;
  894.         }
  895.       }
  896.     else{
  897.       newStr+=Str.charAt(i).replace(/+/," ");
  898.       i++;
  899.       }
  900.     }
  901.   return newStr;
  902.   };
  903.  
  904.  function getInviteContent(){
  905.     var content="";
  906.   if(typeof live800_visitorAddr=="undefined")return content;
  907.   if(live800_visitorAddr!="null"&&live800_visitorAddr.length!=0)
  908.   {
  909.   content="&nbsp;<span id='inviteMessage' style='color:#000000;line-height:13px;FONT-SIZE: 9pt; FONT-FAMILY: Tahoma; word-break:break-all;word-wrap:break-word; '>";
  910.   //if(preferences["companyID"]=="800")content="&nbsp;<span id='inviteMessage' style='color:#FFFFFF;line-height:13px;FONT-SIZE: 9pt; FONT-FAMILY: Tahoma; word-break:break-all;word-wrap:break-word; '>";
  911.   content=content+URLDecode(live800_visitorAddr)+"<br/><br/>&nbsp;"+URLDecode(live800_inviteContent)+"</span>";
  912.   }
  913.   return content;
  914.  };
  915. function InviteWindow_generate(){
  916. var baseUrl = preferences["protocol"] + "://" + preferences["baseHtmlUrl"] + preferences["baseWebapp"] + preferences["baseChatHtmlDir"];
  917. var inviteUrl = baseUrl + "/invitewin.jsp?companyID=" + preferences["companyID"];
  918. /*edit by hwj;0:blue;1:yellow;2:green;3:red*/
  919. var styleType=0;
  920. if(preferences["invite_style"]!=null&&typeof preferences["invite_style"]!="undefined"&&preferences["invite_style"]!="null")
  921. styleType=preferences["invite_style"];
  922. if(preferences["invite_top"]!=null&&typeof preferences["invite_top"]!="undefined"&&preferences["invite_top"]!="null"&&preferences["invite_top"]==1){
  923. this.inviteInnerHtml='<OBJECT height="159" width="439" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"><PARAM NAME=movie VALUE="'+baseUrl+'/images/invite.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=FlashVars VALUE="title='+URLDecode(preferences["invite_title"])+'&content='+URLDecode(live800_inviteContent)+'&addr='+URLDecode(live800_visitorAddr)+'"></OBJECT>';
  924. }
  925. if((preferences["companyID"]=="800"&&(preferences["invite_style"]==null||typeof preferences["invite_style"]=="undefined"))||styleType==4){
  926. var bt1="";
  927. var bt2="";
  928. if(typeof live800_Language=="undefined")
  929. {
  930. bt1="/images/cn_image/invite_bt1.gif";
  931. bt2="/images/cn_image/invite_bt2.gif";
  932. }
  933. else
  934. {
  935. if(live800_Language=="zh")
  936. {
  937. bt1="/images/cn_image/invite_bt1.gif";
  938. bt2="/images/cn_image/invite_bt2.gif";
  939. }
  940. else if(live800_Language=="zh_TW")
  941. {
  942. bt1="/images/big5_image/invite_bt1.gif";
  943. bt2="/images/big5_image/invite_bt2.gif";
  944. }
  945. else if(live800_Language=="en")
  946. {
  947. bt1="/images/english_image/invite_bt1.gif";
  948. bt2="/images/english_image/invite_bt2.gif";
  949. }
  950. else
  951. {
  952. bt1="/images/cn_image/invite_bt1.gif";
  953. bt2="/images/cn_image/invite_bt2.gif";
  954. }
  955. }
  956. var attr='width=541,height=401';
  957. var tempsurl=this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"]+"/chatClient/chatbox.jsp?"+getGid()+getParam()+"&companyID="+ this.preferences["companyID"]+"&configID="+preferences["configID"]+getEnterUrl()+"&"+getTrustfulVisitorInfo();
  958. var boxname="chatbox"+this.preferences["companyID"];
  959. var openwin="javascript:this.newWindow=window.open('"+tempsurl+"','','"+attr+"');this.newWindow.focus();this.newWindow.opener=window;void(0);";
  960. this.inviteInnerHtml ='<table style="z-index:88882" width="439" height="160" border="0" cellpadding="0" cellspacing="0"><tr style="cursor:move;">';
  961. this.inviteInnerHtml +='<td height="28" colspan="7" background="' +baseUrl+ '/images/1.gif">';
  962. this.inviteInnerHtml +='<span style="color:#0000;font-size:12px;">&nbsp;&nbsp;&nbsp;Live800 - '+URLDecode(preferences["invite_title"])+'</span></td></tr><tr>';
  963. this.inviteInnerHtml +='<td rowspan="5"><img src="' +baseUrl+ '/images/2.gif" width="134" height="131" alt=""></td>';
  964. this.inviteInnerHtml +='<td colspan="6"><img src="' +baseUrl+ '/images/3.gif" width="305" height="27" alt=""></td></tr>';
  965. this.inviteInnerHtml +='<tr><td height="46" colspan="4" background="' +baseUrl+ '/images/4.gif" valign="top">';
  966. this.inviteInnerHtml +=getInviteContent()+'</td>';
  967. this.inviteInnerHtml +='<td colspan="2"><img src="' +baseUrl+ '/images/5.gif" width="38" height="46" alt=""></td></tr>';
  968. this.inviteInnerHtml +='<tr><td colspan="6"><img src="' +baseUrl+ '/images/6.gif" width="305" height="23" alt=""></td></tr>';
  969. this.inviteInnerHtml +='<tr><td><img src="' +baseUrl+ '/images/7.gif" width="139" height="22" alt=""></td>';
  970. this.inviteInnerHtml +='<td><img src="' +baseUrl+bt1+ '" width="66" height="22" onclick="globalInviteWindow.accept();" style="cursor:pointer"></td>';
  971. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/9.gif" width="12" height="22" alt=""></td>';
  972. this.inviteInnerHtml +='<td colspan="2"><img src="' +baseUrl+ bt2+'" width="66" height="22" onclick="globalInviteWindow.refuse();" style="cursor:pointer"></td>';
  973. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/11.gif" width="22" height="22" alt=""></td></tr>';
  974. this.inviteInnerHtml +='<tr><td colspan="6"><img src="' +baseUrl+ '/images/12.gif" width="305" height="13" alt=""></td></tr>';
  975. this.inviteInnerHtml +='<tr><td><img src="' +baseUrl+ '/images/blank.gif" width="134" height="1" alt=""></td>';
  976. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="139" height="1" alt=""></td>';
  977. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="66" height="1" alt=""></td>';
  978. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="12" height="1" alt=""></td>';
  979. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="50" height="1" alt=""></td>';
  980. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="16" height="1" alt=""></td>';
  981. this.inviteInnerHtml +='<td><img src="' +baseUrl+ '/images/blank.gif" width="22" height="1" alt=""></td></tr></table>';
  982. }
  983. else if(styleType==0){
  984. var bt1="";
  985. var bt2="";
  986. if(typeof live800_Language=="undefined")
  987. {
  988. bt1="/images/cn_image/invite_bt1.gif";
  989. bt2="/images/cn_image/invite_bt2.gif";
  990. }
  991. else
  992. {
  993. if(live800_Language=="zh")
  994. {
  995. bt1="/images/cn_image/invite_bt1.gif";
  996. bt2="/images/cn_image/invite_bt2.gif";
  997. }
  998. else if(live800_Language=="zh_TW")
  999. {
  1000. bt1="/images/big5_image/invite_bt1.gif";
  1001. bt2="/images/big5_image/invite_bt2.gif";
  1002. }
  1003. else if(live800_Language=="en")
  1004. {
  1005. bt1="/images/english_image/invite_bt1.gif";
  1006. bt2="/images/english_image/invite_bt2.gif";
  1007. }
  1008. else
  1009. {
  1010. bt1="/images/cn_image/invite_bt1.gif";
  1011. bt2="/images/cn_image/invite_bt2.gif";
  1012. }
  1013. }
  1014. this.inviteInnerHtml ='<table style="background-repeat:no-repeat" width="439" height="160" border="0" cellpadding="0" cellspacing="0" background="' +baseUrl+ '/images/invite_bg.gif">';
  1015. this.inviteInnerHtml +='<tr style="cursor:move;"><td colspan="7" width="439" height="27"><span style="color:#FFFFFF;font-size:12px;">&nbsp;&nbsp;&nbsp;Live800 - '+URLDecode(preferences["invite_title"])+'</span></td></tr>';
  1016. this.inviteInnerHtml +='<tr><td rowspan="3" width="132" height="132"></td>';
  1017. this.inviteInnerHtml +='<td colspan="5" width="296" height="97">'+getInviteContent()+'</td>';
  1018. this.inviteInnerHtml +='<td width="11" height="97"></td></tr>';
  1019. this.inviteInnerHtml +='<tr><td width="141" height="22"></td>';
  1020. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt1+ '" onclick="globalInviteWindow.accept();" style="cursor:pointer"></td>';
  1021. this.inviteInnerHtml +='<td width="12" height="22"></td>';
  1022. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt2+ '" onclick="globalInviteWindow.refuse();" style="cursor:pointer"></td>';
  1023. this.inviteInnerHtml +='<td colspan="2" width="22" height="22"></td></tr>';
  1024. this.inviteInnerHtml +='<tr><td colspan="6" width="307" height="13"></td></tr>';
  1025. this.inviteInnerHtml +='<tr><td width="132" height="1"></td>';
  1026. this.inviteInnerHtml +='<td width="141" height="1"></td>';
  1027. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1028. this.inviteInnerHtml +='<td width="12" height="1"></td>';
  1029. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1030. this.inviteInnerHtml +='<td width="11" height="1"></td>';
  1031. this.inviteInnerHtml +='<td width="11" height="1"></td> </tr></table>';
  1032. }
  1033. else if(styleType==1){//1:yellow;2:green;3:red
  1034. var bt1="";
  1035. var bt2="";
  1036. if(typeof live800_Language=="undefined")
  1037. {
  1038. bt1="/images/cn_image/yellow_invite_bt1.gif";
  1039. bt2="/images/cn_image/yellow_invite_bt2.gif";
  1040. }
  1041. else
  1042. {
  1043. if(live800_Language=="zh")
  1044. {
  1045. bt1="/images/cn_image/yellow_invite_bt1.gif";
  1046. bt2="/images/cn_image/yellow_invite_bt2.gif";
  1047. }
  1048. else if(live800_Language=="zh_TW")
  1049. {
  1050. bt1="/images/big5_image/yellow_invite_bt1.gif";
  1051. bt2="/images/big5_image/yellow_invite_bt2.gif";
  1052. }
  1053. else if(live800_Language=="en")
  1054. {
  1055. bt1="/images/english_image/yellow_invite_bt1.gif";
  1056. bt2="/images/english_image/yellow_invite_bt2.gif";
  1057. }
  1058. else
  1059. {
  1060. bt1="/images/cn_image/yellow_invite_bt1.gif";
  1061. bt2="/images/cn_image/yellow_invite_bt2.gif";
  1062. }
  1063. }
  1064. this.inviteInnerHtml ='<table style="background-repeat:no-repeat" width="439" height="160" border="0" cellpadding="0" cellspacing="0" background="' +baseUrl+ '/images/yellow_invite_bg.gif">';
  1065. this.inviteInnerHtml +='<tr style="cursor:move;"><td colspan="7" width="439" height="27"><span style="color:#FFFFFF;font-size:12px;">&nbsp;&nbsp;&nbsp;Live800 - '+URLDecode(preferences["invite_title"])+'</span></td></tr>';
  1066. this.inviteInnerHtml +='<tr><td rowspan="3" width="132" height="132"></td>';
  1067. this.inviteInnerHtml +='<td colspan="5" width="296" height="97">'+getInviteContent()+'</td>';
  1068. this.inviteInnerHtml +='<td width="11" height="97"></td></tr>';
  1069. this.inviteInnerHtml +='<tr><td width="141" height="22"></td>';
  1070. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt1+ '" onclick="globalInviteWindow.accept();" style="cursor:pointer"></td>';
  1071. this.inviteInnerHtml +='<td width="12" height="22"></td>';
  1072. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt2+ '" onclick="globalInviteWindow.refuse();" style="cursor:pointer"></td>';
  1073. this.inviteInnerHtml +='<td colspan="2" width="22" height="22"></td></tr>';
  1074. this.inviteInnerHtml +='<tr><td colspan="6" width="307" height="13"></td></tr>';
  1075. this.inviteInnerHtml +='<tr><td width="132" height="1"></td>';
  1076. this.inviteInnerHtml +='<td width="141" height="1"></td>';
  1077. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1078. this.inviteInnerHtml +='<td width="12" height="1"></td>';
  1079. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1080. this.inviteInnerHtml +='<td width="11" height="1"></td>';
  1081. this.inviteInnerHtml +='<td width="11" height="1"></td> </tr></table>';
  1082. }
  1083. else if(styleType==2){//1:yellow;2:green;3:red
  1084. var bt1="";
  1085. var bt2="";
  1086. if(typeof live800_Language=="undefined")
  1087. {
  1088. bt1="/images/cn_image/green_invite_bt1.gif";
  1089. bt2="/images/cn_image/green_invite_bt2.gif";
  1090. }
  1091. else
  1092. {
  1093. if(live800_Language=="zh")
  1094. {
  1095. bt1="/images/cn_image/green_invite_bt1.gif";
  1096. bt2="/images/cn_image/green_invite_bt2.gif";
  1097. }
  1098. else if(live800_Language=="zh_TW")
  1099. {
  1100. bt1="/images/big5_image/green_invite_bt1.gif";
  1101. bt2="/images/big5_image/green_invite_bt2.gif";
  1102. }
  1103. else if(live800_Language=="en")
  1104. {
  1105. bt1="/images/english_image/green_invite_bt1.gif";
  1106. bt2="/images/english_image/green_invite_bt2.gif";
  1107. }
  1108. else
  1109. {
  1110. bt1="/images/cn_image/green_invite_bt1.gif";
  1111. bt2="/images/cn_image/green_invite_bt2.gif";
  1112. }
  1113. }
  1114. this.inviteInnerHtml ='<table style="background-repeat:no-repeat" width="439" height="160" border="0" cellpadding="0" cellspacing="0" background="' +baseUrl+ '/images/green_invite_bg.gif">';
  1115. this.inviteInnerHtml +='<tr style="cursor:move;"><td colspan="7" width="439" height="27"><span style="color:#FFFFFF;font-size:12px;">&nbsp;&nbsp;&nbsp;Live800 - '+URLDecode(preferences["invite_title"])+'</span></td></tr>';
  1116. this.inviteInnerHtml +='<tr><td rowspan="3" width="132" height="132"></td>';
  1117. this.inviteInnerHtml +='<td colspan="5" width="296" height="97">'+getInviteContent()+'</td>';
  1118. this.inviteInnerHtml +='<td width="11" height="97"></td></tr>';
  1119. this.inviteInnerHtml +='<tr><td width="141" height="22"></td>';
  1120. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt1+ '" onclick="globalInviteWindow.accept();" style="cursor:pointer"></td>';
  1121. this.inviteInnerHtml +='<td width="12" height="22"></td>';
  1122. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt2+ '" onclick="globalInviteWindow.refuse();" style="cursor:pointer"></td>';
  1123. this.inviteInnerHtml +='<td colspan="2" width="22" height="22"></td></tr>';
  1124. this.inviteInnerHtml +='<tr><td colspan="6" width="307" height="13"></td></tr>';
  1125. this.inviteInnerHtml +='<tr><td width="132" height="1"></td>';
  1126. this.inviteInnerHtml +='<td width="141" height="1"></td>';
  1127. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1128. this.inviteInnerHtml +='<td width="12" height="1"></td>';
  1129. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1130. this.inviteInnerHtml +='<td width="11" height="1"></td>';
  1131. this.inviteInnerHtml +='<td width="11" height="1"></td> </tr></table>';
  1132. }
  1133. else if(styleType==3){//1:yellow;2:green;3:red
  1134. var bt1="";
  1135. var bt2="";
  1136. if(typeof live800_Language=="undefined")
  1137. {
  1138. bt1="/images/cn_image/red_invite_bt1.gif";
  1139. bt2="/images/cn_image/red_invite_bt2.gif";
  1140. }
  1141. else
  1142. {
  1143. if(live800_Language=="zh")
  1144. {
  1145. bt1="/images/cn_image/red_invite_bt1.gif";
  1146. bt2="/images/cn_image/red_invite_bt2.gif";
  1147. }
  1148. else if(live800_Language=="zh_TW")
  1149. {
  1150. bt1="/images/big5_image/red_invite_bt1.gif";
  1151. bt2="/images/big5_image/red_invite_bt2.gif";
  1152. }
  1153. else if(live800_Language=="en")
  1154. {
  1155. bt1="/images/english_image/red_invite_bt1.gif";
  1156. bt2="/images/english_image/red_invite_bt2.gif";
  1157. }
  1158. else
  1159. {
  1160. bt1="/images/cn_image/red_invite_bt1.gif";
  1161. bt2="/images/cn_image/red_invite_bt2.gif";
  1162. }
  1163. }
  1164. this.inviteInnerHtml ='<table style="background-repeat:no-repeat" width="439" height="160" border="0" cellpadding="0" cellspacing="0" background="' +baseUrl+ '/images/red_invite_bg.gif">';
  1165. this.inviteInnerHtml +='<tr style="cursor:move;"><td colspan="7" width="439" height="27"><span style="color:#FFFFFF;font-size:12px;">&nbsp;&nbsp;&nbsp;Live800 - '+URLDecode(preferences["invite_title"])+'</span></td></tr>';
  1166. this.inviteInnerHtml +='<tr><td rowspan="3" width="132" height="132"></td>';
  1167. this.inviteInnerHtml +='<td colspan="5" width="296" height="97">'+getInviteContent()+'</td>';
  1168. this.inviteInnerHtml +='<td width="11" height="97"></td></tr>';
  1169. this.inviteInnerHtml +='<tr><td width="141" height="22"></td>';
  1170. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt1+ '" onclick="globalInviteWindow.accept();" style="cursor:pointer"></td>';
  1171. this.inviteInnerHtml +='<td width="12" height="22"></td>';
  1172. this.inviteInnerHtml +='<td width="66" height="22"><img src="' +baseUrl+bt2+ '" onclick="globalInviteWindow.refuse();" style="cursor:pointer"></td>';
  1173. this.inviteInnerHtml +='<td colspan="2" width="22" height="22"></td></tr>';
  1174. this.inviteInnerHtml +='<tr><td colspan="6" width="307" height="13"></td></tr>';
  1175. this.inviteInnerHtml +='<tr><td width="132" height="1"></td>';
  1176. this.inviteInnerHtml +='<td width="141" height="1"></td>';
  1177. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1178. this.inviteInnerHtml +='<td width="12" height="1"></td>';
  1179. this.inviteInnerHtml +='<td width="66" height="1"></td>';
  1180. this.inviteInnerHtml +='<td width="11" height="1"></td>';
  1181. this.inviteInnerHtml +='<td width="11" height="1"></td> </tr></table>';
  1182. }
  1183. this.layerHtml = "<div id="InviteWindow" onmousedown="popDivMoveStart()"  style="z-index:8888;position:absolute;visibility:hidden;left:500px;top:200px;">";
  1184. this.layerHtml += "";
  1185. this.layerHtml += "</div>";
  1186. document.write(this.layerHtml);
  1187. }
  1188. function openFlashWin(){
  1189. var attr='width=541,height=401';
  1190. var tempUrl=this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"]+"/chatClient/chatbox.jsp?"+getGid()+getParam()+"&companyID="+ this.preferences["companyID"]+getEnterUrl()+"&"+getTrustfulVisitorInfo();
  1191. var newWin=window.open(tempUrl,'',attr);
  1192. globalInviteWindow.hide();
  1193. }
  1194. var popDivDiffX=null;
  1195. var popDivDiffY=null;
  1196. var floadttime;
  1197. function getEnterUrl()
  1198. {
  1199. var url="";
  1200. if(enterurl=="null")
  1201. enterurl=document.URL;
  1202. url=URLEncode(enterurl);
  1203. return "&enterurl="+url;
  1204. };
  1205. function popDivMoveStart(){
  1206. clearTimeout(floadttime);
  1207. var InviteWindow=document.getElementById("InviteWindow");
  1208. popDivDiffX=event.x-InviteWindow.style.pixelLeft;
  1209. popDivDiffY=event.y-InviteWindow.style.pixelTop;
  1210. window.document.body.attachEvent("onmousemove",popDivMove);
  1211. window.document.body.attachEvent("onmouseup",popDivMoveStop);
  1212. InviteWindow.setCapture();
  1213. };
  1214. function popDivMove(){
  1215. if(popDivDiffX!=null){
  1216. if(event.x<10 || event.y<10||event.x>document.body.clientWidth||event.y>document.body.clientHeight){
  1217. popDivMoveStop();
  1218. return;
  1219. }
  1220. document.getElementById("InviteWindow").style.pixelLeft=event.x-popDivDiffX;
  1221. document.getElementById("InviteWindow").style.pixelTop=event.y-popDivDiffY;
  1222. }
  1223. };
  1224. function popDivMoveStop(){
  1225. if(popDivDiffX != null){
  1226. document.getElementById("InviteWindow").releaseCapture();
  1227. popDivDiffX=null;
  1228. popDivDiffY=null;
  1229. window.document.body.detachEvent("onmousemove",popDivMove);
  1230. window.document.body.detachEvent("onmouseup",popDivMoveStop);
  1231.  }
  1232. };
  1233. function resizeInvite(){
  1234. document.getElementById("InviteWindow").style.top=document.body.scrollTop+(document.body.clientHeight-document.getElementById("InviteWindow").offsetHeight)/2;
  1235. document.getElementById("InviteWindow").style.left=document.body.scrollLeft+(document.body.clientWidth-document.getElementById("InviteWindow").offsetWidth)/2;
  1236. };
  1237. function InviteWindow_showTimer()
  1238. {
  1239. if (this.loaded && this.showInvite)
  1240. {
  1241. var top;
  1242. var left;
  1243. if (Sys.IE)
  1244. {
  1245. if(this.inviteInnerHtml == null)
  1246. this.inviteInnerHtml=Sys.getObj('InviteWindow').innerHTML;
  1247. if(Sys.getObj('InviteWindow').innerHTML.indexOf('live800')==-1){
  1248. Sys.getObj('InviteWindow').innerHTML = this.inviteInnerHtml;
  1249. }
  1250.     scrollPosY = 0;
  1251.     scrollPosX = 0;
  1252.     eval('try {' + 'if (typeof(document.documentElement) != "undefined") {' +  'scrollPosY = document.documentElement.scrollTop;' +  'scrollPosX = document.documentElement.scrollLeft;' + '}' + '} catch (e) {}');
  1253.     scrollPosY = Math.max(document.body.scrollTop, scrollPosY);
  1254.         scrollPosX = Math.max(document.body.scrollLeft, scrollPosX);
  1255.         top = scrollPosY;
  1256.         left = scrollPosX;
  1257.         if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left))){
  1258.         document.all.InviteWindow.style.visibility = 'visible';
  1259.         }
  1260.         else
  1261.         {
  1262.         document.all.InviteWindow.style.visibility = 'hidden';
  1263.         }
  1264.   }
  1265.   else if (Sys.NS)
  1266.   {
  1267.   top = pageYOffset;
  1268.   left = pageXOffset;
  1269.   if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left)))
  1270.   {
  1271.   document.layers.InviteWindow.visibility = 'visible';
  1272.   }
  1273.   else
  1274.   {
  1275.   document.layers.InviteWindow.visibility = 'hidden';
  1276.   }
  1277.   }
  1278.   else if (Sys.DOM)
  1279.   {
  1280.   if(this.inviteInnerHtml == null)
  1281. this.inviteInnerHtml=Sys.getObj('InviteWindow').innerHTML;
  1282. if(Sys.getObj('InviteWindow').innerHTML.indexOf('live800')==-1)
  1283. {
  1284. Sys.getObj('InviteWindow').innerHTML = this.inviteInnerHtml;
  1285. }
  1286.     scrollPosY = 0;
  1287.     scrollPosX = 0;
  1288.     eval('try {' + 'if (typeof(document.documentElement) != "undefined") {' +  'scrollPosY = document.documentElement.scrollTop;' +  'scrollPosX = document.documentElement.scrollLeft;' + '}' + '} catch (e) {}');
  1289.     scrollPosY = Math.max(document.body.scrollTop, scrollPosY);
  1290.         scrollPosX = Math.max(document.body.scrollLeft, scrollPosX);
  1291.  
  1292.   top = pageYOffset;
  1293.   left = pageXOffset;
  1294.   if ((this.lastTop < 0) || ((this.lastTop == top) && (this.lastLeft == left)))
  1295.   {
  1296.   Sys.getObj('InviteWindow').style.visibility = 'visible';
  1297.   }
  1298.   else
  1299.   {
  1300.   Sys.getObj('InviteWindow').style.visibility = 'hidden';
  1301.   }
  1302.   }
  1303.   this.lastTop = top;
  1304.   this.lastLeft = left;
  1305.   //write cookie flag
  1306. if(preferences["invite_auto"]==2&&(getCookie("hasVisited")==null||typeof getCookie("hasVisited")=="undefined")){
  1307.   setCookie("hasVisited","true");
  1308.   }/*
  1309.   if(getCookie("hasVisited")==null||typeof getCookie("hasVisited")=="undefined"){
  1310.   setCookie("hasVisited","true");
  1311.   }*/
  1312.   }
  1313.   resizeInvite();
  1314.   floadttime=setTimeout('globalInviteWindow.showTimer()', 250);
  1315. };
  1316. function InviteWindow_scrollPlace()
  1317. {
  1318. var y;
  1319. var x;
  1320. y = this.floatTop;
  1321.     if (document.body)
  1322.         x = document.body.clientWidth -250 - this.floatLeft;
  1323.     else
  1324.         x = innerWidth - 250 - this.floatLeft;
  1325. var obj = null;
  1326. if (Sys.IE)
  1327. {
  1328. obj = document.all.InviteWindow.style;
  1329. }
  1330. else if (Sys.NS)
  1331. {
  1332. obj = document.layers.InviteWindow;
  1333. }
  1334. else if (Sys.DOM)
  1335. {
  1336. obj = Sys.getObj('InviteWindow').style;
  1337. }
  1338. if (Sys.IE)
  1339. {
  1340. scrollPosY = 0;
  1341. scrollPosX = 0;
  1342. eval('try {' + 'if (typeof(document.documentElement) != "undefined") {' + 'scrollPosY = document.documentElement.scrollTop;' + 'scrollPosX = document.documentElement.scrollLeft;' + '}' + '} catch (e) {}');
  1343. scrollPosY = Math.max(document.body.scrollTop, scrollPosY);
  1344. scrollPosX = Math.max(document.body.scrollLeft, scrollPosX);
  1345. obj.left = scrollPosX + x - 50 + 'px';
  1346. obj.top = scrollPosY + y + 'px';
  1347. }
  1348. else if (Sys.NS)
  1349. {
  1350. obj.left = pageXOffset + x;
  1351. obj.top = pageYOffset + y;
  1352. }
  1353. else if (Sys.DOM)
  1354. {
  1355. obj.left = pageXOffset + x + 'px';
  1356. obj.top = pageYOffset + y + 'px';
  1357. }
  1358. };
  1359. function InviteWindow_show()
  1360. {
  1361. if(getCookie("hasVisited")!=null&&getCookie("hasVisited")=="true"&&this.operatorInvite&&preferences["invite_auto"]==2){
  1362. return;
  1363. }
  1364. this.showInvite = true;
  1365. if (Sys.IE)
  1366. {
  1367.   document.all.InviteWindow.style.visibility = 'visible';
  1368.   }
  1369.   else if (Sys.NS)
  1370.   {
  1371. document.layers.InviteWindow.visibility = 'visible';
  1372. }
  1373.   else if (Sys.DOM)
  1374.   {
  1375. Sys.getObj('InviteWindow').style.visibility = 'visible';
  1376.   }
  1377. };
  1378. function InviteWindow_hide()
  1379. {
  1380. this.showInvite = false;
  1381. if (Sys.IE)
  1382. {
  1383.   document.all.InviteWindow.style.visibility = 'hidden';
  1384.   }
  1385.   else if (Sys.NS)
  1386.   {
  1387.   document.layers.InviteWindow.visibility = 'hidden';
  1388. }
  1389.   else if (Sys.DOM)
  1390.   {
  1391. Sys.getObj('InviteWindow').style.visibility = 'hidden';
  1392.   }
  1393. };
  1394. function InviteWindow_accept()
  1395. {
  1396. this.hide();
  1397. if(this.isauto){
  1398. this.parentObject.onIconClick();
  1399. }else{
  1400. this.parentObject.onInviteWindowAccept();
  1401. }
  1402. };
  1403. function InviteWindow_refuse()
  1404. {
  1405. this.hide();
  1406. if(!this.isauto)
  1407. this.parentObject.onInviteWindowRefuse();
  1408. };
  1409. function VisitServer(inLogger, inPreferences, inVisitClient, inSendDriver)
  1410. {
  1411. this.logger = inLogger;
  1412. this.preferences = inPreferences;
  1413. this.visitClient = inVisitClient;
  1414. this.sendDriver = inSendDriver;
  1415. this.visitServerTimer = null;
  1416. this.refuseInvite = VisitServer_refuseInvite;
  1417. this.acceptInvite = VisitServer_acceptInvite;
  1418. this.initiatedChat = VisitServer_initiatedChat;
  1419. this.getAcceptInviteUrl = VisitServer_getAcceptInviteUrl;
  1420. this.getInitiatedChatUrl = VisitServer_getInitiatedChatUrl;
  1421. this.getCallUrl = VisitServer_getCallUrl;
  1422. this.start = VisitServer_start;
  1423. this.stop = VisitServer_stop;
  1424. }
  1425. function VisitServer_getCallUrl()
  1426. {
  1427. var openUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"]+ this.preferences["baseChatHtmlDir"] +"/chatbox.jsp?"+getGid()+getParam()+getTrustfulVisitorInfo();
  1428. openUrl += "&companyID=" + this.preferences["companyID"]+"&";
  1429. if(this.preferences["skin"] != null)
  1430. openUrl += "&skin=" + this.preferences["skin"];
  1431. if(this.preferences["chatBanner"] != null)
  1432. openUrl += "&chatBanner=" + this.preferences["chatBanner"];
  1433. if(this.preferences["chatBannerLink"] != null)
  1434. openUrl += "&chatBannerLink=" + this.preferences["chatBannerLink"];
  1435. if(typeof live800_configContent != "undefined" && live800_configContent != null)
  1436. openUrl += "&configID=" + live800_configID;
  1437. return openUrl+getEnterUrl();
  1438. }
  1439. function VisitServer_getInitiatedChatUrl()
  1440. {
  1441. var openUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + this.preferences["baseWebapp"] + this.preferences["baseChatHtmlDir"] +"/chatbox.jsp?"+getGid()+"&companyID=" + this.preferences["companyID"] +"&chatType=2";
  1442. if(typeof this.preferences["configID"] != "undefined" && this.preferences["configID"] != null && this.preferences["configID"] != "")
  1443. {
  1444. openUrl += "&configID=" + this.preferences["configID"];
  1445. }
  1446. if(this.preferences["skin"] != null)
  1447. openUrl += "&skin=" + this.preferences["skin"];
  1448. if(this.preferences["chatBanner"] != null)
  1449. openUrl += "&chatBanner=" + this.preferences["chatBanner"];
  1450. if(this.preferences["chatBannerLink"] != null)
  1451. openUrl += "&chatBannerLink=" + this.preferences["chatBannerLink"];
  1452. if(typeof live800_configContent != "undefined" && live800_configContent != null)
  1453. openUrl += "&configID=" + live800_configID;
  1454. return openUrl+getEnterUrl()+"&"+getTrustfulVisitorInfo();
  1455. };
  1456. function VisitServer_getAcceptInviteUrl()
  1457. {
  1458. var openUrl = this.preferences["protocol"] + "://" + this.preferences["baseUrl"] + live800_baseWebApp+"/SurferServer?&cmd=102";
  1459. openUrl += "&accept=1";
  1460. openUrl += "&visitorIDInSession=" + this.preferences["visitorIDInSession"];
  1461. openUrl += "&companyID=" + this.preferences["companyID"];
  1462. if(typeof this.preferences["configID"] != "undefined" && this.preferences["configID"] != null && this.preferences["configID"] !="")
  1463. openUrl += "&configID=" + live800_configID;
  1464. if(typeof live800_configContent != "undefined" && live800_configContent != null)
  1465. openUrl += "&configID=" + live800_configID;
  1466. return openUrl+"&"+getGid()+getParam()+getTrustfulVisitorInfo();
  1467. };
  1468. function VisitServer_start()
  1469. {
  1470. //this.visitServerTimer = setTimeout('globalVisitServer.getConfigInServer()',100);
  1471. };
  1472. function VisitServer_stop()
  1473. {
  1474. clearTimeout(this.visitServerTimer);
  1475. };
  1476. function VisitServer_refuseInvite()
  1477. {
  1478. var params = new Array();
  1479. params[0] = "companyID=" + this.preferences["companyID"];
  1480. params[1] = "accept=0";
  1481. var rpcMethod = new RpcMethod("SurferServer", "102", params, 0, null, null);
  1482. this.sendDriver.execute(rpcMethod);
  1483. };
  1484. function VisitServer_acceptInvite()
  1485. {
  1486. var params = new Array();
  1487. params[0] = "companyID=" + this.preferences["companyID"];
  1488. params[1] = "accept=1";
  1489. var rpcMethod = new RpcMethod("SurferServer", "102", params, 0, null, null);
  1490. this.sendDriver.execute(rpcMethod);
  1491. };
  1492. function VisitServer_initiatedChat()
  1493. {
  1494. var params = new Array();
  1495. params[0] = "companyID=" + this.preferences["companyID"];
  1496. var rpcMethod = new RpcMethod("SurferServer", "109", params, 0, null, null);
  1497. this.sendDriver.execute(rpcMethod);
  1498. }
  1499. function VisitServer_call()
  1500. {
  1501. };
  1502. function VisitHandle(inLogger, inPreferences, inVisitClient, inWindow, inInviteWindow, inIcon)
  1503. {
  1504. this.logger = inLogger;
  1505. this.preferences = inPreferences;
  1506. this.visitClient = inVisitClient;
  1507. this.visitWindow = inWindow;
  1508. this.visitDocument = inWindow.document;
  1509. this.inviteWindow = inInviteWindow;
  1510. this.icon = inIcon;
  1511. this.inviteWindow.parentObject = this;
  1512. if(this.icon != null)
  1513. this.icon.parentObject = this;
  1514. this.chatWindow = null;
  1515. this.showInvite = VisitHandle_showInvite;
  1516. this.hideInvite = VisitHandle_hideInvite;
  1517. this.openInitiatedChat = VisitHandle_openInitiatedChat;
  1518. this.reloadIcon = VisitHandle_reloadIcon;
  1519. this.onInviteWindowAccept = VisitHandle_onInviteWindowAccept;
  1520. this.onInviteWindowRefuse = VisitHandle_onInviteWindowRefuse;
  1521. this.onIconClick = VisitHandle_onIconClick;
  1522.     this.initListener = VisitHandle_initListener;
  1523. this.initListener();
  1524. }
  1525. function VisitHandle_onIconClick()
  1526. {
  1527. var openUrl = this.visitClient.getCallUrl();
  1528. var winAttr = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=541,height=401';
  1529. if (typeof(this.chatWindow) == "undefined"||this.chatWindow==null)
  1530. {
  1531. this.chatWindow = window.open(openUrl, 'chatbox'+ this.preferences["companyID"], winAttr);
  1532. }
  1533. try
  1534. {
  1535. this.chatWindow.focus();
  1536. this.chatWindow.opener=window;
  1537. }
  1538. catch(e)
  1539. {
  1540. this.chatWindow = window.open(openUrl, 'chatbox'+ this.preferences["companyID"], winAttr);
  1541. }
  1542.     return false;
  1543. }
  1544. function VisitHandle_onInviteWindowAccept()
  1545. {
  1546. var openUrl = this.visitClient.getAcceptInviteUrl();
  1547. var winAttr = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=541,height=401';
  1548. this.chatWindow = window.open(openUrl, 'chatbox'+ this.preferences["companyID"], winAttr);
  1549. try
  1550. {
  1551. this.chatWindow.focus();
  1552. this.chatWindow.opener=window;
  1553. }
  1554. catch(e)
  1555. {
  1556. this.chatWindow = window.open(openUrl, 'chatbox'+ this.preferences["companyID"], winAttr);
  1557. }
  1558.     return false;
  1559. };
  1560. function VisitHandle_onInviteWindowRefuse()
  1561. {
  1562. this.visitClient.refuseInvite();
  1563. };
  1564. function VisitHandle_showInvite()
  1565. {
  1566. this.inviteWindow.operatorInvite=false;
  1567. this.visitWindow.focus();
  1568. this.inviteWindow.show();
  1569. this.inviteWindow.isauto = false;
  1570. this.inviteWindow.operatorInvite=true;
  1571. };
  1572. function VisitHandle_hideInvite()
  1573. {
  1574. this.inviteWindow.hide();
  1575. };
  1576. function VisitHandle_openInitiatedChat()
  1577. {
  1578. //this.visitClient.initiatedChat();
  1579. var openUrl = this.visitClient.getInitiatedChatUrl();
  1580. var winAttr = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=541,height=401';
  1581. try
  1582. {
  1583. this.chatWindow = window.open(openUrl, 'chatbox'+ this.preferences["companyID"], winAttr);
  1584. this.chatWindow.focus();
  1585. this.chatWindow.opener=window;
  1586. }
  1587. catch(e)
  1588. {
  1589. /*for must initiated chat*/
  1590. openUrl += '&blocked=1';
  1591. window.location = openUrl;
  1592. }
  1593.     return false;
  1594. };
  1595. function VisitHandle_reloadIcon()
  1596. {
  1597. var live800iconList = document.getElementsByName("live800icon");
  1598. if(live800iconList == null) return;
  1599. for(i=0; i<live800iconList.length; i++)
  1600. {
  1601. temp = live800iconList[i].src ;
  1602. temp += "&rpcImageId=" + (new Date()).getTime();
  1603. live800iconList[i].src = temp;
  1604. }
  1605. };
  1606. function VisitHandle_initListener()
  1607. {
  1608. this.visitClient.addMessageListener(this);
  1609. };
  1610. if(live800_companyID == null || live800_companyID == ""){alert("miss companyID");}
  1611. else
  1612. {
  1613. preferences = new Array();
  1614. preferences["companyID"] = live800_companyID;
  1615. preferences["float"] = (typeof live800_float != "undefined" ? live800_float : "1");
  1616. preferences["iconIndex"] = (typeof live800_iconIndex !="undefined" ? live800_iconIndex : "0");
  1617. preferences["online"] =  (typeof live800_online !="undefined" ? live800_online : null);
  1618. preferences["offline"] =  (typeof live800_offline !="undefined" ? live800_offline : null);
  1619. preferences["floatToRight"] = (typeof live800_floatToRight !="undefined" ? live800_floatToRight : "1");
  1620. preferences["skin"] = (typeof live800_skin !="undefined" ? live800_skin : "0");
  1621. preferences["chatBanner"] = (typeof live800_chatBanner !="undefined" ? live800_chatBanner : null);
  1622. preferences["chatBannerLink"] = (typeof live800_chatBannerLink !="undefined" ? live800_chatBannerLink : null);
  1623. preferences["status"] = (typeof live800_status !="undefined" ? live800_status : null);
  1624. if(typeof live800_configContent != "undefined")
  1625. {
  1626. params = Sys.urlToParams(live800_configContent);
  1627. preferences["configID"] = live800_configID;
  1628. preferences["invite_auto"] = (typeof params["live800_invite_auto"] !="undefined" ? params["live800_invite_auto"] : 1);
  1629. preferences["invite_delay"] = (typeof params["live800_invite_delay"] !="undefined" ? params["live800_invite_delay"] : 10);
  1630. preferences["invite_title"] = (typeof params["live800_invite_title"] !="undefined" ? params["live800_invite_title"] : unescape("Live800%u7F51%u7AD9%u5728%u7EBF%u5BA2%u670D%u7CFB%u7EDF"));
  1631. preferences["invite_style"] = (typeof params["live800_invite_style"] !="undefined" ? params["live800_invite_style"] : null);
  1632. preferences["invite_top"] = (typeof params["live800_invite_top"] !="undefined" ? params["live800_invite_top"] : 0);
  1633. }
  1634. else
  1635. {
  1636. preferences["configID"] = 1;
  1637. preferences["invite_auto"] = 1;
  1638. preferences["invite_delay"] = 10;
  1639. preferences["invite_style"]=null;
  1640. preferences["invite_top"]=0;
  1641. preferences["invite_title"] = unescape("Live800%u7F51%u7AD9%u5728%u7EBF%u5BA2%u670D%u7CFB%u7EDF");
  1642. }
  1643. preferences["protocol"] = "http";
  1644. preferences["baseUrl"] = live800_baseUrl;
  1645. preferences["baseHtmlUrl"] =live800_baseHtmlUrl;
  1646. preferences["baseWebapp"] = live800_baseWebApp;
  1647. preferences["baseChatHtmlDir"] = live800_baseChatHtmlDir;
  1648. preferences["visitorIDInSession"] = preferences["companyID"] + "chater";
  1649. var globalLogger = new Logger();
  1650. var globalSendDriver = new SendDriver(globalLogger, preferences);
  1651. var globalReceiveDriver = new ReceiveDriver(globalLogger, preferences);
  1652. var globalVisitClient = new VisitClient(globalLogger, preferences, globalReceiveDriver, globalSendDriver);
  1653. var globalVisitServer = globalVisitClient.visitServer;
  1654. var globalIcon = null;
  1655. if(typeof live800_configContent == "undefined")
  1656. {
  1657. if(preferences["float"]=="1")
  1658. {
  1659. globalIcon = globalFloatIcon = new FloatIcon(globalLogger, preferences, globalVisitClient, window);
  1660. }
  1661. else
  1662. {
  1663. globalIcon = globalStaticIcon = new StaticIcon(globalLogger, preferences, globalVisitClient, window);
  1664. }
  1665. globalIcon.start();
  1666. }
  1667. /*var live800_configContent to detect is a a version 3 live800 js*/
  1668. var globalInviteWindow = new InviteWindow(globalLogger, preferences, globalVisitClient, window);
  1669. var globalVisitHandle = new VisitHandle(globalLogger, preferences, globalVisitClient, window, globalInviteWindow, globalIcon);
  1670. globalVisitClient.start();
  1671. }