gpt4 book ai didi

javascript - 尝试填充 Lync Presence 时在 NPObject 上调用方法时出错

转载 作者:行者123 更新时间:2023-11-30 05:36:17 25 4
gpt4 key购买 nike

我想使用 javascript 填充 Lync 用户状态,并在下面找到一些很好的教程

http://blogs.msdn.com/b/tomholl/archive/2013/03/02/integrate-lync-into-your-intranet-sites-using-the-namectrl-plug-in.aspx

它在我的电脑上运行良好,但在我尝试在另一台不包含“微软”东西的电脑上运行后,我收到错误“在 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>

我应该安装特定的插件还是安装特定的软件到电脑上?

最佳答案

您应该将您的站点添加到 Internet Explorer 中的受信任站点。即使您没有使用 IE 运行您的应用程序,您也应该将该特定站点添加到受信任的站点。那么它也只能在非 IE 浏览器上工作。我也遇到了类似的问题,当我添加到受信任的站点时,问题就解决了。

关于javascript - 尝试填充 Lync Presence 时在 NPObject 上调用方法时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23605925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com