我想使用javascript填充Lync用户状态,并在下面找到一些好的教程
它在我的计算机上正常运行,但在我试图在另一台不包含" microsoft"我得到错误"错误调用方法在NPObject"。我试图为firefox安装active x插件但仍然出错(https://code.google.com/p/ff-activex-host/downloads/list)。
在我的代码下面
<script language="javascript">
var nameCtrl = null;
var lyncUsers = {
'1' : {
'name' : 'david',
'sip' : 'david@example.com',
'img' : 'lync_photo/example.png'
},
'2' : {
'name' : 'dennis',
'sip' : 'dennis@example.com',
'img' : 'lync_photo/example.png'
}
};
window.onload=function(){
try {
if (window.ActiveXObject) {
nameCtrl = new ActiveXObject("Name.NameCtrl");
} else {
nameCtrl = CreateNPApiOnWindowsPlugin("application/x-sharepoint-uc");
}
attachLyncPresenceChangeEvent();
PopulateUser();
}
catch (ex) {alert(ex.toString()); }
};
function PopulateUser() {
for (objVal in lyncUsers) {
var userName = lyncUsers[objVal].sip;
var userElementId = getId(userName);
var imagePath = lyncUsers[objVal].img;
var userSection = "<div id=\""+userElementId+"\" class=\"user\"";
userSection += "onmouseover=\"showLyncPresencePopup('"+userName+"', this)\" onmouseout=\"hideLyncPresencePopup()\">";
userSection += "<img class=\"img_user\"width=\"80px\" height=\"80px\" src=\""+imagePath+"\" />";
userSection += "</div>";
var div = document.getElementById('users');
div.innerHTML += userSection;
getStatus(userName);
}
}
function getStatus(sip)
{
if (nameCtrl) {
nameCtrl.GetStatus(sip, 'users');
}
}
function IsSupportedNPApiBrowserOnWin() {
return true; // SharePoint does this: IsSupportedChromeOnWin() || IsSupportedFirefoxOnWin()
}
function IsNPAPIOnWinPluginInstalled(a) {
return Boolean(navigator.mimeTypes) && navigator.mimeTypes[a] && navigator.mimeTypes[a].enabledPlugin
}
function CreateNPApiOnWindowsPlugin(b) {
var c = null;
if (IsSupportedNPApiBrowserOnWin())
try {
c = document.getElementById(b);
if (!Boolean(c) && IsNPAPIOnWinPluginInstalled(b)) {
var a = document.createElement("object");
a.id = b;
a.type = b;
a.width = "0";
a.height = "0";
a.style.setProperty("visibility", "hidden", "");
document.body.appendChild(a);
c = document.getElementById(b)
}
} catch (d) {
c = null
}
return c
}
function showLyncPresencePopup(userName, target) {
if (!nameCtrl) {
return;
}
//var eLeft = $(target).offset().left;
//var x = eLeft - $(window).scrollLeft();
//var eTop = $(target).offset().top;
//var y = eTop - $(window).scrollTop();
nameCtrl.ShowOOUI(userName, 0, 100, 100);
}
function hideLyncPresencePopup() {
if (!nameCtrl) {
return;
}
nameCtrl.HideOOUI();
}
function getLyncPresenceString(status) {
switch (status) {
case 0:
return 'available';
break;
case 1:
return 'offline';
break;
case 2:
case 4:
case 16:
return 'away';
break;
case 3:
case 5:
return 'inacall';
break;
case 6:
case 7:
case 8:
case 10:
return 'busy';
break;
case 9:
case 15:
return 'donotdisturb';
break;
default:
return '';
}
}
function attachLyncPresenceChangeEvent() {
if (!nameCtrl) {
return;
}
nameCtrl.OnStatusChange = onLyncPresenceStatusChange;
}
function onLyncPresenceStatusChange(userName, status, id) {
var presenceClass = getLyncPresenceString(status);
var userElementId = getId(userName);
//var userElement = $('#' + userElementId + " .img_user");
var userElement = document.getElementById(userElementId).getElementsByClassName("img_user");
removePresenceClasses(userElement);
userElement[0].classList.add(presenceClass);
}
function removePresenceClasses(Obj) {
Obj[0].classList.remove('available');
Obj[0].classList.remove('offline');
Obj[0].classList.remove('away');
Obj[0].classList.remove('busy');
Obj[0].classList.remove('donotdisturb');
Obj[0].classList.remove('inacall');
}
function getId(userName) {
return userName.replace(/\@/g, '_').replace(/\./g, '_');
}
</script>
<style>
.user{
margin-bottom:20px;
width:80px;
}
.img_user{
width:80px;
border-left: 10px solid;
}
.available {
border-color: #5DD255;
}
.offline {
border-color: gray;
}
.away {
border-color: #FFD200;
}
.busy, .inacall {
border-color: #D00E0D;
}
.donotdisturb {
border-color: #C72D25;
}
</style>
我应该安装特定的插件或安装特定的软件到计算机?
答案 0 :(得分:1)
您应该将您的网站添加到Internet Explorer中的受信任网站。 即使您没有使用IE运行应用程序,也应将该特定站点添加到受信任的站点。然后它也只适用于非IE浏览器。我也遇到了类似的问题,当我加入可信站点时问题得到了解决。