/** @format */

var userAgent = navigator.userAgent,
  rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
  rFirefox = /(firefox)\/([\w.]+)/,
  rOpera = /(opera).+version\/([\w.]+)/,
  rChrome = /(chrome)\/([\w.]+)/,
  rSafari = /version\/([\w.]+).*(safari)/;
var browser;
var version;
var ua = userAgent.toLowerCase();
export function uaMatch(ua) {
  var match = rMsie.exec(ua);
  if (match != null) {
    return { browser: "IE", version: match[2] || "0" };
  }
  var match = rFirefox.exec(ua);
  if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
  }
  var match = rOpera.exec(ua);
  if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
  }
  var match = rChrome.exec(ua);
  if (match != null) {
    return { browser: match[1] || "", version: match[2] || "0" };
  }
  var match = rSafari.exec(ua);
  if (match != null) {
    return { browser: match[2] || "", version: match[1] || "0" };
  }
  if (match != null) {
    return { browser: "", version: "0" };
  }
}
var browserMatch = uaMatch(userAgent.toLowerCase());
if (browserMatch.browser) {
  browser = browserMatch.browser;
  version = browserMatch.version;
}

var str = "";

// var copyright =
//   "金格科技iWebOffice2015智能文档中间件[演示版];V5.0S0xGAAEAAAAAAAAAEAAAAKkBAACwAQAALAAAAOdsFeIokb18K8sEYGhKKlfViSL+OmRUscIwKiqlAGQqWYRSZtv/GtAzU/Kq95sQMCjGuCYxNNLssxkrBjxjPfEXVzE4KJdGlBmhKMmCoRvjA5/FF1v8lqC0oWOzJ8tVpHqEL5GR62UVJF3EmYz3VypSarfY2oWBlWedL6GQI9jCYHipAU2OnPNc+12CQttwwEjApGeKor92uaUFEi7jumt3JM8qdJzFiuzFehCbxedXXdRuun9g2g5aht/6XwQ2yNIbteov5RgESvOzjwjtXRcfwD+R5anrSL75tR1Jhki9omVD/njeIEpGBxDrXy4WKkS86Uo2dy0kxF2ue/G7xXIjcPd9THNNPtnjlKhnLY5ssbzk3T5KI9FpuighQKidH4K7i/ezWy8tZiypQqxKG3B/sKMk63ZeegwlePJyzt68i0F+hdqHUts4d/XZOeNAENl3xkQ3ttM50krKgVlFDbpMkk292KWMu7bQd9PcRUiJQsljM21hOg5zAWkuZfZTUShmrC2a9++BwVrObk7t0aU1yFDu75FgUkE4Z71aJ84CsBbtui6uNppUB5jhsJfatNosjB+qyytrkJeaULhmfT8=";

var copyright =
  "河北省卫生健康委员会综合监督服务中心[专用];V5.0S0xGAAEAAAAAAAAAEAAAAIMBAACQAQAALAAAAP9kvweQGfH6fMFJhAskcnpQwDeYz5iv1m1/iQCjHFNmxQj2X+zjSKIs7YsMt3IRkU+2o5arN0iBCOQwJvkRTWV14H34uVXfEMIPGMMpJqEe8zQ4fpJFGO7SoNv1wZx4DrcRL7eEh/xx78BOAVGOfN+MeHEyowXfXQuvBhcSQd9gZIjGUNjOmw6N1VpV8PL/fP8TE9Yk1KvjlX95gmiaZCn9JwFi8yrGFt2XTZ4OAj3YY9q7a4hmqlp0Vq+Wbb7uUgCYtQ088UgIJlgKotV7JM9ReMfViI+8Lo4p5e9LIOpkxt5BzVQ2Y5WrP+WEI/TPdr6l/rILJxC/mPCmu4E8tS7Ni+ZeU2CVdpSRaJ6jfi4ozckJ5UO+o0XBJnyScyLQ7z2JBq2du4f+zrWP5N8VWf+Mbc720r48sE0e0U29KOcJiIkRGKArP/E9J6GXD+PqlDw7I6rFuZNBeFjZ9ipl5gorXca2M29N6kR15zEnPQOnS41Q0H6rjOBcTeJ//2NaKwAswPQff7dk1E/QznqYvv2cLWH/hYdgpKiJwty1zOm9";

var copyright_zukk =
  "河北省卫生健康委员会综合监督服务中心[专用];V5.0S0xGAAEAAAAAAAAAEAAAAI0BAACQAQAALAAAAKzMAg5TGjodAt3T0TAi7qZQbA5ZEvqVXsAp0rCKuGGKTk1Sq6vJutar4bdMlmoE/BIrbX7iRaG26TrgjhvFYPBbeyJ/DXAfAgw3ZlwlzFAW4R9RSQjOR2CJaqtNfE+BVn+64PqccosLFvpWv/OhzIiYsCSZZ/OezVmHGP/e2vTTa04yzlttisRGLio+wkt0xbxduBgs2PKq8/xO5mEf108ZTqCRlwj85lVFqrcPw2PT4zUhsI4ncNX3Pz7DLS9xLuHEimqU5LOrvPSF5NTfk4jeCSK0ABEqC03qENF7omyCnwUtbGK06Yo9xyZYlWUvFwmb1jIsb3qBGEt7nsp19HwN6AgzRJg3Rqm7MU6tw2Wr2YZjGuulv6XyQbQwbYViUmZVXBh4jrKZLf/rNhP/8hE5E4Yw6larmIHOwcDCdW7CgkPx8Jbyvm8ScatQlyRnGJum9QZw8gWyM4xO+8jB66XLVow1zQOgKqJsZx+yN/FnGXAiLVpuOYl3yR2r/kgdE/b4S3iWDnc/BgrHMOs6qwvjzcF/FL3MHBQquWB8EsR2";

// var copyright_zukk =
//   "金格科技iWebOffice信创中间件[演示];V5.0S0xGAAEAAAAAAAAAEAAAAF8BAABgAQAALAAAAGb/MDrC/wPBij0x6NXpOUI5EfDllFOegu+SVaJ+hFnSy45jNm2L2E/j/jqV7QpuhVKIfY2P+aPn/0vQ0tYYC6AKrRPQuxWXjSxbJcPECQCeYCLXudsoz9xDRpgMO57ooVekLVUuCiK6S2Fnm0YcBwbsXCl/ah4RrUatTz1DcCC1EFv3cb27xoMuA0OZQoBQdSENQzndm9PXgQQ1HXWX3dmDan0NQnDXVR/g5j0K8cvLVK89L7vNpMg4pK0Bl+dRIcJHuSQsi1PwQgMEZLFNdLkqYWg/ODvga1scJdNju5c2QZTCMs7VkInA/SJOsCH197ZqhjvlTBhY6bjuavzfPWWnDe2ZQwFElpA53AEVh6OXrDMKeIO1ONLUK/yS9ZoWU9WiSNx4euUwUyLJ5x3ABZjSiFOAmtUx0JRUrqYDkpqgnu41A6m0nGoLAbPa9KnQzBtJicAbpJu5YsDLuvFt3AhkdUHiyKuD/Tafi0gBOhYL";

if (
  window.ActiveXObject != undefined ||
  window.ActiveXObject != null ||
  "ActiveXObject" in window
) {
  str += '<object id="WebOffice2015" ';

  str += ' width="100%"';
  str += ' height="100%"';
  //32位控件
  if (window.navigator.platform == "Win32")
    str +=
      ' CLASSID="CLSID:D89F482C-5045-4DB5-8C53-D2C9EE71D025"  codebase="iWebOffice2015.cab#version=12,7,0,828"';
  //64位控件
  if (window.navigator.platform == "Win64")
    str +=
      ' CLASSID="CLSID:D89F482C-5045-4DB5-8C53-D2C9EE71D024"  codebase="iWebOffice2015.cab#version=12,5,0,652"';
  str += ">";
  str += '<param name="Copyright" value="' + copyright + '">';
} else if (browser == "chrome") {
  str += '<object id="WebOffice2015" ';

  str += ' width="100%"';
  str += ' height="100%"';
  str += ' clsid="CLSID:D89F482C-5045-4DB5-8C53-D2C9EE71D025"';
  str += ' type="application/kg-plugin"'; //KGChromePlugin插件type
  //str += ' type="application/kg-activex"';                           //iWebPlugin插件type
  //str += ' type="application/iwebplugin"';
  str += ' OnCommand="OnCommand"';
  str += ' OnOLECommand="OnOLECommand"';
  str += ' OnReady="OnReady"';
  str += ' OnRightClickedWhenAnnotate="OnRightClickedWhenAnnotate"';
  str += ' OnSending="OnSending"';
  str += ' OnSendEnd="OnSendEnd"';
  str += ' OnRecvStart="OnRecvStart"';
  str += ' OnRecving="OnRecving"';
  str += ' OnRecvEnd="OnRecvEnd"';
  str += ' OnFullSizeBefore="OnFullSizeBefore"';
  str += ' OnFullSizeAfter="OnFullSizeAfter"';
  str += ' Copyright="' + copyright + '"';
  str += ">";
} else if (browser == "firefox") {
  str += '<object id="WebOffice2015" ';
  str += ' width="100%"';
  str += ' height="1000px"';
  str += ' clsid="CLSID:D89F482C-5045-4DB5-8C53-D2C9EE71D025"';
  str += ' type="application/kg-activex"';
  //str += ' type="application/iwebplugin"';
  str += ' OnCommand="OnCommand"';
  str += ' OnReady="OnReady"';
  str += ' onUnload="onUnload"';
  str += ' OnOLECommand="OnOLECommand"';
  str += ' OnExecuteScripted="OnExecuteScripted"';
  str += ' OnQuit="OnQuit"';
  str += ' OnSendStart="OnSendStart"';
  str += ' OnSending="OnSending"';
  str += ' OnSendEnd="OnSendEnd"';
  str += ' OnRecvStart="OnRecvStart"';
  str += ' OnRecving="OnRecving"';
  str += ' OnRecvEnd="OnRecvEnd"';
  str += ' OnRightClickedWhenAnnotate="OnRightClickedWhenAnnotate"';
  str += ' OnFullSizeBefore="OnFullSizeBefore"';
  str += ' OnFullSizeAfter="OnFullSizeAfter"';
  str += ' Copyright="' + copyright + '"';
  str += ">";
}

str += "</object>";

var str_zukk =
  '<object id="WebOffice" type="application/iweboffice" height="100%" width="100%" >';
str_zukk += '<param name="Copyright" value="' + copyright_zukk + '">';
str_zukk += "</object>";

//alert(OSType.indexOf("Win"))
var OSType = detectOS();
export function LoadStr() {
  if (OSType.indexOf("Win") > -1) {
    //document.write(str);
    //alert(str);
    return str;
  } else {
    //alert(str_zukk);
    return str_zukk;
    //document.write(str_zukk);
  }
}

export function detectOS() {
  var sUserAgent = navigator.userAgent;
  //alert("navigator.userAgent" + navigator.userAgent);
  //alert("navigator.platform" + navigator.platform);

  var isWin = navigator.platform == "Win32" || navigator.platform == "Windows";
  var isMac =
    navigator.platform == "Mac68K" ||
    navigator.platform == "MacPPC" ||
    navigator.platform == "Macintosh" ||
    navigator.platform == "MacIntel";

  if (isMac) return "Mac";

  var isUnix = navigator.platform == "X11" && !isWin && !isMac;

  if (isUnix) return "Unix";

  var isLinux = String(navigator.platform).indexOf("Linux") > -1;

  if (isLinux) return "Linux";

  if (isWin) {
    return "isWin";

    var isWin2K =
      sUserAgent.indexOf("Windows NT 5.0") > -1 ||
      sUserAgent.indexOf("Windows 2000") > -1;
    if (isWin2K) return "Win2000";

    var isWinXP =
      sUserAgent.indexOf("Windows NT 5.1") > -1 ||
      sUserAgent.indexOf("Windows XP") > -1;
    if (isWinXP) return "WinXP";

    var isWin2003 =
      sUserAgent.indexOf("Windows NT 5.2") > -1 ||
      sUserAgent.indexOf("Windows 2003") > -1;
    if (isWin2003) return "Win2003";

    var isWinVista =
      sUserAgent.indexOf("Windows NT 6.0") > -1 ||
      sUserAgent.indexOf("Windows Vista") > -1;
    if (isWinVista) return "WinVista";

    var isWin7 =
      sUserAgent.indexOf("Windows NT 6.1") > -1 ||
      sUserAgent.indexOf("Windows 7") > -1;
    if (isWin7) return "Win7";

    var isWin10 =
      sUserAgent.indexOf("Windows NT 10.0") > -1 ||
      sUserAgent.indexOf("Windows 10") > -1;
    if (isWin10) return "isWin10";
  }

  return "other";
}

/////////////////////////////////////////////////////////////////////
//const WebOfficeStr = str
