Add set_assistant and show_message functions

Fri, 16 Apr 2010 18:35:33 +0100

author
matthew@heavyhorse.vm.bytemark.co.uk
date
Fri, 16 Apr 2010 18:35:33 +0100
changeset 54
e5e70a46ace8
parent 53
5cb47f4087a8
child 55
6f0822a428b7

Add set_assistant and show_message functions

support-chat/js/supportchat.js file | annotate | diff | comparison | revisions
--- a/support-chat/js/supportchat.js	Fri Apr 16 18:34:56 2010 +0100
+++ b/support-chat/js/supportchat.js	Fri Apr 16 18:35:33 2010 +0100
@@ -65,6 +65,35 @@
 	}
 }
 
+var current_assistant = null;
+function set_assistant(new_assistant)
+{
+	if(new_assistant == null)
+	{
+		$("#support-assistant-name").text("No assistant present.");
+		question_muc.send_message("{System} There is now no active assistant");
+		team_muc.send_message("Query has no active assistant");
+		show_message(null, current_assistant + " has left, please stand by.");
+	}
+	else
+	{
+	$("#support-assistant-name").html("<u>Assistant:</u> "+htmlescape(new_assistant));
+		question_muc.send_message("{System} "+new_assistant+": You are now the selected assistant");
+		team_muc.send_message("Query being handled by "+new_assistant);
+		show_message(null, "You are now being assisted by " + new_assistant)
+	}
+	current_assistant = new_assistant;
+}
+
+function show_message(nick, message)
+{
+	var html = "<span class='muc-"+(nick?"message":"system")+"'>";
+	if(nick)
+		html += "<span class='muc-nick'>" + htmlescape(nick) + "</span>" + ": ";
+	html += htmlescape(message) + "</span><br/>\n";
+	$("#support-log").append(html).scrollTop($("#support-log")[0].scrollHeight);
+}
+
 /* Handle the user submitting the question form */
 function on_question_submit()
 {

mercurial