mirror of
				https://github.com/Mibew/design.git
				synced 2025-10-31 10:31:05 +03:00 
			
		
		
		
	Split chat.js
JavaScript's chat.js library split into several logical parts: chatcontroller.js, chatview.js and chatinit.js
This commit is contained in:
		
							parent
							
								
									edb40a06d3
								
							
						
					
					
						commit
						4cfac7bbef
					
				| @ -1,25 +0,0 @@ | ||||
| /* | ||||
|  This file is part of Mibew Messenger project. | ||||
|  http://mibew.org
 | ||||
| 
 | ||||
|  Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  License: http://mibew.org/license.php
 | ||||
| */ | ||||
| var FrameUtils={options:{},getDocument:function(a){return a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.document:a.document?a.document:null},initFrame:function(a){var b=this.getDocument(a);b.open();b.write("<html><head>");this.options.cssfile&&b.write('<link rel="stylesheet" type="text/css" media="all" href="'+this.options.cssfile+'">');b.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>");b.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom' name='bottom'></a>"); | ||||
| b.write("</body></html>");b.close();a.onload=function(){a.myHtml&&(FrameUtils.getDocument(a).getElementById("content").innerHTML+=a.myHtml,FrameUtils.scrollDown(a))}},insertIntoFrame:function(a,b){var c=this.getDocument(a).getElementById("content");null==c?(a.myHtml||(a.myHtml=""),a.myHtml+=b):c.innerHTML+=b},scrollDown:function(a){var b=this.getDocument(a).getElementById("bottom");if("opera"==myAgent)try{a.contentWindow.scrollTo(0,this.getDocument(a).getElementById("content").clientHeight)}catch(c){}b&& | ||||
| b.scrollIntoView(!1)}};ChatView=Class.create(); | ||||
| ChatView.prototype={statusTimeout:null,localizedStrings:{},predefinedAnswers:[],messageContainer:null,initialize:function(a,b){this.localizedStrings=a||{};this.predefinedAnswers=b||[];this.messageContainer="safari"==myRealAgent?self.frames[0]:$("chatwnd");FrameUtils.initFrame(this.messageContainer)},getLocaleString:function(a){return"undefined"==typeof this.localizedStrings[a]?!1:this.localizedStrings[a]},enableInput:function(a){var b=$("msgwnd");b&&(b.disabled=!a)},clearInput:function(){var a=$("msgwnd"); | ||||
| a&&(a.value="",a.focus())},showStatusDiv:function(a){$("engineinfo")&&($("engineinfo").style.display="inline",$("engineinfo").innerHTML=a)},setStatus:function(a){this.statusTimeout&&clearTimeout(this.statusTimeout);this.showStatusDiv(a);this.statusTimeout=setTimeout(this.clearStatus.bind(this),4E3)},clearStatus:function(){$("engineinfo").style.display="none"},showTyping:function(a){$("typingdiv")&&($("typingdiv").style.display=a?"inline":"none")},updateAvatar:function(a,b){var c="";""!=b&&(c='<img src="'+ | ||||
| a+'/images/free.gif" width="7" height="1" border="0" alt="" /><img src="'+b+'" border="0" alt=""/>');$("avatarwnd").innerHTML=c},displayMessages:function(a){for(var b=0;b<a.length;b++)this.outputMessage(a[b]);0<a.length&&FrameUtils.scrollDown(this.messageContainer)},outputMessage:function(a){FrameUtils.insertIntoFrame(this.messageContainer,a)},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"},hideNameField:function(){$("changename1").style.display= | ||||
| "none";$("changename2").style.display="inline"},updateUserName:function(a){$("unamelink").innerHTML=htmlescape(a)},changeSoundButtonState:function(a){$("soundimg").className=a?"tplimage isound":"tplimage inosound";(a=$("msgwnd"))&&a.focus()},displayPredefinedAnswer:function(a){var b=$("msgwnd");b.value=this.predefinedAnswers[a];b.focus()},resetSelectedIndex:function(a){a.selectedIndex=0}};ChatController=Class.create(); | ||||
| ChatController.prototype={options:{},thread:null,server:null,view:null,cansend:!0,skipNextSound:!0,focused:!0,message:null,ownThread:null,initialize:function(a,b,c,d){this.options=d;this.thread=c;this.server=a;this.view=b;this.message=$("msgwnd");this.ownThread=null!=this.message;this.message&&(this.message.onkeydown=this.handleKeyDown.bind(this),this.message.onfocus=function(){this.focused=!0}.bind(this),this.message.onblur=function(){this.focused=!1}.bind(this));this.server.callFunctionsPeriodically(this.updateFunctionBuilder.bind(this), | ||||
| this.updateChatState.bind(this));this.server.registerFunction("updateMessages",this.updateMessages.bind(this));this.server.registerFunction("setupAvatar",this.setupAvatar.bind(this));this.server.runUpdater()},handleException:function(){this.view.setStatus("offline, reconnecting");this.view.enableInput(!0)},handleTimeout:function(){this.view.setStatus("timeout, reconnecting");this.view.enableInput(!0)},refresh:function(){this.server.restartUpdater()},postMessage:function(a){""!=a&&this.cansend&&(this.cansend= | ||||
| !1,this.skipNextSound=!0,"opera"!=myRealAgent&&this.view.enableInput(!1),this.server.callFunctions([{"function":"post",arguments:{references:{},"return":{},message:a,threadId:this.thread.threadid,token:this.thread.token,user:this.thread.user}}],function(){this.view.enableInput(!0);this.cansend=!0;this.view.clearInput()}.bind(this),!0))},changeName:function(a){this.skipNextSound=!0;this.server.callFunctions([{"function":"rename",arguments:{references:{},"return":{},threadId:this.thread.threadid,token:this.thread.token, | ||||
| name:a}}],function(a){a.errorCode&&this.handleError(a,"cannot rename")}.bind(this),!0)},closeThread:function(){(!this.view.getLocaleString("closeConfirmation")||confirm(this.view.getLocaleString("closeConfirmation")))&&this.server.callFunctions([{"function":"close",arguments:{references:{},"return":{closed:"closed"},threadId:this.thread.threadid,token:this.thread.token,lastId:this.thread.lastid,user:this.thread.user}}],this.onThreadClosed.bind(this),!0)},onThreadClosed:function(a){a.closed?window.close(): | ||||
| this.handleError(a,"cannot close")},setupAvatar:function(a){$("avatarwnd")&&this.thread.user&&this.view.updateAvatar(this.options.webimRoot,a.imageLink)},updateMessages:function(a){a.lastId&&(this.thread.lastid=a.lastId);this.view.displayMessages(a.messages);this.view.clearStatus();0<a.messages.length&&(this.skipNextSound||(a=$("soundimg"),(null==a||a.className.match(/\bisound\b/))&&playSound(this.options.webimRoot+"/sounds/new_message.wav")),this.focused||window.focus());this.skipNextSound=!1},updateFunctionBuilder:function(){return[{"function":"update", | ||||
| arguments:{"return":{typing:"typing",canPost:"canPost"},references:{},threadId:this.thread.threadid,token:this.thread.token,lastId:this.thread.lastid,typed:this.message&&""!=this.message.value,user:this.thread.user}}]},updateChatState:function(a){if(a.errorCode)this.handleError(a,"refresh failed");else if("undefined"!=typeof a.typing&&this.view.showTyping(a.typing),"undefined"!=typeof a.canPost&&(a.canPost&&!this.ownThread||this.ownThread&&!a.canPost))window.location.href=window.location.href},isSendkey:function(a, | ||||
| b){return 13==b&&(a||this.options.ignorectrl)||10==b},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);return this.message&&this.isSendkey(ctrl,a)?(a=this.message.value,this.options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1):!0},handleError:function(a){a.errorCode?this.view.setStatus(a.errorMessage):this.view.setStatus("reconnecting")},applyName:function(){this.changeName($("uname").value);this.view.hideNameField();this.view.updateUserName($("uname").value)}, | ||||
| showNameField:function(){this.view.showNameField()},selectPredefinedAnswer:function(a){var b=a.selectedIndex;0!=b&&(this.view.displayPredefinedAnswer(b-1),this.view.resetSelect(a))},toggleSound:function(){var a=$("soundimg");a&&(a.className.match(/\bisound\b/)?this.view.changeSoundButtonState(!1):this.view.changeSoundButtonState(!0))}}; | ||||
| Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&chatController.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){chatController.selectPredefinedAnswer(this)}},"div#changename2 a":function(a){a.onclick=function(){chatController.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){chatController.applyName();return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){13==(a||event).keyCode&& | ||||
| chatController.applyName()}},"a#refresh":function(a){a.onclick=function(){chatController.refresh()}},"a#togglesound":function(a){a.onclick=function(){chatController.toggleSound()}},"a.closethread":function(a){a.onclick=function(){chatController.closeThread()}}});var pluginManager=new PluginManager,chatController; | ||||
| EventHelper.register(window,"onload",function(){FrameUtils.options.cssfile=chatParams.cssfile;var a=new ChatServer(chatParams.serverParams),b=new Thread(chatParams.threadParams);chatParams.initPlugins(pluginManager,b,a);var c=new ChatView(chatParams.localizedStrings,chatParams.predefinedAnswers||[]);chatController=new ChatController(a,c,b,{ignorectrl:-1}.extend(chatParams.controllerParams||{}))}); | ||||
							
								
								
									
										16
									
								
								src/messenger/webim/js/164/chatcontroller.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/messenger/webim/js/164/chatcontroller.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| /* | ||||
|  This file is part of Mibew Messenger project. | ||||
|  http://mibew.org
 | ||||
| 
 | ||||
|  Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  License: http://mibew.org/license.php
 | ||||
| */ | ||||
| ChatController=Class.create(); | ||||
| ChatController.prototype={options:{},thread:null,server:null,view:null,cansend:!0,skipNextSound:!0,focused:!0,message:null,ownThread:null,initialize:function(a,b,c,d){this.options=d;this.thread=c;this.server=a;this.view=b;this.message=$("msgwnd");this.ownThread=null!=this.message;this.message&&(this.message.onkeydown=this.handleKeyDown.bind(this),this.message.onfocus=function(){this.focused=!0}.bind(this),this.message.onblur=function(){this.focused=!1}.bind(this));this.server.callFunctionsPeriodically(this.updateFunctionBuilder.bind(this),this.updateChatState.bind(this)); | ||||
| this.server.registerFunction("updateMessages",this.updateMessages.bind(this));this.server.registerFunction("setupAvatar",this.setupAvatar.bind(this));this.server.runUpdater()},handleException:function(){this.view.setStatus("offline, reconnecting");this.view.enableInput(!0)},handleTimeout:function(){this.view.setStatus("timeout, reconnecting");this.view.enableInput(!0)},refresh:function(){this.server.restartUpdater()},postMessage:function(a){""!=a&&this.cansend&&(this.cansend=!1,this.skipNextSound= | ||||
| !0,"opera"!=myRealAgent&&this.view.enableInput(!1),this.server.callFunctions([{"function":"post",arguments:{references:{},"return":{},message:a,threadId:this.thread.threadid,token:this.thread.token,user:this.thread.user}}],function(){this.view.enableInput(!0);this.cansend=!0;this.view.clearInput()}.bind(this),!0))},changeName:function(a){this.skipNextSound=!0;this.server.callFunctions([{"function":"rename",arguments:{references:{},"return":{},threadId:this.thread.threadid,token:this.thread.token, | ||||
| name:a}}],function(a){a.errorCode&&this.handleError(a,"cannot rename")}.bind(this),!0)},closeThread:function(){(!this.view.getLocaleString("closeConfirmation")||confirm(this.view.getLocaleString("closeConfirmation")))&&this.server.callFunctions([{"function":"close",arguments:{references:{},"return":{closed:"closed"},threadId:this.thread.threadid,token:this.thread.token,lastId:this.thread.lastid,user:this.thread.user}}],this.onThreadClosed.bind(this),!0)},onThreadClosed:function(a){a.closed?window.close(): | ||||
| this.handleError(a,"cannot close")},setupAvatar:function(a){$("avatarwnd")&&this.thread.user&&this.view.updateAvatar(this.options.webimRoot,a.imageLink)},updateMessages:function(a){a.lastId&&(this.thread.lastid=a.lastId);this.view.displayMessages(a.messages);this.view.clearStatus();0<a.messages.length&&(this.skipNextSound||(a=$("soundimg"),(null==a||a.className.match(/\bisound\b/))&&playSound(this.options.webimRoot+"/sounds/new_message.wav")),this.focused||window.focus());this.skipNextSound=!1},updateFunctionBuilder:function(){return[{"function":"update", | ||||
| arguments:{"return":{typing:"typing",canPost:"canPost"},references:{},threadId:this.thread.threadid,token:this.thread.token,lastId:this.thread.lastid,typed:this.message&&""!=this.message.value,user:this.thread.user}}]},updateChatState:function(a){if(a.errorCode)this.handleError(a,"refresh failed");else if("undefined"!=typeof a.typing&&this.view.showTyping(a.typing),"undefined"!=typeof a.canPost&&(a.canPost&&!this.ownThread||this.ownThread&&!a.canPost))window.location.href=window.location.href},isSendkey:function(a, | ||||
| b){return 13==b&&(a||this.options.ignorectrl)||10==b},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);return this.message&&this.isSendkey(ctrl,a)?(a=this.message.value,this.options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1):!0},handleError:function(a){a.errorCode?this.view.setStatus(a.errorMessage):this.view.setStatus("reconnecting")},applyName:function(){this.changeName($("uname").value);this.view.hideNameField();this.view.updateUserName($("uname").value)}, | ||||
| showNameField:function(){this.view.showNameField()},selectPredefinedAnswer:function(a){var b=a.selectedIndex;0!=b&&(this.view.displayPredefinedAnswer(b-1),this.view.resetSelect(a))},toggleSound:function(){var a=$("soundimg");a&&(a.className.match(/\bisound\b/)?this.view.changeSoundButtonState(!1):this.view.changeSoundButtonState(!0))}}; | ||||
							
								
								
									
										11
									
								
								src/messenger/webim/js/164/chatinit.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/messenger/webim/js/164/chatinit.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| /* | ||||
|  This file is part of Mibew Messenger project. | ||||
|  http://mibew.org
 | ||||
| 
 | ||||
|  Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  License: http://mibew.org/license.php
 | ||||
| */ | ||||
| var chatController=null,pluginManager=new PluginManager; | ||||
| Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&chatController.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){chatController.selectPredefinedAnswer(this)}},"div#changename2 a":function(a){a.onclick=function(){chatController.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){chatController.applyName();return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){13==(a||event).keyCode&& | ||||
| chatController.applyName()}},"a#refresh":function(a){a.onclick=function(){chatController.refresh()}},"a#togglesound":function(a){a.onclick=function(){chatController.toggleSound()}},"a.closethread":function(a){a.onclick=function(){chatController.closeThread()}}}); | ||||
| EventHelper.register(window,"onload",function(){FrameUtils.options.cssfile=chatParams.cssfile;var a=new ChatServer(chatParams.serverParams),b=new Thread(chatParams.threadParams);chatParams.initPlugins(pluginManager,b,a);var c=new ChatView(chatParams.localizedStrings,chatParams.predefinedAnswers||[]);chatController=new ChatController(a,c,b,{ignorectrl:-1}.extend(chatParams.controllerParams||{}))}); | ||||
							
								
								
									
										14
									
								
								src/messenger/webim/js/164/chatview.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/messenger/webim/js/164/chatview.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| /* | ||||
|  This file is part of Mibew Messenger project. | ||||
|  http://mibew.org
 | ||||
| 
 | ||||
|  Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  License: http://mibew.org/license.php
 | ||||
| */ | ||||
| var FrameUtils={options:{},getDocument:function(a){return a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.document:a.document?a.document:null},initFrame:function(a){var b=this.getDocument(a);b.open();b.write("<html><head>");this.options.cssfile&&b.write('<link rel="stylesheet" type="text/css" media="all" href="'+this.options.cssfile+'">');b.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>");b.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom' name='bottom'></a>"); | ||||
| b.write("</body></html>");b.close();a.onload=function(){a.myHtml&&(FrameUtils.getDocument(a).getElementById("content").innerHTML+=a.myHtml,FrameUtils.scrollDown(a))}},insertIntoFrame:function(a,b){var c=this.getDocument(a).getElementById("content");null==c?(a.myHtml||(a.myHtml=""),a.myHtml+=b):c.innerHTML+=b},scrollDown:function(a){var b=this.getDocument(a).getElementById("bottom");if("opera"==myAgent)try{a.contentWindow.scrollTo(0,this.getDocument(a).getElementById("content").clientHeight)}catch(c){}b&& | ||||
| b.scrollIntoView(!1)}};ChatView=Class.create(); | ||||
| ChatView.prototype={statusTimeout:null,localizedStrings:{},predefinedAnswers:[],messageContainer:null,initialize:function(a,b){this.localizedStrings=a||{};this.predefinedAnswers=b||[];this.messageContainer="safari"==myRealAgent?self.frames[0]:$("chatwnd");FrameUtils.initFrame(this.messageContainer)},getLocaleString:function(a){return"undefined"==typeof this.localizedStrings[a]?!1:this.localizedStrings[a]},enableInput:function(a){var b=$("msgwnd");b&&(b.disabled=!a)},clearInput:function(){var a=$("msgwnd"); | ||||
| a&&(a.value="",a.focus())},showStatusDiv:function(a){$("engineinfo")&&($("engineinfo").style.display="inline",$("engineinfo").innerHTML=a)},setStatus:function(a){this.statusTimeout&&clearTimeout(this.statusTimeout);this.showStatusDiv(a);this.statusTimeout=setTimeout(this.clearStatus.bind(this),4E3)},clearStatus:function(){$("engineinfo").style.display="none"},showTyping:function(a){$("typingdiv")&&($("typingdiv").style.display=a?"inline":"none")},updateAvatar:function(a,b){var c="";""!=b&&(c='<img src="'+ | ||||
| a+'/images/free.gif" width="7" height="1" border="0" alt="" /><img src="'+b+'" border="0" alt=""/>');$("avatarwnd").innerHTML=c},displayMessages:function(a){for(var b=0;b<a.length;b++)this.outputMessage(a[b]);0<a.length&&FrameUtils.scrollDown(this.messageContainer)},outputMessage:function(a){FrameUtils.insertIntoFrame(this.messageContainer,a)},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"},hideNameField:function(){$("changename1").style.display= | ||||
| "none";$("changename2").style.display="inline"},updateUserName:function(a){$("unamelink").innerHTML=htmlescape(a)},changeSoundButtonState:function(a){$("soundimg").className=a?"tplimage isound":"tplimage inosound";(a=$("msgwnd"))&&a.focus()},displayPredefinedAnswer:function(a){var b=$("msgwnd");b.value=this.predefinedAnswers[a];b.focus()},resetSelectedIndex:function(a){a.selectedIndex=0}}; | ||||
| @ -6,286 +6,6 @@ | ||||
|  * License: http://mibew.org/license.php
 | ||||
|  */ | ||||
| 
 | ||||
| var FrameUtils = { | ||||
| 
 | ||||
|     options: {}, | ||||
| 
 | ||||
|     getDocument: function(frm) { | ||||
|         if (frm.contentDocument) { | ||||
|             return frm.contentDocument; | ||||
|         } else if (frm.contentWindow) { | ||||
|             return frm.contentWindow.document; | ||||
|         } else if (frm.document) { | ||||
|             return frm.document; | ||||
|         } else { | ||||
|             return null; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     initFrame: function(frm) { | ||||
|         var doc = this.getDocument(frm); | ||||
|         doc.open(); | ||||
|         doc.write("<html><head>"); | ||||
|         if (this.options.cssfile) { | ||||
|             doc.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""+this.options.cssfile+"\">"); | ||||
|         } | ||||
|         doc.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>"); | ||||
|         doc.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom' name='bottom'></a>"); | ||||
|         doc.write("</body></html>"); | ||||
|         doc.close(); | ||||
|         frm.onload = function() { | ||||
|             if (frm.myHtml) { | ||||
|                 FrameUtils.getDocument(frm).getElementById('content').innerHTML += frm.myHtml; | ||||
|                 FrameUtils.scrollDown(frm); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     insertIntoFrame: function(frm, htmlcontent) { | ||||
|         var vcontent = this.getDocument(frm).getElementById('content'); | ||||
|         if (vcontent == null) { | ||||
|             if (!frm.myHtml) { | ||||
|                 frm.myHtml = ""; | ||||
|             } | ||||
|             frm.myHtml += htmlcontent; | ||||
|         } else { | ||||
|             vcontent.innerHTML += htmlcontent; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     scrollDown: function(frm) { | ||||
|         var vbottom = this.getDocument(frm).getElementById('bottom'); | ||||
|         if (myAgent == 'opera') { | ||||
|             try { | ||||
|                 frm.contentWindow.scrollTo(0,this.getDocument(frm).getElementById('content').clientHeight); | ||||
|             } catch(e) {} | ||||
|         } | ||||
|         if (vbottom) { | ||||
|             vbottom.scrollIntoView(false); | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| ChatView = Class.create(); | ||||
| ChatView.prototype = { | ||||
|     /** | ||||
|      * Status timeout identifier | ||||
|      * @type Number | ||||
|      * @private | ||||
|      */ | ||||
|     statusTimeout: null, | ||||
| 
 | ||||
|     /** | ||||
|      * Contains localized strings. Properties names are language key and | ||||
|      * properties values are localized strings | ||||
|      * @type Object | ||||
|      */ | ||||
|     localizedStrings: {}, | ||||
| 
 | ||||
|     /** | ||||
|      * Contains predefined answers configurable from administrative interface | ||||
|      * @type Array | ||||
|      */ | ||||
|     predefinedAnswers: [], | ||||
| 
 | ||||
|     /** | ||||
|      * Messages container DOM element | ||||
|      * @type Object | ||||
|      */ | ||||
|     messageContainer: null, | ||||
| 
 | ||||
|     /** | ||||
|      * Create an instance of ChatView | ||||
|      * @constructor | ||||
|      */ | ||||
|     initialize: function(localizedStrings, predefinedAnswers) { | ||||
|         this.localizedStrings = localizedStrings || {}; | ||||
|         this.predefinedAnswers = predefinedAnswers || []; | ||||
| 
 | ||||
|         this.messageContainer = (myRealAgent == 'safari') | ||||
|             ? self.frames[0] | ||||
|             : $("chatwnd"); | ||||
|         FrameUtils.initFrame(this.messageContainer); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Get localized string by language key | ||||
|      * @param {String} key Language key | ||||
|      * @returns {Boolean|String} Returns boolean FALSE if string with specified | ||||
|      * key is undefined and localized string otherwise | ||||
|      */ | ||||
|     getLocaleString: function(key) { | ||||
|         if (typeof this.localizedStrings[key] == 'undefined') { | ||||
|             return false; | ||||
|         } | ||||
|         return this.localizedStrings[key]; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Enables or disables input field | ||||
|      * @param {Boolean} val Use boolean true for enable input and false | ||||
|      * otherwise | ||||
|      */ | ||||
|     enableInput: function(val) { | ||||
|         var message = $('msgwnd'); | ||||
|         if (message) { | ||||
|             message.disabled = !val; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Clear message input element and set focus to it | ||||
|      */ | ||||
|     clearInput: function() { | ||||
|         var message = $('msgwnd'); | ||||
|         if(message) { | ||||
|             message.value = ''; | ||||
|             message.focus(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Displays status div and sets the status string into it | ||||
|      * @param {String} k Status string | ||||
|      */ | ||||
|     showStatusDiv: function(k) { | ||||
|         if ($("engineinfo")) { | ||||
|             $("engineinfo").style.display = 'inline'; | ||||
|             $("engineinfo").innerHTML = k; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Sets the status | ||||
|      * @param {String} k Status string | ||||
|      */ | ||||
|     setStatus: function(k) { | ||||
|         if (this.statusTimeout) { | ||||
|             clearTimeout(this.statusTimeout); | ||||
|         } | ||||
|         this.showStatusDiv(k); | ||||
|         this.statusTimeout = setTimeout(this.clearStatus.bind(this), 4000); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Hide the status string | ||||
|      */ | ||||
|     clearStatus: function() { | ||||
|         $("engineinfo").style.display='none'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Displays typing status | ||||
|      * @param {Boolean} istyping Indicates the other side of conversation is | ||||
|      * typing a message or not | ||||
|      */ | ||||
|     showTyping: function(istyping) { | ||||
|         if( $("typingdiv") ) { | ||||
|             $("typingdiv").style.display = istyping ? 'inline' : 'none'; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Updates operator's avatar | ||||
|      * @param {String} root Base path | ||||
|      * @param {String} imageLink New avatar URL | ||||
|      */ | ||||
|     updateAvatar: function(root, imageLink) { | ||||
|         var avatar = ""; | ||||
|         if (imageLink != "") { | ||||
|             avatar = '<img src="'+root+'/images/free.gif" width="7" height="1" border="0" alt="" />' + | ||||
|                 '<img src="'+imageLink+'" border="0" alt=""/>'; | ||||
|         } | ||||
|         $("avatarwnd").innerHTML = avatar; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Display all messages at the message window | ||||
|      * @param {Array} messages Messages array | ||||
|      */ | ||||
|     displayMessages: function(messages) { | ||||
|         // Output messages
 | ||||
|         for (var i = 0; i < messages.length; i++) { | ||||
|             this.outputMessage(messages[i]); | ||||
|         } | ||||
|         // There are some new messages
 | ||||
|         if (messages.length > 0) { | ||||
|             FrameUtils.scrollDown(this.messageContainer); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Add message to the message window | ||||
|      * @param {String} message HTML message to insert | ||||
|      * @private | ||||
|      */ | ||||
|     outputMessage: function(message) { | ||||
|         FrameUtils.insertIntoFrame(this.messageContainer, message); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Show new user name input | ||||
|      */ | ||||
|     showNameField: function() { | ||||
|         $('changename1').style.display='inline'; | ||||
|         $('changename2').style.display='none'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Hide new user name input | ||||
|      */ | ||||
|     hideNameField: function() { | ||||
|         $('changename1').style.display='none'; | ||||
|         $('changename2').style.display='inline'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Update user name in chat window | ||||
|      * @param {String} name New user's name | ||||
|      */ | ||||
|     updateUserName: function(name) { | ||||
|         $('unamelink').innerHTML = htmlescape(name); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Change sound button state. | ||||
|      * | ||||
|      * @param {Boolean} enable TRUE if sound enabled and FALSE otherwise | ||||
|      */ | ||||
|     changeSoundButtonState: function(enable) { | ||||
|         var tsound = $('soundimg'); | ||||
|         if (enable) { | ||||
|             tsound.className = "tplimage isound"; | ||||
|         } else { | ||||
|             tsound.className = "tplimage inosound"; | ||||
|         } | ||||
|         var messagePane = $('msgwnd'); | ||||
|         if(messagePane) { | ||||
|             messagePane.focus(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Add predefined answer to message input element and set focus to it. | ||||
|      * | ||||
|      * @param {Number} answerIndex Index of predefined answer | ||||
|      */ | ||||
|     displayPredefinedAnswer: function(answerIndex) { | ||||
|         var message = $('msgwnd'); | ||||
|         message.value = this.predefinedAnswers[answerIndex]; | ||||
|         message.focus(); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Set selectedIndex property of the select box DOM element passed as | ||||
|      * argument to zero. | ||||
|      * @param {Object} elem Select box DOM element | ||||
|      */ | ||||
|     resetSelectedIndex: function(elem) { | ||||
|         elem.selectedIndex = 0; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ChatController = Class.create(); | ||||
| ChatController.prototype = { | ||||
|     /** | ||||
| @ -694,82 +414,4 @@ ChatController.prototype = { | ||||
|             this.view.changeSoundButtonState(true); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Behaviour.register({ | ||||
|     '#postmessage a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             var message = $('msgwnd'); | ||||
|             if (message) { | ||||
|                 chatController.postMessage(message.value); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'select#predefined' : function(el) { | ||||
|         el.onchange = function() { | ||||
|             chatController.selectPredefinedAnswer(this); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename2 a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.showNameField(); | ||||
|             return false; | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename1 a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.applyName(); | ||||
|             return false; | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename1 input#uname' : function(el) { | ||||
|         el.onkeydown = function(e) { | ||||
|             var ev = e || event; | ||||
|             if( ev.keyCode == 13 ) { | ||||
|                 chatController.applyName(); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a#refresh' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.refresh(); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a#togglesound' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.toggleSound(); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a.closethread' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.closeThread(); | ||||
|         }; | ||||
|     } | ||||
| }); | ||||
| 
 | ||||
| var pluginManager = new PluginManager(); | ||||
| var chatController; | ||||
| 
 | ||||
| EventHelper.register(window, 'onload', function(){ | ||||
|     FrameUtils.options.cssfile = chatParams.cssfile; | ||||
|     var chatServer = new ChatServer(chatParams.serverParams); | ||||
|     var thread = new Thread(chatParams.threadParams); | ||||
|     chatParams.initPlugins(pluginManager, thread, chatServer); | ||||
|     var chatView = new ChatView( | ||||
|         chatParams.localizedStrings, | ||||
|         chatParams.predefinedAnswers || [] | ||||
|     ); | ||||
|     chatController = new ChatController( | ||||
|         chatServer, | ||||
|         chatView, | ||||
|         thread, | ||||
|         {ignorectrl: -1}.extend(chatParams.controllerParams || {}) | ||||
|     ); | ||||
| }); | ||||
| } | ||||
							
								
								
									
										85
									
								
								src/messenger/webim/js/source/chatinit.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/messenger/webim/js/source/chatinit.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,85 @@ | ||||
| /** | ||||
|  * @preserve This file is part of Mibew Messenger project. | ||||
|  * http://mibew.org
 | ||||
|  *  | ||||
|  * Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  * License: http://mibew.org/license.php
 | ||||
|  */ | ||||
| 
 | ||||
| var chatController = null; | ||||
| var pluginManager = new PluginManager(); | ||||
| 
 | ||||
| Behaviour.register({ | ||||
|     '#postmessage a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             var message = $('msgwnd'); | ||||
|             if (message) { | ||||
|                 chatController.postMessage(message.value); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'select#predefined' : function(el) { | ||||
|         el.onchange = function() { | ||||
|             chatController.selectPredefinedAnswer(this); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename2 a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.showNameField(); | ||||
|             return false; | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename1 a' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.applyName(); | ||||
|             return false; | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'div#changename1 input#uname' : function(el) { | ||||
|         el.onkeydown = function(e) { | ||||
|             var ev = e || event; | ||||
|             if( ev.keyCode == 13 ) { | ||||
|                 chatController.applyName(); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a#refresh' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.refresh(); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a#togglesound' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.toggleSound(); | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     'a.closethread' : function(el) { | ||||
|         el.onclick = function() { | ||||
|             chatController.closeThread(); | ||||
|         }; | ||||
|     } | ||||
| }); | ||||
| 
 | ||||
| EventHelper.register(window, 'onload', function(){ | ||||
|     FrameUtils.options.cssfile = chatParams.cssfile; | ||||
|     var chatServer = new ChatServer(chatParams.serverParams); | ||||
|     var thread = new Thread(chatParams.threadParams); | ||||
|     chatParams.initPlugins(pluginManager, thread, chatServer); | ||||
|     var chatView = new ChatView( | ||||
|         chatParams.localizedStrings, | ||||
|         chatParams.predefinedAnswers || [] | ||||
|     ); | ||||
|     chatController = new ChatController( | ||||
|         chatServer, | ||||
|         chatView, | ||||
|         thread, | ||||
|         {ignorectrl: -1}.extend(chatParams.controllerParams || {}) | ||||
|     ); | ||||
| }); | ||||
							
								
								
									
										287
									
								
								src/messenger/webim/js/source/chatview.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										287
									
								
								src/messenger/webim/js/source/chatview.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,287 @@ | ||||
| /** | ||||
|  * @preserve This file is part of Mibew Messenger project. | ||||
|  * http://mibew.org
 | ||||
|  *  | ||||
|  * Copyright (c) 2005-2011 Mibew Messenger Community | ||||
|  * License: http://mibew.org/license.php
 | ||||
|  */ | ||||
| 
 | ||||
| var FrameUtils = { | ||||
| 
 | ||||
|     options: {}, | ||||
| 
 | ||||
|     getDocument: function(frm) { | ||||
|         if (frm.contentDocument) { | ||||
|             return frm.contentDocument; | ||||
|         } else if (frm.contentWindow) { | ||||
|             return frm.contentWindow.document; | ||||
|         } else if (frm.document) { | ||||
|             return frm.document; | ||||
|         } else { | ||||
|             return null; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     initFrame: function(frm) { | ||||
|         var doc = this.getDocument(frm); | ||||
|         doc.open(); | ||||
|         doc.write("<html><head>"); | ||||
|         if (this.options.cssfile) { | ||||
|             doc.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""+this.options.cssfile+"\">"); | ||||
|         } | ||||
|         doc.write("</head><body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400'>"); | ||||
|         doc.write("<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message' id='content'></td></tr></table><a id='bottom' name='bottom'></a>"); | ||||
|         doc.write("</body></html>"); | ||||
|         doc.close(); | ||||
|         frm.onload = function() { | ||||
|             if (frm.myHtml) { | ||||
|                 FrameUtils.getDocument(frm).getElementById('content').innerHTML += frm.myHtml; | ||||
|                 FrameUtils.scrollDown(frm); | ||||
|             } | ||||
|         }; | ||||
|     }, | ||||
| 
 | ||||
|     insertIntoFrame: function(frm, htmlcontent) { | ||||
|         var vcontent = this.getDocument(frm).getElementById('content'); | ||||
|         if (vcontent == null) { | ||||
|             if (!frm.myHtml) { | ||||
|                 frm.myHtml = ""; | ||||
|             } | ||||
|             frm.myHtml += htmlcontent; | ||||
|         } else { | ||||
|             vcontent.innerHTML += htmlcontent; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     scrollDown: function(frm) { | ||||
|         var vbottom = this.getDocument(frm).getElementById('bottom'); | ||||
|         if (myAgent == 'opera') { | ||||
|             try { | ||||
|                 frm.contentWindow.scrollTo(0,this.getDocument(frm).getElementById('content').clientHeight); | ||||
|             } catch(e) {} | ||||
|         } | ||||
|         if (vbottom) { | ||||
|             vbottom.scrollIntoView(false); | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| ChatView = Class.create(); | ||||
| ChatView.prototype = { | ||||
|     /** | ||||
|      * Status timeout identifier | ||||
|      * @type Number | ||||
|      * @private | ||||
|      */ | ||||
|     statusTimeout: null, | ||||
| 
 | ||||
|     /** | ||||
|      * Contains localized strings. Properties names are language key and | ||||
|      * properties values are localized strings | ||||
|      * @type Object | ||||
|      */ | ||||
|     localizedStrings: {}, | ||||
| 
 | ||||
|     /** | ||||
|      * Contains predefined answers configurable from administrative interface | ||||
|      * @type Array | ||||
|      */ | ||||
|     predefinedAnswers: [], | ||||
| 
 | ||||
|     /** | ||||
|      * Messages container DOM element | ||||
|      * @type Object | ||||
|      */ | ||||
|     messageContainer: null, | ||||
| 
 | ||||
|     /** | ||||
|      * Create an instance of ChatView | ||||
|      * @constructor | ||||
|      */ | ||||
|     initialize: function(localizedStrings, predefinedAnswers) { | ||||
|         this.localizedStrings = localizedStrings || {}; | ||||
|         this.predefinedAnswers = predefinedAnswers || []; | ||||
| 
 | ||||
|         this.messageContainer = (myRealAgent == 'safari') | ||||
|             ? self.frames[0] | ||||
|             : $("chatwnd"); | ||||
|         FrameUtils.initFrame(this.messageContainer); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Get localized string by language key | ||||
|      * @param {String} key Language key | ||||
|      * @returns {Boolean|String} Returns boolean FALSE if string with specified | ||||
|      * key is undefined and localized string otherwise | ||||
|      */ | ||||
|     getLocaleString: function(key) { | ||||
|         if (typeof this.localizedStrings[key] == 'undefined') { | ||||
|             return false; | ||||
|         } | ||||
|         return this.localizedStrings[key]; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Enables or disables input field | ||||
|      * @param {Boolean} val Use boolean true for enable input and false | ||||
|      * otherwise | ||||
|      */ | ||||
|     enableInput: function(val) { | ||||
|         var message = $('msgwnd'); | ||||
|         if (message) { | ||||
|             message.disabled = !val; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Clear message input element and set focus to it | ||||
|      */ | ||||
|     clearInput: function() { | ||||
|         var message = $('msgwnd'); | ||||
|         if(message) { | ||||
|             message.value = ''; | ||||
|             message.focus(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Displays status div and sets the status string into it | ||||
|      * @param {String} k Status string | ||||
|      */ | ||||
|     showStatusDiv: function(k) { | ||||
|         if ($("engineinfo")) { | ||||
|             $("engineinfo").style.display = 'inline'; | ||||
|             $("engineinfo").innerHTML = k; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Sets the status | ||||
|      * @param {String} k Status string | ||||
|      */ | ||||
|     setStatus: function(k) { | ||||
|         if (this.statusTimeout) { | ||||
|             clearTimeout(this.statusTimeout); | ||||
|         } | ||||
|         this.showStatusDiv(k); | ||||
|         this.statusTimeout = setTimeout(this.clearStatus.bind(this), 4000); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Hide the status string | ||||
|      */ | ||||
|     clearStatus: function() { | ||||
|         $("engineinfo").style.display='none'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Displays typing status | ||||
|      * @param {Boolean} istyping Indicates the other side of conversation is | ||||
|      * typing a message or not | ||||
|      */ | ||||
|     showTyping: function(istyping) { | ||||
|         if( $("typingdiv") ) { | ||||
|             $("typingdiv").style.display = istyping ? 'inline' : 'none'; | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Updates operator's avatar | ||||
|      * @param {String} root Base path | ||||
|      * @param {String} imageLink New avatar URL | ||||
|      */ | ||||
|     updateAvatar: function(root, imageLink) { | ||||
|         var avatar = ""; | ||||
|         if (imageLink != "") { | ||||
|             avatar = '<img src="'+root+'/images/free.gif" width="7" height="1" border="0" alt="" />' + | ||||
|                 '<img src="'+imageLink+'" border="0" alt=""/>'; | ||||
|         } | ||||
|         $("avatarwnd").innerHTML = avatar; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Display all messages at the message window | ||||
|      * @param {Array} messages Messages array | ||||
|      */ | ||||
|     displayMessages: function(messages) { | ||||
|         // Output messages
 | ||||
|         for (var i = 0; i < messages.length; i++) { | ||||
|             this.outputMessage(messages[i]); | ||||
|         } | ||||
|         // There are some new messages
 | ||||
|         if (messages.length > 0) { | ||||
|             FrameUtils.scrollDown(this.messageContainer); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Add message to the message window | ||||
|      * @param {String} message HTML message to insert | ||||
|      * @private | ||||
|      */ | ||||
|     outputMessage: function(message) { | ||||
|         FrameUtils.insertIntoFrame(this.messageContainer, message); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Show new user name input | ||||
|      */ | ||||
|     showNameField: function() { | ||||
|         $('changename1').style.display='inline'; | ||||
|         $('changename2').style.display='none'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Hide new user name input | ||||
|      */ | ||||
|     hideNameField: function() { | ||||
|         $('changename1').style.display='none'; | ||||
|         $('changename2').style.display='inline'; | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Update user name in chat window | ||||
|      * @param {String} name New user's name | ||||
|      */ | ||||
|     updateUserName: function(name) { | ||||
|         $('unamelink').innerHTML = htmlescape(name); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Change sound button state. | ||||
|      * | ||||
|      * @param {Boolean} enable TRUE if sound enabled and FALSE otherwise | ||||
|      */ | ||||
|     changeSoundButtonState: function(enable) { | ||||
|         var tsound = $('soundimg'); | ||||
|         if (enable) { | ||||
|             tsound.className = "tplimage isound"; | ||||
|         } else { | ||||
|             tsound.className = "tplimage inosound"; | ||||
|         } | ||||
|         var messagePane = $('msgwnd'); | ||||
|         if(messagePane) { | ||||
|             messagePane.focus(); | ||||
|         } | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Add predefined answer to message input element and set focus to it. | ||||
|      * | ||||
|      * @param {Number} answerIndex Index of predefined answer | ||||
|      */ | ||||
|     displayPredefinedAnswer: function(answerIndex) { | ||||
|         var message = $('msgwnd'); | ||||
|         message.value = this.predefinedAnswers[answerIndex]; | ||||
|         message.focus(); | ||||
|     }, | ||||
| 
 | ||||
|     /** | ||||
|      * Set selectedIndex property of the select box DOM element passed as | ||||
|      * argument to zero. | ||||
|      * @param {Object} elem Select box DOM element | ||||
|      */ | ||||
|     resetSelectedIndex: function(elem) { | ||||
|         elem.selectedIndex = 0; | ||||
|     } | ||||
| } | ||||
| @ -39,7 +39,9 @@ var chatParams = { | ||||
| //--> | ||||
| </script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chat.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> | ||||
| <style type="text/css"> | ||||
| #header{ | ||||
| 	height:50px; | ||||
|  | ||||
| @ -39,7 +39,9 @@ var chatParams = { | ||||
| //--> | ||||
| </script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chat.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> | ||||
| <style type="text/css"> | ||||
| .tplimage { | ||||
| 	background: transparent url(${tplroot}/images/wmchat.png) no-repeat scroll 0px 0px; | ||||
|  | ||||
| @ -80,7 +80,9 @@ | ||||
| 		//--> | ||||
| 	</script> | ||||
| 	<script type="text/javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script> | ||||
| 	<script type="text/javascript" src="${webimroot}/js/${jsver}/chat.js"></script> | ||||
| 	<script type="text/javascript" src="${webimroot}/js/${jsver}/chatview.js"></script> | ||||
| 	<script type="text/javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script> | ||||
| 	<script type="text/javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> | ||||
| </head> | ||||
| <body class="body"> | ||||
| 	<div id="top"> | ||||
|  | ||||
| @ -39,7 +39,9 @@ var chatParams = { | ||||
| //--> | ||||
| </script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chat.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script> | ||||
| <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> | ||||
| <style type="text/css"> | ||||
| .isound { background: url(${tplroot}/images/buttons/sound.gif) no-repeat; width: 19px; height: 19px; } | ||||
| .inosound { background: url(${tplroot}/images/buttons/nosound.gif) no-repeat; width: 19px; height: 19px; } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user