Index: lams_learning/web/includes/presence.js
===================================================================
RCS file: /usr/local/cvsroot/lams_learning/web/includes/Attic/presence.js,v
diff -u -r1.7.2.2 -r1.7.2.3
--- lams_learning/web/includes/presence.js 24 Apr 2009 03:06:15 -0000 1.7.2.2
+++ lams_learning/web/includes/presence.js 7 May 2009 06:54:35 -0000 1.7.2.3
@@ -69,6 +69,8 @@
// set presence chat to minimized height
$("#presenceChat").css({'top': windowHeight + "px"});
}
+
+ $("#presenceChatWarning").css({'top': windowHeight - 10 + "px"});
}
function getUserFromTag(tag){
@@ -115,7 +117,7 @@
$("#" + tag).html(createPrivateTabContent(nick, tag));
var anticache = new Date().getTime();
- $.get(lamsUrl + "PresenceChatLogger.do", {method: "getConversationHistory", roomName:CONFERENCEROOM, from:NICK, to:nick, anticache:anticache}, handleGetConversation);
+ $.post(lamsUrl + "PresenceChatLogger.do", {method: "getConversationHistory", roomName:CONFERENCEROOM, from:NICK, to:nick, anticache:anticache}, handleGetConversation);
}
function htmlEnc(str) {
@@ -174,6 +176,14 @@
return tag + '_contextMenu';
}
+function nickToTabLabel(nick){
+ return tagToTabLabel(nickToTag(nick));
+}
+
+function tagToTabLabel(tag){
+ return tag + '_tabLabel';
+}
+
function parseXml(xml) {
if (jQuery.browser.msie) {
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
@@ -285,6 +295,8 @@
else if(action == "block" && !blocked){
roster.users[rosterIndex].blocked = handleAllowBlockClick(tag, blocked);
}
+
+ roster.updateDisplay();
});
}
@@ -406,7 +418,7 @@
if(listing.length == 0){
// create listing div
// note: attrId must be added to array before onClick
- var listingDiv = $('
' + createPresenceListing(nick, tag) + '
');
+ var listingDiv = $('' + createPresenceListing(nick, tag) + '
');
// add the listing div
rosterDiv.append(listingDiv);
@@ -446,9 +458,18 @@
// set the correct icon depending on status
if(available == "available"){
availableCount++;
- listingImage.attr("src", "../images/icons/user_online.png");
+
+ if(blocked){
+ listingImage.attr("src", "../images/icons/user_online_blocked.png");
+ }else{
+ listingImage.attr("src", "../images/icons/user_online.png");
+ }
}else{
- listingImage.attr("src", "../images/icons/user_offline.png");
+ if(blocked){
+ listingImage.attr("src", "../images/icons/user_offline_blocked.png");
+ }else{
+ listingImage.attr("src", "../images/icons/user_offline.png");
+ }
}
}
@@ -524,10 +545,10 @@
var aMsg = new JSJaCMessage();
// prepare nick
- var toNick = "";
+ var toNick;
// prepare user
- var user = null;
+ var user;
// if the form has a hidden sendTo input, it's a private message
if (aForm.sendTo) {
@@ -536,34 +557,33 @@
aMsg.setTo(CONFERENCEROOM + "/" + toNick);
aMsg.setType("chat");
aMsg.setBody(aForm.messageInput.value);
- // apending the private message to the incoming window,
- // since the jabber server will not echo sent private messages.
- // TODO: need to check if this is correct behaviour
+
+ // append message to one's own window (jabber doesn't send message back to sender)
if (!(NICK == toNick)) {
updateMessageDisplay(nickToMessageArea(toNick), generateMessageHTML(NICK, aForm.messageInput.value, null));
}
-
- // log message
- $.get(lamsUrl + "PresenceChatLogger.do", {method: "saveMessage", roomName:CONFERENCEROOM, from:NICK, to:toNick, dateSent:new Date(), message:aForm.messageInput.value}, null);
}
// otherwise, it's a group chat message
else {
+ toNick = null;
+ user = null
aMsg.setTo(CONFERENCEROOM);
aMsg.setType("groupchat");
aMsg.setBody(aForm.messageInput.value);
-
- $.get(lamsUrl + "PresenceChatLogger.do", {method: "saveMessage", roomName:CONFERENCEROOM, from:NICK, to:null, dateSent:new Date(), message:aForm.messageInput.value}, null);
}
aMsg.setFrom(USERNAME + "@" + XMPPDOMAIN + "/" + RESOURCE);
// if groupchat or if user is available
- if(user == null || user.status == "available"){
+ if(!user || user.status == "available"){
+ // log message
+ $.post(lamsUrl + "PresenceChatLogger.do", {method: "saveMessage", roomName:CONFERENCEROOM, from:NICK, to:toNick, dateSent:new Date(), message:aForm.messageInput.value}, null);
+
// send message
con.send(aMsg);
}
// otherwise if not groupchat and user is unavailable
- else if(user != null && user.status == "unavailable"){
+ else if(user && user.status == "unavailable"){
// generate the emote message and display it to user
var emoteMessage = generateEmoteHTML("Your previous message has not been sent because " + toNick + " is unavailable");
updateMessageDisplay(nickToMessageArea(toNick), emoteMessage);
@@ -591,12 +611,12 @@
// prepare htmlMessage
var htmlMessage;
-
- // get the tag from nick
- var tag = nickToTag(nick);
-
+
// if message is private chat
- if (type == "chat") {
+ if (type == "chat") {
+ // get the tag from nick
+ var tag = nickToTag(nick);
+
// get user from nick
var user = roster.getUserByNick(nick);
@@ -607,27 +627,24 @@
// add a tab
addTab(nick, tag);
- // make the sender's tab label bold
- $('#' + tag + '_tabLabel').html('' + nick + '');
-
// don't add the message, let the log take care of that
}
// if there is a tab for the send open
- else{
- // get the selected tab
- var selected = $("#presenceChatTabs").tabs().data('selected.tabs');
-
- // if the selected tab is any other than sender's tab
- if(getUserFromTabIndex(selected).tag != tag){
- // make the sender's tab label bold
- $('#' + tag + '_tabLabel').html('' + nick + '');
- $("#presenceChatTabs").tabs('_tabify', false);
- }
-
+ else{
// generate html
htmlMessage = generateMessageHTML(nick, message, null);
}
+ // get the selected tab
+ var selected = $("#presenceChatTabs").tabs().data('selected.tabs');
+
+ // if the selected tab is any other than sender's tab
+ if(getUserFromTabIndex(selected).tag != tag){
+ // notify of new message
+ $("#" + tagToTabLabel(tag)).addClass('presenceTabNewMessage');
+ $("#" + tagToListing(tag)).addClass('presenceListingNewMessage');
+ }
+
// add the div to the sender's tab
updateMessageDisplay(nickToMessageArea(nick), htmlMessage);
}
@@ -641,8 +658,7 @@
// if the selected tab is any other than groupchat
if(selected != 0){
// make the group chat label label bold
- $('#groupchat_tabLabel').html('Group Chat');
- $("#presenceChatTabs").tabs('_tabify', false);
+ $("#" + tagToTabLabel(groupChatInfo.tag)).addClass('presenceTabNewMessage');
}
htmlMessage = generateMessageHTML(nick, message, null);
@@ -715,8 +731,8 @@
if(showStatus){
// if the selected tab is any other than groupchat
if(selected != 0){
- // make the group chat label bold
- $('#groupchat_tabLabel').html('Group Chat');
+ // make the group chat label label bold
+ $("#" + tagToTabLabel(groupChatInfo.tag)).addClass('presenceTabNewMessage');
}
// generate the emote message and display it to group chat
@@ -732,13 +748,14 @@
// if the person who got disconnected has a tab open
if(document.getElementById(nickToMessageArea(nick)) != null){
- // if the selected tab is any other than sender's tab
- if(getUserFromTabIndex(selected).tag != tag){
- // make the sender's tab label bold
- $('#' + tag + '_tabLabel').html('' + nick + '');
- }
-
+ // if showing status messages
if(showStatus){
+ // if the selected tab is any other than sender's tab
+ if(getUserFromTabIndex(selected).tag != tag){
+ // notify of new message
+ $("#" + tagToTabLabel(tag)).addClass('presenceTabNewMessage');
+ }
+
// generate the emote message and display it to private chat
var emoteMessage;
if(user.status == "unavailable"){
@@ -779,7 +796,7 @@
// get group chat history
var anticache = new Date().getTime();
- $.get(lamsUrl + "PresenceChatLogger.do", {method: "getGroupHistory", roomName:CONFERENCEROOM, anticache:anticache}, handleGetGroupHistory);
+ $.post(lamsUrl + "PresenceChatLogger.do", {method: "getGroupHistory", roomName:CONFERENCEROOM, anticache:anticache}, handleGetGroupHistory);
}
function handleDisconnected() {
@@ -883,7 +900,7 @@
}
function doRegistration(){
- $.get(xmppServlet, {method: "createXmppId"}, handlePresenceRegistration);
+ $.post(xmppServlet, {method: "createXmppId"}, handlePresenceRegistration);
}
/*