This Presence helps users to get in touch with their colleagues easily. User can see more information about colleagues like contact numbers, designation, departments without going to their personal page. Also it indicates the presence of colleague whether he/she available, away or offline.
<
span
class
=
"ms-verticalAlignTop ms-noWrap ms-displayInlineBlock"
>
"ms-imnSpan"
><
a
href
"#"
onclick
"IMNImageOnClick(event);return false;"
"ms-imnlink ms-spimn-presenceLink"
"ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10"
img
name
"imnmark"
title
""
showofflinepawn
"1"
"ms-spimn-img ms-spimn-presence-online-10x10x32"
src
"/_layouts/15/images/spimn.png"
alt
"Available"
sip
"ID@domain.com"
id
"imn_715,type=sip"
</
"ms-noWrap ms-imnSpan"
"ms-imnlink"
tabindex
"-1"
" ms-hide"
"imn_716,type=sip"
></
"ms-subtleLink"
"GoToLinkOrDialogNewWindow(this);return false;"
"/yammer/_layouts/15/userdisp.aspx?ID=259"
>User Name</
This is very easy and straight forward requirement for single user. What if you have to provide presence indicator of users more than one? In this case you need to be careful with some parameters in above code. These are:
User Presence with Picture Now in this article we will see how to display the OC or Lync Presence of user on mouse hover on the Picture of user. In one of my article we seen how to get my followers and those I am following. In this article let’s display users to whom I am following.
The Output of Presence Indicator with Picture is like below:
The below code snippet is used to generate this output:
script
type
"text/javascript"
function showPeople(followed) {
var htmlStr = "";
for (var i = 0; i <
3
; i++) {
var
userObj
followed
[i];
userName
.get_name();
userSiteUri
.get_personalSiteUri();
userId
.get_id();
userPictureUri
.get_imageUri();
userEmailAddress
.get_emailAddress();
if (userPictureUri == null) {
var picsStr = '<span
"ms-imnlink ms-spimn-prese nceLink"
"ms-spimn-presenceWrapper ms-spimn-imgSize-8x72"
onload
"IMNRC(\'' + userEmailAddress + '\')"
"' + userName + '"
ShowOfflinePawn
"ms-spimn-img ms-spimn-presence-disconnected-8x72x32"
"/_layouts/15/images/spimn.png?rev=23"
"' + userEmailAddress + '"
"imn_' + i + ',type=sip"
/></
tabIndex
"T_' + userName + '"
"A' + userName + '"
"simn_' + i + ',type=sip"
"ms-peopleux-imgUserLink"
"ms-peopleux-userImgWrapper"
style
"width:72px; height:72px"
"' + userSiteUri + '"
"min-width:72px; min-height:72px; clip:rect(0px, 72px, 72px, 0px); max-width:72px"
"/_layouts/15/images/PersonPlaceholder.200x150x32.png"
>';
}
else {
var picsStr = '<
"'+ userPictureUri +'"
htmlStr += picsStr;
$('#followedDiv').html(htmlStr);
div
id=" followedDiv'”></
Once the all images loads successfully, now do mouse hover on any user picture, the Lync/OC Presence Tool tip box appears. also the User Presence indicator appears in front of user picture. Important: when you are using JavaScript to generate this html and then binding it the control as in above example; do not forget to call “IMNRC“ on “onload” of image where presence is displayed. Without this “IMNRC” call user presence indicator will not work.
In this way you can implement user presence indicator in our application. With slight modification you can display the name of user instead of Picture, or both Picture and name.
Gokan Ozcifci edited Revision 1. Comment: Removed unsuded space and tag