
Displaying Contextual Content in Custom Tabs
You can develop custom tab content that is specific to the current user or the currently selected contact names. When you set <contactid> or <userid> to true, Communicator sends the following two types of contextual information to your Web page:
-
The SIP URI of the current user, appended to the URL of the custom tab page.
-
An OnSelectionChange function call, sent automatically by Communicator every time one or more contacts are selected, or the current selection changes.
If the <userid> is, for example, sip:mallen@contoso.com, the URL used to retrieve the custom tab content is http://moc.corp.contoso.com/corpnews.html?userid= sip:mallen@contoso.com.
To retrieve the names of the currently selected contacts, use a scripting language to add an OnSelectionChange function to the Web page. OnSelectionChange has the following syntax:
OnSelectionChange(contacts, groups, distribution_groups)
The contacts and distribution_groups parameters contain SIP URIs of contacts and distribution groups, and the groups parameter contains the name of the group. If more than one contact or distribution group is selected, the SIP URIs are separated by semi-colons. Parameters that are not applicable at the time the OnSelectionChange event occurs are assigned a NULL value.
The following example shows how OnSelectionChange might be used on a simple Web page:
<html>
<head>
<title>Context-Sensitive Custom Tab</title>
<script language="javascript" >
function OnSelectionChange (ocContacts, ocGroups, ocDgs)
{
document.SelectionTest.contacts.value = ocContacts;
document.SelectionTest.groups.value = ocGroups;
document.SelectionTest.dgs.value = ocDgs;
}
function getUserName()
{
var params = location.search; //returns any form data appended to the URL
// regular expression returns the user ID in the second backreference
var parseParams = new RegExp("(userid=)([-a-zA-Z0-9+@._:]*)");
var name = "";
if (params == "")
name = "There is no data appended to the URL" ;
else
{
parseParams.exec(params);
name = RegExp.$2;
};
document.SelectionTest.userid.value = name;
}
</script>
</head>
<body>
<center>
<form name="SelectionTest" method="post">
<b>Context-Sensitive Custom Tab</b>
<table>
<tr>
<td style="width: 100px"> User ID</td>
<td style="width: 100px">
<input type="text" name="userid" size=100></font>
</td>
</tr>
<tr>
<td colspan="2">
<b>Select one or more contacts, groups, or distribution groups:</b>
</td>
</tr>
<tr>
<td style="width: 100px"> Contacts</td>
<td style="width: 100px">
<input type="text" name="contacts" size=100>
</td>
</tr>
<tr>
<td style="width: 100px"> Groups</td>
<td style="width: 100px">
<input type="text" name="groups" size=100>
</td>
</tr>
<tr>
<td style="width: 100px; height: 23px"> Distribution Groups</td>
<td style="width: 100px; height: 23px">
<input type="text" name="dgs" size=100>
</td>
</tr>
</table>
<script language="javascript" >
getUserName();
</script>
</form>
</body>
</html>