From 1f76033e5d17b27a73ea2be2b4cf826483599f2e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 5 Sep 2016 16:06:24 +0300 Subject: [PATCH] [DE] Changed pluigns config. --- .../main/app/controller/Main.js | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 8996ee31a..7c46f711a 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -826,7 +826,7 @@ define([ application.getController('Common.Controllers.ExternalMergeEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); pluginsController.setApi(me.api); - me.updatePluginsList(me.plugins); + me.updatePlugins(me.plugins); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); documentHolderController.setApi(me.api); @@ -1721,6 +1721,60 @@ define([ if (url) this.iframePrint.src = url; }, + updatePlugins: function(plugins) { // plugins from config + if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return; + + var _createXMLHTTPObject = function() { + var xmlhttp; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); + } + return xmlhttp; + }; + + var _getPluginJson = function(plugin) { + if (!plugin) return ''; + try { + var xhrObj = _createXMLHTTPObject(); + if (xhrObj && plugin) { + xhrObj.open('GET', plugin, false); + xhrObj.send(''); + var pluginJson = eval("(" + xhrObj.responseText + ")"); + return pluginJson; + } + } + catch (e) {} + return null; + }; + + var arr = [], + baseUrl = plugins.url; + plugins.pluginsData.forEach(function(item){ + var url = item; + if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) + url = baseUrl + item; + var value = _getPluginJson(url); + if (value) arr.push(value); + }); + + if (arr.length>0) + this.updatePluginsList({ + url: plugins.url, + pluginsData: arr + }); + }, + updatePluginsList: function(plugins) { var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'), isEdit = this.appOptions.isEdit;