chrome不支持application / x-sharepoint-uc

时间:2017-04-12 03:27:24

标签: javascript google-chrome sharepoint

我正在努力展示Skype用户在网络应用程序中的存在,它应该适用于IE和无IE(Chrome / Edge / Firefox ......)。 以前,我可以在IE上使用NameCtrl,在Chome上使用application / x-sharepoint-uc来实现此目的,但它在chrome上不再起作用。 当我在chorme上检查navigator.mimeTypes时,我找不到application / x-sharepoint-uc,我认为这是导致这个问题的原因。 有没有人有类似的要求?或者你知道NameCtrl / application / x-sharepoint-uc的任何替换组件吗?

演示代码如下: `

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title>Lync plug-in demo</title>
      <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script>
      <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script>
      <script language="javascript">
         var nameCtrl = null;
         $(document).ready(function () {

             try {
               nameCtrl = new ActiveXObject("Name.NameCtrl");
           }
           catch (ex) {
             nameCtrl = CreateNPApiOnWindowsPlugin("application/x-sharepoint-uc");
         }
         finally{
             if (nameCtrl) {
                 attachLyncPresenceChangeEvent();
             }
         }
         });

         function addUser() {
             var userName = $('#userName').val();
             var userElementId = getId(userName);
             $('<div/>', {
                 text: userName,
                 id: userElementId,
                 class: 'user',
                 onmouseover: "showLyncPresencePopup('" + userName + "', this)",
                 onmouseout: "hideLyncPresencePopup()",
             }).appendTo('#users');

             if (nameCtrl) {
                 nameCtrl.GetStatus(userName, 'users');
             }
             $('#userName').val('');
         }

         function IsSupportedNPApiBrowserOnWin() {
         return true; // SharePoint does this: IsSupportedChromeOnWin() || IsSupportedFirefoxOnWin()
         }

         function IsNPAPIOnWinPluginInstalled(a) {
            return true;
         //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, x, y);
         }

         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);
             removePresenceClasses(userElement);
             userElement.addClass(presenceClass);

         }

         function removePresenceClasses(jqueryObj) {
             jqueryObj.removeClass('available');
             jqueryObj.removeClass('offline');
             jqueryObj.removeClass('away');
             jqueryObj.removeClass('busy');
             jqueryObj.removeClass('donotdisturb');
             jqueryObj.removeClass('inacall');
         }

         function getId(userName) {
             return userName.replace('@', '_').replace('.', '_');
         }
      </script>
      <style>
         .user {
         width: 250px;
         height: 40px;
         border-style: solid;
         border-width: 3px;
         }
         .available {
         border-color: green;
         }
         .offline {
         border-color: gray;
         }
         .away {
         border-color: yellow;
         }
         .busy, .inacall {
         border-color: red;
         }
         .donotdisturb {
         border-color: crimson;
         }
      </style>
   </head>
   <body>
      <h1>Lync Demo</h1>
      <div>
         Email/SIP address: <input type="text" id="userName" />
         <button id="add" onclick="addUser()">Add</button>
      </div>
      <div id="users">
      </div>
   </body>
</html>

`

0 个答案:

没有答案