« I hate it when England goes out on penalties... | Main| Last week I presented at the CTC Conference in Boston »

I got a request today from somebody for my STLinks code

Category
for the page that gets launched when a user clicks to chat with me from the link on the left.

Being the kind person I am, here it is

<html>

<head>


<style type="text/css">
.stHideLink{display:none}
.HideSupportLink{display:none}
.ShowSupportLink{display:inline;color:blue;text-decoration:none;cursor:hand}
</style>

<LINK REL=STYLESHEET HREF="http://stserverdnsname/sametime/stlinks/stlinks.css" TYPE="text/css">
<SCRIPT src="http://stserverdnsname/sametime/stlinks/stlinks.js"></SCRIPT>


<SCRIPT LANGUAGE="JavaScript">
function getParm(string,parm) {
// returns value of parm from string
var startPos = string.indexOf(parm + "=");
if (startPos > -1) {
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1)
endPos = string.length;
return unescape(string.substring(startPos,endPos));
}
return '';
}
</SCRIPT>


<SCRIPT>
var passed = location.search.substring(1);
var UsertoIM = getParm(passed,'UsertoIM');
setSTLinksURL("http://stserverdnsname/sametime/stlinks");
</SCRIPT>

<SCRIPT>
writeSTLinksApplet("Anonymous User","",false);
</SCRIPT>

<SCRIPT>
function STLinksAppletStarted(){
// alert("ST Links Applet Started successfully");
}
function STLinksLoggedIn(myUserId, myUserName){
// alert("ST Links Applet Logged in with UserID " + myUserId + " and the display name " + myUserName);

}
function STLinksUserStatusChanged(userId, displayName, status, statusMessage){
//Function is called by STLinks whenever a user whose presence is on the page changes
// alert(userId);
if (userId == UsertoIM) STLinksCreateIM(UsertoIM);
}
</SCRIPT>

</head>

<body>
<SCRIPT>
prepareSametimeLink(UsertoIM,"User to IM",false,"icon:no;onlineStyle:stHideLink;offlineStyle:stHideLink");
</SCRIPT>
<font face=verdana>If you are presented with a security warning, please accept it to continue into the chat.</font><br><br>
<DIV id="PopupTest" valign="center">
<font color="red" face=verdana><br>This machine has a popup blocker running, this <b>WILL</b> stop the chat window from appearing.</font>
</DIV>

<SCRIPT>
testpopupwindow = window.open('','testpopupwindow','width=15,height=15,toolbars=false');
if (testpopupwindow != null) {
testpopupwindow.document.open();
testpopupwindow.document.write('<head><title>Test Popup Window</title></head>');
testpopupwindow.document.write('<FONT SIZE=2>Popup test window, you may close this window</FONT>');
testpopupwindow.document.write('<scrip' + 't>');
testpopupwindow.document.write('window.opener.document.getElementById("PopupTest").innerHTML = "<font face=verdana>Please wait whilst you are connected...<\/font>";');
testpopupwindow.document.write(' testpopupwindow.document.close();
testpopupwindow.close();
}
</SCRIPT>
</body>

</html>


So what is this code doing? Well a couple of things, first the page loads looks at the parameters that were passed to the page to work out who the user wants to chat with, for the link on this blog that's
http://stserverdnsname/teststlinks.nsf/root/immediatechat.htm?opendocument&UsertoIM=CN=Carl Tyler/OU=US/O=Instant
Where the parameter UsertoIM contains the fully qualified name of the person to chat with.

Then the window loads an empty popup window to check that popups are allowed, if popups aren't allowed then the Sametime links window won't appear, so it's important I let the user know if that is the case, otherwise they will sit there for a long time...

Obviously stserverdnsname should be replaced with your sametime server name.

Comments

Gravatar Image1 - FONT tags?? Oh the shame!



But seriously, a useful post, thank you. I've used stlinks in an app in the past, and it's devilishly good.

Gravatar Image2 - I copied the code to an html page(page.html) ; I change the stservername to reflect my machine's host name; I got to the web browser and I enter http://myhost/sametime/stlinks/page.html&UsertoIM=CN=Erwin Zavala/O=TEST

Gravatar Image3 - thanks

Gravatar Image4 - Did you store the immediatechat.htm file as a file resource in your database? Is root a directory or folder?

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)