Index: sandbox/jabberit_messenger/trophy/xsl/chatBox.xsl
===================================================================
--- sandbox/jabberit_messenger/trophy/xsl/chatBox.xsl (revision 2293)
+++ sandbox/jabberit_messenger/trophy/xsl/chatBox.xsl (revision 2298)
@@ -4,4 +4,5 @@
+
@@ -10,11 +11,9 @@
-
Index: sandbox/jabberit_messenger/trophy/js/trophyim.js
===================================================================
--- sandbox/jabberit_messenger/trophy/js/trophyim.js (revision 2293)
+++ sandbox/jabberit_messenger/trophy/js/trophyim.js (revision 2298)
@@ -196,10 +196,13 @@
*/
chatHistory : {},
+
/** Object: activeChats
*
* This object stores the currently active chats.
*/
- activeChats : {current: null, divs: {}},
- /** Function: setCookie
+
+ activeChats : {current: null, divs: {}},
+
+ /** Function: setCookie
*
* Sets cookie name/value pair. Date and path are auto-selected.
@@ -618,5 +621,5 @@
var message =
{
- contact : contact,
+ contact : "" + contact + "",
msg : Strophe.getText(elems[0])
};
@@ -668,6 +671,6 @@
{
'idChatBox' : barjid + "__chatBox",
+ 'jidTo' : barjid,
};
-
var winChatBox =
@@ -787,5 +790,5 @@
var messageDiv = document.createElement("div");
messageDiv.style.margin = "3px 0px 3px 3px";
- messageDiv.innerHTML = "" + msg.contact + " : " + msg.msg ;
+ messageDiv.innerHTML = msg.contact + " : " + msg.msg ;
chatBox.appendChild(messageDiv);
@@ -1061,24 +1064,56 @@
* Send message from chat input to user
*/
- sendMessage : function(chat_box) {
- var message_input =
- getElementsByClassName('trophyimchatinput', null,
- chat_box.parentNode)[0];
+
+ sendMessage : function()
+ {
+
+ if( arguments.length > 0 )
+ {
+ var jidTo = arguments[0];
+ var message_input = document.getElementById(jidTo + "__sendBox");
+
+ if( message_input.value.replace(/^\s+|\s+$/g,"") != "" )
+ {
+ // Send Message
+ TrophyIM.connection.send($msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input.value).tree());
+
+ var message =
+ {
+ contact : "" + "Eu" + "",
+ msg : message_input.value
+ }
+
+ message_input.value = '';
+
+ // Add Message in chatBox;
+ TrophyIM.addMessage( message, jidTo);
+ }
+ }
+
+
+ /*
+ * Codigo original comentado
+ *
+ var message_input = getElementsByClassName('trophyimchatinput', null, chat_box.parentNode)[0];
var active_jid = TrophyIM.activeChats['current'];
- if(TrophyIM.activeChats['current']) {
+
+ if(TrophyIM.activeChats['current'])
+ {
var active_chat =
TrophyIM.activeChats['divs'][TrophyIM.activeChats['current']];
var to = TrophyIM.activeChats['current'];
- if (active_chat['resource']) {
+ if (active_chat['resource'])
+ {
to += "/" + active_chat['resource'];
}
- TrophyIM.connection.send($msg({to: to, from:
- TrophyIM.connection.jid, type: 'chat'}).c('body').t(
- message_input.value).tree());
+ TrophyIM.connection.send($msg({to: to, from: TrophyIM.connection.jid, type: 'chat'}).c('body').t(message_input.value).tree());
+
TrophyIM.addMessage("Me:\n" + message_input.value,
TrophyIM.activeChats['current']);
}
+
message_input.value = '';
message_input.focus();
+ */
}
};