[Vtigercrm-commits] [vtiger-commits] r7920 - /branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sun Jul 9 22:59:14 EDT 2006
Author: mmbrich
Date: Sun Jul 9 20:59:13 2006
New Revision: 7920
Log:
conflict resolution
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js Sun Jul 9 20:59:13 2006
@@ -516,516 +516,3 @@
globalCommSystem.timer = window.setTimeout('globalCommSystem.CommUpdate()',globalCommSystem.refreshtime);
}
}
-=======
-/******************************************
- * The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is FOSS Labs.
- * Portions created by FOSS Labs are Copyright (C) FOSS Lbas.
- * All Rights Reserved.
- *
- *****************************************/
-CommSystem = Class.create();
-
-CommSystem.prototype = {
- initialize: function(element,CurrentUser,chatWith,sendValue) {
- this.debug=true;
- this.refreshtime = '1000';
- this.username = VtUser.user_name;
- this.sliderElement = element;
- this.CheckSession();
- this.sliderOpen = "false";
- this.timer;
- this.keycount=0;
- this.keytimer;
- this.user=CurrentUser;
- this.tmpCount=0;
- this.Focused='true';
- this.ChattingWith=chatWith;
- this.SendValue=sendValue;
- this.reloadMsg="This is reloaded content:";
- },
-
- /*
- * Update function to fire @ refreshtime
- * Calls the HandleEvent function which
- * will react on the JSON data passed to it.
- */
- CommUpdate: function() {
- globalCommSystem = this;
- if(globalCommSystem.Focused == 'false') {
- window.clearTimeout(globalCommSystem.timer);
- globalCommSystem.timer = window.setTimeout('globalCommSystem.CommUpdate()',globalCommSystem.refreshtime);
- } else {
- window.clearTimeout(globalCommSystem.timer);
- var first = globalCommSystem.IsPageReload();
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo&first_load='+first,
- onComplete: globalCommSystem.HandleEvent,
- onFailure: function() {
- alert("Failed");
- window.clearTimeout(globalCommSystem.timer);
- }
- }
- );
- }
- },
-
- IsPageReload: function() {
- if(typeof(globalCommSystem.tmpCount) == "undefined") {
- globalCommSystem.tmpCount++;
- var answer = 'true';
- } else if(globalCommSystem.tmpCount < 1) {
- globalCommSystem.tmpCount++;
- var answer = 'true';
- } else
- var answer = 'false';
-
- return answer;
- },
-
- /*
- * Function to open slider for comm center.
- * First the function tries to open the slider by
- * using an Effect(), if that fails it uses a css
- * class value to change the appearance
- */
- OpenSlider: function() {
- globalCommSystem = this;
- if(this.sliderOpen == "false") {
- Try.these (
- function() {
- $(globalCommSystem.sliderElement).className = "commSliderOpen";
- },
- function() {
- $(globalCommSystem.sliderElement).style.width = '180px';
- },
- function() {
- new Effect.Appear($(globalCommSystem.sliderElement),{duration:'0.2'});
- }
- );
- this.sliderOpen = "true";
- } else {
- Try.these (
- function() {
- $(globalCommSystem.sliderElement).className = "commSlider";
- },
- function() {
- new Effect.Fade($(globalCommSystem.sliderElement),{duration:'0.2'});
- },
- function() {
- $(globalCommSystem.sliderElement).style.width = '0px';
- }
- );
- this.sliderOpen = "false";
- }
- },
-
- /*
- * Function to check past sessions and load elements
- * that were open when window was reloaded, etc.
- * Creates elements and populates with past info
- */
- CheckSession: function() {
- this.Focused='true';
- Event.observe(document, 'focus', this.OnFocusEvent.bindAsEventListener(this));
- Event.observe(document, 'blur', this.OnFocusEvent.bindAsEventListener(this));
- window.clearTimeout(this.timer);
- this.CommUpdate();
- },
-
- /*
- * Called when this window is focused or un-focused
- */
- OnFocusEvent: function(evt) {
- if(evt.type == "focus")
- this.Focused='true';
- else if(evt.type == "blur") {
- window.focus();
- this.Focused='false';
- }
- },
-
- /*
- * Send a "User is typing" or "Done typing" message
- */
- SendStatusMessage: function(period,users) {
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=sendStatusMessage&receivers='+users+'&period='+period,
- onComplete: function(response) {
- //alert(response.responseText);
- }
- }
- );
- },
-
- /*
- * Function to send an instant message to another
- * user and update the chat window element with
- * message text.
- */
- SendChatMessage: function(otheruser,msg) {
- if(msg == "") {return;}
- var myDate=new Date();
- msgStruct = {
- sending_user: otheruser,
- msg_data: msg,
- msg_type: 'P2PIM',
- user_name: globalCommSystem.user.user_name,
- timestamp: myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds()
- }
- globalCommSystem = this;
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=sendChatMessage&receivers='+otheruser+'&msg='+msg.stripTags()+'&msg_type=P2PIM',
- onComplete: function(response) {
- if(response.responseText != "failed") {
- globalCommSystem.ShowNewChatMessage(msgStruct,"");
- } else {
- Object.extend(msgStruct, {msg_data:'<font color="red">Failed to deliver message</font>: '+msgStruct.msg_data});
- globalCommSystem.ShowNewChatMessage(msgStruct,"");
- }
- }
- }
- );
- },
-
- /*
- * Called prior to SendChatMessage so that proper variables
- * can be populated
- */
- SendMsg: function(evt) {
- try {
- globalCommSystem.UserStopTyping(Event.element(evt).name);
- var dat = $("msg_input_"+Event.element(evt).name);
- globalCommSystem.SendChatMessage(Event.element(evt).name,dat.value);
- }catch(p){alert(p);}
- dat.value = "";
- },
-
- OpenChatSession: function(receivers,usr_name) {
- var myDate=new Date();
- msgStruct = {
- sending_user: receivers,
- msg_data: '',
- msg_type: 'P2PIM',
- user_name: usr_name,
- timestamp: myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds()
- }
- this.ShowNewChatMessage(msgStruct, this.ChattingWith+" "+usr_name);
- },
-
- /*
- * Open a new chat window for a fresh session
- * or open a past window that was closed during
- * this session
- */
- ShowNewChatMessage: function(msg,header_msg) {
- Try.these (
- /* Try to open a window from past messaging with this user */
- function() {
- new Effect.Appear("msgwindow_"+msg.sending_user,{duration:'0.2'});
- if(msg.user_name == "" || typeof(msg.user_name) == "undefined" || msg.user_name == globalCommSystem.user.user_name) {
- msg.msg_data = "<BR><font color='blue'>"+globalCommSystem.user.user_name+"</font> ("+msg.timestamp+"): "+msg.msg_data;
- } else if(msg.user_name != globalCommSystem.user.user_name && msg.msg_data != "") {
- msg.msg_data = "<br><font color='red'>"+msg.user_name+"</font> ("+msg.timestamp+"): "+msg.msg_data;
- } else if(msg.msg_data != "")
- msg.msg_data = "<br>"+msg.msg_data;
-
- $("chat_data_"+msg.sending_user).innerHTML += msg.msg_data;
- globalCommSystem.ScrollChatWindow($("chat_data_"+msg.sending_user));
- },
- /* Build a new chat window */
- function() {
- if(msg.msg_type == "P2PIM")
- var clsname = "chatWindow";
- else if(msg.msg_type == "GRPCHAT")
- var clsname = "grpChatWindow";
-
- var main_table = Builder.node(
- 'table',
- {
- name:msg.sending_user,cellpadding:'2',cellspacing:'0',border:'0',
- className:clsname,id:'msgwindow_'+msg.sending_user
- }
- );
- var top_bar = Builder.node(
- 'tr',
- {
- align:'center',width:'100%',valign:'top'
- },
- [ Builder.node(
- 'td',
- [ Builder.node(
- 'span',
- {
- className:'chatWindowHeaderLeft'
- },
- header_msg+" "
- )],
- [ Builder.node(
- 'span',
- {
- className:'chatWindowHeaderRight'
- },
- [ Builder.node(
- 'img',
- {src:'themes/blue/images/close.gif',
- onClick: 'globalCommSystem.CloseSession(\''+msg.sending_user+'\')'
- }
- )]
- )]
- )]
- );
- main_table.appendChild(top_bar);
-
- Try.these (
- function() {
- if(msg.user_name != globalCommSystem.user.user_name) {return false;}
- msg.msg_data = "<BR><font color='red'>"+msg.user_name+"</font> ("+msg.timestamp+"): "+msg.msg_data;
- },
- function() {
- msg.msg_data += "<BR>";
- }
- );
-
- var chat_data = Builder.node(
- 'tr',
- {
- valign:'top',align:'center',id:'chatd_row_'+msg.sending_user
- },
- [ Builder.node(
- 'td',
- {
- width:'100%',height:'100%',colspan:'2'
- },
- [ Builder.node(
- 'div', {id:'chat_data_'+msg.sending_user,className:'chatWindowDataArea',name:msg.sending_user}
- )]
- )]
- );
- main_table.appendChild(chat_data);
-
- var msg_input = Builder.node(
- 'tr',
- {valign:'top',align:'center',id:'bchat_row_'+msg.sending_user},
- [ Builder.node(
- 'td',
- [ Builder.node(
- 'div', {id:'msg_wrapper_'+msg.sending_user},
- [ Builder.node(
- 'textarea', {id:'msg_input_'+msg.sending_user,name:msg.sending_user}
- )]
- )],
- [ Builder.node(
- 'p',{id:'status_bar_'+msg.sending_user}
- )],
- {width:'100%',colspan:'2'}
- )]
- );
- main_table.appendChild(msg_input);
-
- main_table.style.display = "none";
- $("comm_sys").appendChild(main_table);
-
- if(globalCommSystem.IsPageReload() != 'true' && msg.sending_user != globalCommSystem.user.user_name && msg.msg_data != "") {
- $("chat_data_"+msg.sending_user).innerHTML = "<font color='red'>"+msg.user_name+"</font> ("+msg.timestamp+"): "+msg.msg_data;
- } else if(msg.msg_data != "") {
- $("chat_data_"+msg.sending_user).innerHTML = "<font color='red'>"+globalCommSystem.reloadMsg+"<BR>"+msg.user_name+"</font> ("+msg.timestamp+"): "+msg.msg_data;
- }
-
- try {
- $("msg_wrapper_"+msg.sending_user).innerHTML += '<input type="submit" class="button" value="'+globalCommSystem.SendValue+'" id="send_button_'+msg.sending_user+'" name="'+msg.sending_user+'">';
- Event.observe($("msg_input_"+msg.sending_user), 'keypress', globalCommSystem.UserTyping.bindAsEventListener(this));
- Event.observe($("send_button_"+msg.sending_user), 'click', globalCommSystem.SendMsg.bindAsEventListener(this));
- }catch(g){alert(g);}
-
- new Effect.Appear(main_table,{duration:'0.2'});
- new Draggable(main_table);
- }
- );
- },
-
- /*
- * call this function with any old message
- * to have it appear in the alert slider
- */
- ShowAlertSlider: function(msg) {
- $("alert_display").innerHTML = "<b><a href='index.php?module=Webmails&action=index'>"+msg+"</a></b>";
- $("alert_display").style.display = "block";
-
- new Effect.Highlight("alert_display",{startcolor:'#ff99ff',endcolor:'#999999',
- queue: {position: 'end', scope: 'commsys'},
- afterFinish:function() {
- new Effect.Highlight("alert_display",{
- startcolor:'#ff99ff',endcolor:'#999999',
- queue: {position: 'end', scope: 'commsys'}
- }
- )
- }
- }
- );
- window.setTimeout(function() {
- globalCommSystem.HideAlertSlider();
- },4500);
- },
-
- /*
- * Hide the alert slider
- */
- HideAlertSlider: function() {
- new Effect.Squish($("alert_display"), {
- queue: {position: 'end', scope: 'commsys'},
- afterFinish: function() {
- $("alert_display").innerHTML = "";
- }
- }
- );
- },
-
- CloseSession: function(sending_user) {
- new Effect.Fade($("msgwindow_"+sending_user),{duration:'0.2'});
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=closeSession&sending_user='+sending_user
- }
- );
- },
-
- /*
- * Call this any time you suspect the chat window
- * content has changed. Can either be called with
- * the prototype event listener or with the actual
- * element passed to this function
- */
- ScrollChatWindow: function(evt) {
- //$("debug_win").innerHTML += "<br>Scrolling";
- Try.these (
- function() {
- var tname = "chat_data_"+Event.element(evt).name;
- $(tname).scrollTop = $(tname).scrollHeight;
- },
- function() {
- evt.scrollTop = evt.scrollHeight;
- }
- );
- },
-
- /*
- * called from event listeners. This will send a user typing
- * status message to the other user
- */
- UserTyping: function(evt) {
- var tname = "status_bar_"+Event.element(evt).name;
- if(evt.type === "keypress") {
- window.clearTimeout(globalCommSystem.keytimer);
- if(globalCommSystem.keycount == 0) {
- globalCommSystem.SendStatusMessage('begin',Event.element(evt).name);
- globalCommSystem.keycount++;
- }
- globalCommSystem.keytimer = window.setTimeout('globalCommSystem.UserStopTyping("'+Event.element(evt).name+'")',1000);
- }
- },
-
- /*
- * stop your last UserTyping() message
- */
- UserStopTyping: function(sending_user) {
- window.clearTimeout(globalCommSystem.keytimer);
- globalCommSystem.keycount=0;
- globalCommSystem.SendStatusMessage('end',sending_user);
- },
-
- /*
- * Call this function (n) seconds after your message
- * was first opened. This is for session tracking.
- * If this function isn't called after a message is
- * displayed it will appear again the next time the
- * receiving user opens a CRM window of any kind.
- */
- MarkAsRead: function(msgid) {
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=markAsRead&msgid='+msgid
- }
- );
- },
-
- /*
- * function to parse JSON msg data
- * and act on alerts or messages
- * for alerts the system will open a small slider
- * on the screen to alert the user
- * for messages (IMs) a window object will be built for the message.
- */
- HandleEvent: function(responseData) {
- //$("debug_win").innerHTML += "<BR>"+responseData.responseText;
- try {
- if(!responseData.responseText.match(/none/)) {
- var msgs = eval('(' + responseData.responseText + ')');
- for (var i=0;i<msgs.CommSysMessages.length;i++) {
- try {
- var msg = msgs.CommSysMessages[i].message;
- var msgid = msg.msgid;
- var msg_type = msg.msg_type;
- if(msg.sending_user == globalCommSystem.user.user_id) {return;}
- switch(msg_type) {
- case 'P2PIM':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- globalCommSystem.ShowNewChatMessage(msg,globalCommSystem.ChattingWith+" "+msg.user_name);
- break;
- case 'GRPIM':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- alert(msgs.CommSysMessages[i].message.msg_data);
- break;
- case 'EMAIL':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- globalCommSystem.ShowAlertSlider("<b>New Email:</b><br> "+msgs.CommSysMessages[i].message.recordid);
- break;
- case 'INPHONE':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- globalCommSystem.ShowAlertSlider("<b>Incoming Call:</b><br> "+msgs.CommSysMessages[i].message.msg_data);
- break;
- case 'VOICEMAIL':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- globalCommSystem.ShowAlertSlider("<b>New Voicemial:</b><br> "+msgs.CommSysMessages[i].message.msg_data);
- break;
- case 'GENERAL':
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- globalCommSystem.ShowAlertSlider("<b>New Voicemial:</b><br> "+msgs.CommSysMessages[i].message.msg_data);
- break;
- case 'STATUS':
- $("status_bar_"+msg.sending_user).innerHTML = msg.msg_data;
- window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',3000);
- break;
- }
- }catch(h){}
- Try.these (
- function() {
- if(msgs.CommSysMessages[i].email.unseen_emails > 0)
- globalCommSystem.ShowAlertSlider("You have "+msgs.CommSysMessages[i].email.unseen_emails+" new emails");
- },
- function() {
- if(msgs.CommSysMessages[(i+1)].email.unseen_emails > 0)
- globalCommSystem.ShowAlertSlider("You have "+msgs.CommSysMessages[i].email.unseen_emails+" new emails");
- }
- );
- }
- }
- }catch(f){}
- globalCommSystem.timer = window.setTimeout('globalCommSystem.CommUpdate()',globalCommSystem.refreshtime);
- }
-}
More information about the vtigercrm-commits
mailing list