Monday, January 11, 2010

Embedding Chat Client for Queue Manager into any page

Use the following IFrame HTML snippet that is used to embed the chat link on any page:

<iframe src ="http://fqdn.com/TestSTLink/api.html?userName=QueueSTID" style="background-color:Transparent" allowtransparency="true" width="100%" height="40" frameborder="0" scrolling="NO"></iframe>

IFrame points to the api.html file hosting on IQM server.

http://fqdn.com/TestSTLink/api.html?userName=QueueSTID

URL can contain any number of parameters. For example for passing the Queue display name the URL will look like:

http://fqdn.com/TestSTLink/api.html?userName=QueueSTID&displayName=Name

api.html page source is as follows:

---------------------
<html>
<head>
<link rel="STYLESHEET" href="http://fqdn/TestSTLink/stlinks.css" type="text/css">
<script type="text/javascript" src="http://fqdn/TestSTLink/stlinks.js">
<script type="text/javascript">
var InterviewStartNode="mynode";
setSTLinksURL("http://fqdn/TestSTLink");
</script>

<script type="text/javascript">
function getParameter(name, url) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(url);

if (results == null)
return "";
else {
return results[1];
}
}

function myunescape(str) {
str = "" + str;
while (true) {
var i = str.indexOf('+');
if (i <>
break;
str = str.substring(0, i) + '%20' +
str.substring(i + 1, str.length);
}
return unescape(str);
}
</script>

<script type="text/javascript">
writeSTLinksApplet("Web Visitor","",false);
</script>
</head>

<body style="background-color:transparent">
<script type="text/javascript">
var url=window.location.href;
var userName=getParameter('userName',url);
userName = myunescape(userName);
writeSametimeLink(userName," Live Chat","","",false," text:yes;icon:yes");
</script>
</body>

</html>
----------------------------------------

In the page getParameter() allows you to get value of any parameter that is passed on to the page. After the value is received you might want to use myunescape() to get rid of any escape character sequences.

No comments: