[Vtigercrm-commits] [vtiger-commits] r7882 - in /branches/VTIGERCRM-5.0.2-MMBRICH: Smarty/templates/ include/js/objects/ modules/CommSystem/ themes/blue/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Jul 7 02:10:13 EDT 2006
Author: mmbrich
Date: Fri Jul 7 00:10:12 2006
New Revision: 7882
Log:
more comm system stuff
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/VtigerUser.js
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php
branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl Fri Jul 7 00:10:12 2006
@@ -24,7 +24,7 @@
<!-- header-vtiger crm name & RSS -->
<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
- <script language="javascript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,dragdrop,builder"></script>
+ <script language="javascript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,dragdrop,builder,events"></script>
<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
<script language="JavaScript" type="text/javascript" src="include/calculator/calc.js"></script>
<script language="JavaScript" type="text/javascript" src="modules/Calendar/script.js"></script>
@@ -146,6 +146,7 @@
<span id="CommSliderDiv" class="commSlider">
{$USERLIST}
</span>
+<span id="debug_win"></span>
<div id="calculator_cont" style="position:absolute; z-index:10000" ></div>
{include file="Clock.tpl"}
@@ -426,6 +427,7 @@
return true;
}
+try {
/* START COMMUNICATIONS SYSTEM */
function openCommSystem() {
CS.OpenSlider();
@@ -433,8 +435,9 @@
var VtUser = {}
new VtigerUser();
addOnloadEvent(function() {
- CS = new CommSystem("CommSliderDiv");
+ CS = new CommSystem("CommSliderDiv",VtUser);
});
+}catch(m){alert(m);}
</SCRIPT>
{/literal}
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 Fri Jul 7 00:10:12 2006
@@ -1,6 +1,6 @@
CommSystem = Class.create();
CommSystem.prototype = {
- initialize: function(element) {
+ initialize: function(element,CurrentUser) {
this.debug=true;
this.refreshtime = '5000';
this.username = VtUser.user_name;
@@ -8,6 +8,9 @@
this.CheckSession();
this.sliderOpen = "false";
this.timer;
+ this.keycount=0;
+ this.keytimer;
+ this.user=CurrentUser;
},
/*
@@ -25,7 +28,7 @@
postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo',
onComplete: this.HandleEvent,
onFailure: function() {
- window.ClearTimeout(globalCommSystem.timer);
+ window.clearTimeout(globalCommSystem.timer);
}
}
);
@@ -48,7 +51,7 @@
$(globalCommSystem.sliderElement).style.width = '180px';
},
function() {
- new Effect.Appear($(globalCommSystem.sliderElement));
+ new Effect.Appear($(globalCommSystem.sliderElement),{duration:'0.2'});
}
);
this.sliderOpen = "true";
@@ -58,7 +61,7 @@
$(globalCommSystem.sliderElement).className = "commSlider";
},
function() {
- new Effect.Fade($(globalCommSystem.sliderElement));
+ new Effect.Fade($(globalCommSystem.sliderElement),{duration:'0.2'});
},
function() {
$(globalCommSystem.sliderElement).style.width = '0px';
@@ -74,10 +77,8 @@
* Creates elements and populates with past info
*/
CheckSession: function() {
- try {
window.clearTimeout(this.timer);
this.CommUpdate();
- }catch(e){if(this.debug) alert(e);}
},
/*
@@ -86,16 +87,45 @@
* message text.
*/
SendChatMessage: function(otheruser,msg) {
+ msgStruct = {
+ sending_user: otheruser,
+ msg_data: msg,
+ msg_type: 'P2PIM'
+ }
+ 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+'msg_type=P2PIM',
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=sendChatMessage&receivers='+otheruser+'&msg='+msg+'&msg_type=P2PIM',
onComplete: function(response) {
- alert(response.responseText);
+ if(!response.responseText.match(/^failed/)) {
+ Object.extend(msgStruct, {msg_data:'<font color="blue">'+globalCommSystem.user.user_name+"</font>: "+response.responseText});
+ globalCommSystem.ShowNewChatMessage(msgStruct,"");
+ } else {
+ Object.extend(msgStruct, {msg_data:'<font color="red">Failed to deliver message</font>: '+msgStruct.msg_data});
+ globalCommSystem.ShowNewChatMessage(msgStruct,"");
+ }
}
}
);
+ }
+,
+ SendMsg: function(evt) {
+ var dat = $("msg_input_"+Event.element(evt).name);
+ try {
+ globalCommSystem.SendChatMessage(Event.element(evt).name,dat.value);
+ }catch(e){alert(e);}
+ dat.value = "";
+ },
+
+ OpenChatSession: function(receivers) {
+ msgStruct = {
+ sending_user: receivers,
+ msg_data: '',
+ msg_type: 'P2PIM'
+ }
+ this.ShowNewChatMessage(msgStruct,"Chatting with: "+receivers);
},
/*
@@ -106,7 +136,9 @@
ShowNewChatMessage: function(msg,header_msg) {
Try.these (
function() {
- new Effect.Appear("msgwindow_"+msg.sending_user);
+ new Effect.Appear("msgwindow_"+msg.sending_user,{duration:'0.2'});
+ $("chat_data_"+msg.sending_user).innerHTML += "<br>"+msg.msg_data;
+ globalCommSystem.ScrollChatWindow($("chat_data_"+msg.sending_user));
},
function() {
if(msg.msg_type == "P2PIM")
@@ -143,7 +175,7 @@
[ Builder.node(
'img',
{src:'themes/blue/images/close.gif',
- onClick: 'new Effect.Fade(\'msgwindow_'+msg.sending_user+'\')'
+ onClick: 'new Effect.Fade(\'msgwindow_'+msg.sending_user+'\',{duration:\'0.2\'})'
}
)]
)]
@@ -163,7 +195,7 @@
width:'100%',height:'100%',colspan:'2'
},
[ Builder.node(
- 'div', {id:'chat_data_'+msg.sending_user,className:'chatWindowDataArea'}
+ 'div', {id:'chat_data_'+msg.sending_user,className:'chatWindowDataArea',name:msg.sending_user}
)]
)]
);
@@ -171,20 +203,19 @@
var msg_input = Builder.node(
'tr',
- {
- valign:'top',align:'center'
- },
+ {valign:'top',align:'center'},
[ Builder.node(
'td',
- {
- width:'100%',height:'100%',colspan:'2'
- },
- [ Builder.node(
- 'div', {id:'msg_input_'+msg.sending_user},
+ [ Builder.node(
+ 'div', {id:'msg_wrapper_'+msg.sending_user},
[ Builder.node(
- 'textarea'
- )]
- )]
+ 'textarea', {id:'msg_input_'+msg.sending_user,name:msg.sending_user}
+ )] //, [ Builder.node('br') ],
+ )],
+ [ Builder.node(
+ 'p',{id:'status_bar_'+msg.sending_user},'Status Bar'
+ )],
+ {width:'100%',colspan:'2'}
)]
);
main_table.appendChild(msg_input);
@@ -192,12 +223,48 @@
main_table.style.display = "none";
$("comm_sys").appendChild(main_table);
- $("chat_data_"+msg.sending_user).innerHTML += msg.msg_data;
- $("msg_input_"+msg.sending_user).innerHTML += '<input type="submit" class="button" value="Send">';
-
- new Effect.Appear(main_table);
+ try {
+ $("chat_data_"+msg.sending_user).innerHTML += "<br>"+msg.msg_data;
+ $("msg_wrapper_"+msg.sending_user).innerHTML += '<input type="submit" class="button" value="Send" 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(f){alert(f);}
+
+ new Effect.Appear(main_table,{duration:'0.2'});
+ new Draggable(main_table);
}
);
+ },
+
+ 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;
+ }
+ );
+ },
+
+ UserTyping: function(evt) {
+ window.clearTimeout(this.keytimer);
+ var tname = "status_bar_"+Event.element(evt).name;
+ if(evt.type === "keypress") {
+ if(globalCommSystem.keycount == 0) {
+ $(tname).innerHTML = "User is typing";
+ this.keycount++;
+ }
+ this.keytimer = window.setTimeout('globalCommSystem.UserStopTyping("'+Event.element(evt).name+'")',2000);
+ }
+ },
+
+ UserStopTyping: function(sending_user) {
+ window.clearTimeout(this.keytimer);
+ this.keycount=0;
+ $("status_bar_"+sending_user).innerHTML = "Stopped typing...";
},
/*
@@ -208,18 +275,15 @@
* for messages (IMs) a window object will be built for the message.
*/
HandleEvent: function(responseData) {
- //alert(responseData.responseText);
- if(responseData.responseText.match(/none/))
- return false;
- else {
+ if(!responseData.responseText.match(/none/)) {
var msgs = eval('(' + responseData.responseText + ')');
for (var i=0;i<msgs.CommSysMessages.length;i++) {
- var msgid = msgs.CommSysMessages[i].message.msgid;
- var msg_type = msgs.CommSysMessages[i].message.msg_type;
- try {
+ var msg = msgs.CommSysMessages[i].message;
+ var msgid = msg.msgid;
+ var msg_type = msg.msg_type;
switch(msg_type) {
case 'P2PIM':
- globalCommSystem.ShowNewChatMessage(msgs.CommSysMessages[i].message,"Message from matt");
+ globalCommSystem.ShowNewChatMessage(msg,"Message from matt");
break;
case 'GRPIM':
alert(msgs.CommSysMessages[i].message.msg_data);
@@ -233,10 +297,11 @@
case 'VOICEMAIL':
alert(msgs.CommSysMessages[i].message.msg_data);
break;
+ default:
+ break;
}
- }catch(e){alert(e);}
- }
- }
- //this.timer = window.setTimeout('globalCommSystem.CommUpdate()',this.refreshtime);
+ }
+ }
+ this.timer = window.setTimeout('globalCommSystem.CommUpdate()',this.refreshtime);
}
}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/VtigerUser.js
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/VtigerUser.js (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/VtigerUser.js Fri Jul 7 00:10:12 2006
@@ -9,7 +9,7 @@
'index.php',
{queue: {position: 'end', scope: 'vtobjects'},
method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=getDbValue&columnname='+this.columnname,
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=getDbValues',
onComplete: function(response) {
var tmp = eval('(' + response.responseText + ')');
VtUser = tmp.VtUser[0].data;
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php Fri Jul 7 00:10:12 2006
@@ -69,12 +69,12 @@
break;
case 'VOICEMAIL':
break;
- if(isset($q) && $q != "") {
- //$rs = $this->db->query($q);
- return "true";
- } else
- return "false";
}
+ if(isset($q) && $q != "") {
+ $rs = $this->db->query($q);
+ return "true";
+ } else
+ return "false";
}
function GetNewAlerts($userid) {
@@ -113,6 +113,15 @@
$c++;
}
}
+
+ $q = "UPDATE vtiger_comm_system SET viewed='1' WHERE ";
+ for($i=0,$cnt=count($ret);$i<$cnt;$i++) {
+ if($i==0)
+ $q .= "msgid='".$ret[$i]["msgid"]."'";
+ else
+ $q .= " OR msgid='".$ret[$i]["msgid"]."'";
+ }
+ $this->db->query($q);
return $ret;
}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php Fri Jul 7 00:10:12 2006
@@ -58,9 +58,9 @@
if($_REQUEST["command"] == "sendChatMessage") {
require_once("modules/CommSystem/CommSystem.php");
$commSys = new CommSystem();
- if($commSys->SendAlert($_REQUEST["msg"],$_REQUEST["msg_type"],$_SESSION["authenticated_user_id"],$_REQUEST["receivers"]) == "false")
+ if($commSys->SendAlert(nl2br($_REQUEST["msg"]),$_REQUEST["msg_type"],'0',$_SESSION["authenticated_user_id"],$_REQUEST["receivers"]) == "false")
echo "failed";
else
- echo "success";
+ echo nl2br($_REQUEST["msg"]);
}
?>
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php Fri Jul 7 00:10:12 2006
@@ -105,7 +105,7 @@
$rs = $adb->query($q);
$list = "<center><b>CRM Users:</b>";
while($row=$adb->fetch_array($rs)) {
- $list .= "<br><a href='javascript:;' onclick='CS.SendChatMessage(\"".$row["id"]."\",\"\");'>".$row["user_name"]."</a>";
+ $list .= "<br><a href='javascript:;' onclick='CS.OpenChatSession(\"".$row["id"]."\");'>".$row["user_name"]."</a>";
}
$list .= "</center>";
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css Fri Jul 7 00:10:12 2006
@@ -2904,6 +2904,7 @@
height: 200px;
text-align:left;
padding-left:3px;
+ overflow: auto;
}
.commSlider {
position: absolute;
More information about the vtigercrm-commits
mailing list