# HG changeset patch # User matthew@heavyhorse.vm.bytemark.co.uk # Date 1271439485 -3600 # Node ID 6f0822a428b7575977a1d4b40e44f45515e79034 # Parent e5e70a46ace8cf6b3d8f6dcf54c2001e7012b62a Remove hacky our_nick global, use the relevant MUC's nick property, or question_name as appropriate. diff -r e5e70a46ace8 -r 6f0822a428b7 support-chat/js/supportchat.js --- a/support-chat/js/supportchat.js Fri Apr 16 18:35:33 2010 +0100 +++ b/support-chat/js/supportchat.js Fri Apr 16 18:38:05 2010 +0100 @@ -101,8 +101,6 @@ question_name = $("#support-question-name").val(); question_text = $("#support-question-text").val(); - var our_nick = question_name; - set_ui_state("wait"); // Create our question room @@ -110,20 +108,26 @@ // Handle room joins joined: function (stanza, muc, occupant) { - if(occupant.nick == our_nick) + if(occupant.nick == question_muc.nick) + { // We joined the question room, now join the team room and tell them - team_muc.join(support_config.team_rooms[question_type], our_nick); - else if(ui_state == "wait") + team_muc.join(support_config.team_rooms[question_type], question_muc.nick); + // Also post our question to the question room for reference + question_muc.send_message(question_text); + } + else if(current_assistant == null) { // We were waiting for an assistant, and one just joined - var html = "" + htmlescape(occupant.nick) + "" + " is answering your query
\n"; - $("#support-log").append(html).scrollTop($("#support-log")[0].scrollHeight); - $("#support-send-button").click(function () + set_assistant(occupant.nick); + if(ui_state == "wait") + { + $("#support-send-button").click(function () { question_muc.send_message($("#support-input").val()); $("#support-input").val(""); }); - set_ui_state("converse"); + set_ui_state("converse"); + } } }, @@ -141,12 +145,12 @@ function (result) // Success { var unique = Strophe.getText(result.getElementsByTagName("unique")[0]); - question_muc.join(unique + "@" + support_config.muc_server, our_nick); + question_muc.join(unique + "@" + support_config.muc_server, question_name); }, function (result) // Failure to get unique room name { var unique = "support-"+Math.floor(Math.random()*512); - question_muc.join(unique + "@" + support_config.muc_server, our_nick); + question_muc.join(unique + "@" + support_config.muc_server, question_name); }); // Create the team MUC object (it will be joined after we join the question MUC) @@ -154,13 +158,13 @@ // Someone joined the team MUC joined: function (stanza, muc, occupant) { - if(occupant.nick != our_nick) + if(occupant.nick != team_muc.nick) return; var sent = false; for(var nick in team_muc.occupants) { - if(team_muc.occupants[nick].affiliation == "none" || nick == our_nick) + if(team_muc.occupants[nick].affiliation == "none" || nick == team_muc.nick) continue; sent = true; if(support_config.send_invites) @@ -178,8 +182,7 @@ { if(error == "conflict") { - our_nick += "_"; - muc.join(support_config.team_rooms[question_type], our_nick); + muc.join(support_config.team_rooms[question_type], team_muc.nick+"_"); } else set_ui_state("error");