src/js/supportchat.js

changeset 43
a3febc43e4e9
parent 39
0b18fb969bd3
child 44
094640b971b4
equal deleted inserted replaced
42:815816ceb1ad 43:a3febc43e4e9
74 set_ui_state("wait"); 74 set_ui_state("wait");
75 75
76 // Create our question room 76 // Create our question room
77 var question_muc = new MUC(conn, { 77 var question_muc = new MUC(conn, {
78 // Handle room joins 78 // Handle room joins
79 joined: function (stanza, muc, nick) 79 joined: function (stanza, muc, occupant)
80 { 80 {
81 if(nick == our_nick) 81 if(occupant.nick == our_nick)
82 // We joined the question room, now join the team room and tell them 82 // We joined the question room, now join the team room and tell them
83 team_muc.join(support_config.team_rooms[question_type], our_nick); 83 team_muc.join(support_config.team_rooms[question_type], our_nick);
84 else if(ui_state == "wait") 84 else if(ui_state == "wait")
85 { 85 {
86 // We were waiting for an assistant, and one just joined 86 // We were waiting for an assistant, and one just joined
87 var html = "<span class='muc-message'><span class='muc-nick'>" + htmlescape(nick) + "</span>" + " is answering your query</span><br/>\n"; 87 var html = "<span class='muc-message'><span class='muc-nick'>" + htmlescape(occupant.nick) + "</span>" + " is answering your query</span><br/>\n";
88 $("#support-log").append(html).scrollTop($("#support-log")[0].scrollHeight); 88 $("#support-log").append(html).scrollTop($("#support-log")[0].scrollHeight);
89 $("#support-send-button").click(function () 89 $("#support-send-button").click(function ()
90 { 90 {
91 question_muc.send_message($("#support-input").val()); 91 question_muc.send_message($("#support-input").val());
92 $("#support-input").val(""); 92 $("#support-input").val("");
118 }); 118 });
119 119
120 // Create the team MUC object (it will be joined after we join the question MUC) 120 // Create the team MUC object (it will be joined after we join the question MUC)
121 var team_muc = new MUC(conn, { 121 var team_muc = new MUC(conn, {
122 // Someone joined the team MUC 122 // Someone joined the team MUC
123 joined: function (stanza, muc, nick) 123 joined: function (stanza, muc, occupant)
124 { 124 {
125 if(nick != our_nick) 125 if(occupant.nick != our_nick)
126 return; 126 return;
127 127
128 var sent = false; 128 var sent = false;
129 for(var nick in team_muc.occupants) 129 for(var nick in team_muc.occupants)
130 { 130 {
131 var affiliation = $(stanza) 131 if(team_muc.occupants[nick].affiliation == "none" || nick == our_nick)
132 .find("x[xmlns='http://jabber.org/protocol/muc#user']>item")
133 .attr("affiliation");
134 if(affiliation == "none" || nick == our_nick)
135 continue; 132 continue;
136 sent = true; 133 sent = true;
137 if(support_config.send_invites) 134 if(support_config.send_invites)
138 team_muc.send_invite(team_muc.jid+"/"+nick, question_text + "\n" + question_muc.jid); 135 team_muc.send_invite(team_muc.jid+"/"+nick, question_text + "\n" + question_muc.jid);
139 else 136 else

mercurial