|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- var isServerOk = false
- var isSetupOk = false
- var pluginsMode=0;
-
-
-
-
-
- var curList=[
- {"name":"WpsOAAssist","addonType":"wps","online":"true","url":"http://127.0.0.1:3888/plugin/wps/"},
- {"name":"EtOAAssist","addonType":"et","online":"true","url":"http://127.0.0.1:3888/plugin/et/"},
- {"name":"WppOAAssist","addonType":"wpp","online":"true","url":"http://127.0.0.1:3888/plugin/wpp/"}
- ]
- var localList=[];
- var publishIndex=0;
- var publishUnIndex=0;
-
-
- function installWpsAddin(callBack){
- WpsAddonMgr.getAllConfig(function(e){
-
-
- if(!e.response||e.response.indexOf("null")>=0){
- if(curList.length>0){
- installWpsAddinOne(callBack);
- }
- }else{
- localList=JSON.parse(e.response)
-
- unInstallWpsAddinOne(callBack)
- }
-
- })
- }
-
- function installWpsAddinOne(callBack){
- WpsAddonMgr.enable(curList[publishIndex],function(e){
- if(e.status){
- console.log(e.msg)
- }else{
- console.log("安装成功")
- }
- publishIndex++;
- if(publishIndex<curList.length){
- installWpsAddinOne();
- }else{
- callBack&&callBack()
- }
- })
- }
-
- function unInstallWpsAddinOne(callBack){
- WpsAddonMgr.disable(localList[publishUnIndex],function(e){
- if(e.status){
- console.log(e.msg)
- }else{
- console.log("卸载成功")
- }
- publishUnIndex++;
- if(publishUnIndex<localList.length){
- unInstallWpsAddinOne(callBack);
- }else{
- if(curList.length>0){
- installWpsAddinOne(callBack);
- }
- }
- })
- }
-
- function envTest() {
-
-
- var xhr = getHttpObj()
- xhr.onload = function(e) {
- isServerOk = true
-
- var xhr1 = getHttpObj()
- xhr1.onload = function(e) {
- if (xhr1.responseText.indexOf('异常') > -1 || xhr1.responseText.indexOf('未安装') > -1 || xhr1.responseText.indexOf('失败') > -1) {
- window.location.href = "./demo.html"
- return;
- }
- isSetupOk = true
- window.location.href.indexOf("file://") > -1 ? window.location.href = "http://127.0.0.1:3888/index.html" : ''
- }
- xhr1.onerror = function(e) {
- isServerOk = false
- window.location.href = "./demo.html"
- }
- xhr1.open('get', 'http://127.0.0.1:3888/WpsSetupTest?pluginsMode='+pluginsMode, true)
- xhr1.send()
- }
- xhr.onerror = function(e) {
- isServerOk = false
- window.location.href = "./demo.html"
- }
- xhr.open('get', 'http://127.0.0.1:3888/FileList', true)
- xhr.send();
- }
-
- function SwitchTab(crtTabIndex) {
- var iframe_wps = document.getElementById("iframe_wps");
- var iframe_wpp = document.getElementById("iframe_wpp");
- var iframe_et = document.getElementById("iframe_et");
-
- if (iframe_wps && iframe_wpp && iframe_et) {
- switch (crtTabIndex) {
- case 0:
- iframe_wpp.setAttribute("height", "0px");
- iframe_et.setAttribute("height", "0px");
- iframe_wps.setAttribute("height", "100%");
- break;
- case 1:
- iframe_wps.setAttribute("height", "0px");
- iframe_wpp.setAttribute("height", "0px");
- iframe_et.setAttribute("height", "100%");
- break;
- case 2:
- iframe_wps.setAttribute("height", "0px");
- iframe_et.setAttribute("height", "0px");
- iframe_wpp.setAttribute("height", "100%");
- break;
- default:
- iframe_wps.setAttribute("height", "0px");
- iframe_wpp.setAttribute("height", "0px");
- iframe_et.setAttribute("height", "0px");
- break;
- }
- }
- }
-
- function appChange() {
- var obj = document.getElementById("app");
- SwitchTab(obj.selectedIndex);
- }
-
- window.onload = function() {
- var app = document.getElementById("app");
- var opts = app.getElementsByTagName("option");
- opts[0].selected = true;
- var indexFrame = document.getElementById("indexFrame");
- indexFrame.innerHTML="<iframe src='./resource/wps.html?pluginsMode="+pluginsMode+"' id='iframe_wps' frameborder='0' width='100%' height='0%'></iframe><iframe src='./resource/wpp.html?pluginsMode="+pluginsMode+"' id='iframe_wpp' frameborder='0' width='100%' height='0%'></iframe><iframe src='./resource/et.html?pluginsMode="+pluginsMode+"' id='iframe_et' frameborder='0' width='100%' height='0%'></iframe>"
-
- SwitchTab(0);
-
- envTest()
- if(pluginsMode==1){
- installWpsAddin()
- }else{
-
- curList=[]
- installWpsAddin()
- }
-
- }
-
- function IEVersion() {
- var userAgent = navigator.userAgent;
- var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
- var isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
- var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
- if (isIE) {
- var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
- reIE.test(userAgent);
- var fIEVersion = parseFloat(RegExp["$1"]);
- if (fIEVersion == 7) {
- return 7;
- } else if (fIEVersion == 8) {
- return 8;
- } else if (fIEVersion == 9) {
- return 9;
- } else if (fIEVersion == 10) {
- return 10;
- } else {
- return 6;
- }
- } else if (isEdge) {
- return 20;
- } else if (isIE11) {
- return 11;
- } else {
- return 30;
- }
- }
-
- function getHttpObj() {
- var httpobj = null;
- if (IEVersion() < 10) {
- try {
- httpobj = new XDomainRequest();
- } catch (e1) {
- httpobj = new createXHR();
- }
- } else {
- httpobj = new createXHR();
- }
- return httpobj;
- }
-
- function createXHR() {
- if (typeof XMLHttpRequest != 'undefined') {
- return new XMLHttpRequest();
- } else if (typeof ActiveXObject != 'undefined') {
- var versions = [
- 'MSXML2.XMLHttp.6.0',
- 'MSXML2.XMLHttp.3.0',
- 'MSXML2.XMLHttp'
- ];
-
- for (var i = 0; i < versions.length; i++) {
- try {
- return new ActiveXObject(versions[i]);
- } catch (e) {
-
- }
- }
- } else {
- throw new Error('您的浏览器不支持XHR对象');
- }
- }
|