mirror of
https://github.com/ONLYOFFICE/onlyoffice.github.io.git
synced 2026-02-10 18:05:06 +08:00
Fix/problem with internet cheking (#3)
* [Marketplace] Change internet connection checking for plugin "Marketplace". * [Marketplace] Fix problem with timeout. * [Marketplace] Rename function. * [Marketplace] Add link to jquery. * [Marketplace] Add loader container. * Fix problem with clouds for desktop.
This commit is contained in:
7
store/plugin/3rd-Party.txt
Normal file
7
store/plugin/3rd-Party.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
This plugin uses code from the following 3rd party projects.
|
||||||
|
|
||||||
|
|
||||||
|
1. jQuery - Query is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. (http://jquery.com/)
|
||||||
|
|
||||||
|
License: MIT License
|
||||||
|
License File: jQuery.license
|
||||||
@ -8,7 +8,7 @@
|
|||||||
"cs" : "Správce Pluginů"
|
"cs" : "Správce Pluginů"
|
||||||
},
|
},
|
||||||
"guid" : "asc.{AA2EA9B6-9EC2-415F-9762-634EE8D9A95E}",
|
"guid" : "asc.{AA2EA9B6-9EC2-415F-9762-634EE8D9A95E}",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"group" : {
|
"group" : {
|
||||||
"name" : "Plugin Manager",
|
"name" : "Plugin Manager",
|
||||||
"rank" : 1
|
"rank" : 1
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
|
||||||
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
|
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
|
||||||
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
|
||||||
|
<script type="text/javascript" src="./vendor/jQuery-2.2.2-min/jquery-v2.2.2-min.js"></script>
|
||||||
<link rel="stylesheet" href="resources/css/styles.css">
|
<link rel="stylesheet" href="resources/css/styles.css">
|
||||||
<script type="text/javascript" src="scripts/code.js"></script>
|
<script type="text/javascript" src="scripts/code.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@ -32,5 +33,6 @@
|
|||||||
<div id="div_noIternet" class="hidden" style="position: absolute;">
|
<div id="div_noIternet" class="hidden" style="position: absolute;">
|
||||||
<label id="lb_noInternet" class="form-control lab noselect">No Internet Connection.</label>
|
<label id="lb_noInternet" class="form-control lab noselect">No Internet Connection.</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="loader-container" class="loader hidden"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
20
store/plugin/licenses/jQuery.license
Normal file
20
store/plugin/licenses/jQuery.license
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Copyright (c) 2009 John Resig, http://jquery.com/
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@ -43,4 +43,13 @@ html, body {
|
|||||||
}
|
}
|
||||||
.info {
|
.info {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.loader {
|
||||||
|
margin: 0 !important;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100% !important;
|
||||||
|
background-color: rgba(128, 128, 128, 0.5);
|
||||||
}
|
}
|
||||||
@ -16,12 +16,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
(function(window, undefined) {
|
(function(window, undefined) {
|
||||||
const isDesktop = window.AscDesktopEditor !== undefined;
|
const isLocal = ( (window.AscDesktopEditor !== undefined) && (window.location.protocol.indexOf('file') !== -1) );
|
||||||
let isOnline = isDesktop ? true : null;
|
|
||||||
let isInit = false;
|
|
||||||
let interval = null;
|
let interval = null;
|
||||||
if (!isDesktop)
|
let errTimeout = null;
|
||||||
checkInternet();
|
let loader = null;
|
||||||
|
let loaderTimeout = null;
|
||||||
|
|
||||||
// create iframe
|
// create iframe
|
||||||
const iframe = document.createElement("iframe");
|
const iframe = document.createElement("iframe");
|
||||||
@ -32,7 +31,7 @@
|
|||||||
let BPluginReady = false;
|
let BPluginReady = false;
|
||||||
let editorVersion = null;
|
let editorVersion = null;
|
||||||
let marketplaceURl = null;
|
let marketplaceURl = null;
|
||||||
const OOMarketplaceUrl = isDesktop ? './store/index.html' : 'https://onlyoffice.github.io/store/index.html';
|
const OOMarketplaceUrl = isLocal ? './store/index.html' : 'https://onlyoffice.github.io/store/index.html';
|
||||||
try {
|
try {
|
||||||
// for incognito mode
|
// for incognito mode
|
||||||
marketplaceURl = localStorage.getItem('DeveloperMarketplaceUrl') || OOMarketplaceUrl;
|
marketplaceURl = localStorage.getItem('DeveloperMarketplaceUrl') || OOMarketplaceUrl;
|
||||||
@ -41,8 +40,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.Asc.plugin.init = function() {
|
window.Asc.plugin.init = function() {
|
||||||
isInit = true;
|
// resize window
|
||||||
if (typeof isOnline === 'boolean') {
|
window.Asc.plugin.resizeWindow(608, 570, 608, 570, 0, 0);
|
||||||
|
if (!isLocal) {
|
||||||
|
checkInternet(true);
|
||||||
|
loaderTimeout = setTimeout(createLoader, 500);
|
||||||
|
} else {
|
||||||
initPlugin();
|
initPlugin();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -53,11 +56,10 @@
|
|||||||
|
|
||||||
function initPlugin() {
|
function initPlugin() {
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
// resize window
|
|
||||||
if (marketplaceURl !== OOMarketplaceUrl)
|
if (marketplaceURl !== OOMarketplaceUrl)
|
||||||
document.getElementById('notification').classList.remove('hidden');
|
document.getElementById('notification').classList.remove('hidden');
|
||||||
|
|
||||||
window.Asc.plugin.resizeWindow(608, 570, 608, 570, 0, 0);
|
// send message that plugin is ready
|
||||||
window.Asc.plugin.executeMethod("GetVersion", null, function(version) {
|
window.Asc.plugin.executeMethod("GetVersion", null, function(version) {
|
||||||
editorVersion = version;
|
editorVersion = version;
|
||||||
BPluginReady = true;
|
BPluginReady = true;
|
||||||
@ -66,31 +68,21 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let divNoInt = document.getElementById('div_noIternet');
|
let divNoInt = document.getElementById('div_noIternet');
|
||||||
// send message that plugin is ready
|
let style = document.getElementsByTagName('head')[0].lastChild;
|
||||||
if (isOnline) {
|
let pageUrl = marketplaceURl;
|
||||||
let style = document.getElementsByTagName('head')[0].lastChild;
|
iframe.src = pageUrl + window.location.search;
|
||||||
let pageUrl = marketplaceURl;
|
iframe.onload = function() {
|
||||||
iframe.src = pageUrl + window.location.search;
|
BFrameReady = true;
|
||||||
iframe.onload = function() {
|
if (BPluginReady) {
|
||||||
BFrameReady = true;
|
if (!divNoInt.classList.contains('hidden')) {
|
||||||
if (BPluginReady) {
|
divNoInt.classList.add('hidden');
|
||||||
if (!divNoInt.classList.contains('hidden')) {
|
clearInterval(interval);
|
||||||
divNoInt.classList.add('hidden');
|
interval = null;
|
||||||
clearInterval(interval);
|
|
||||||
interval = null;
|
|
||||||
}
|
|
||||||
postMessage( { type: 'Theme', theme: window.Asc.plugin.theme, style : style.innerHTML } );
|
|
||||||
postMessage( { type: 'PluginReady', version: editorVersion } );
|
|
||||||
}
|
}
|
||||||
};
|
postMessage( { type: 'Theme', theme: window.Asc.plugin.theme, style : style.innerHTML } );
|
||||||
} else {
|
postMessage( { type: 'PluginReady', version: editorVersion } );
|
||||||
divNoInt.classList.remove('hidden');
|
|
||||||
if (!interval) {
|
|
||||||
interval = setInterval(function() {
|
|
||||||
checkInternet();
|
|
||||||
}, 5000);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
window.Asc.plugin.button = function(id, windowID) {
|
window.Asc.plugin.button = function(id, windowID) {
|
||||||
@ -183,33 +175,49 @@
|
|||||||
label.innerHTML = window.Asc.plugin.tr(label.innerHTML);
|
label.innerHTML = window.Asc.plugin.tr(label.innerHTML);
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkInternet() {
|
function checkInternet(bSetTimeout) {
|
||||||
try {
|
try {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
let url = 'https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice.github.io/master/store/translations/langs.json';
|
let url = 'https://onlyoffice.github.io/store/translations/langs.json';
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
|
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
if (this.readyState == 4) {
|
if (this.readyState == 4) {
|
||||||
if (this.status >= 200 && this.status < 300) {
|
if (this.status >= 200 && this.status < 300) {
|
||||||
isOnline = true;
|
endInternetChecking(true);
|
||||||
if (isInit)
|
|
||||||
initPlugin();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onerror = function (err) {
|
xhr.onerror = function (err) {
|
||||||
isOnline = false;
|
endInternetChecking(false);
|
||||||
if (isInit)
|
|
||||||
initPlugin();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
isOnline = false;
|
endInternetChecking(false);
|
||||||
if (isInit)
|
}
|
||||||
initPlugin();
|
if (bSetTimeout) {
|
||||||
|
errTimeout = setTimeout(function() {
|
||||||
|
// if loading is too long show the error (because sometimes requests can not send error)
|
||||||
|
endInternetChecking(false);
|
||||||
|
}, 15000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function endInternetChecking(isOnline) {
|
||||||
|
clearTimeout(errTimeout);
|
||||||
|
errTimeout = null;
|
||||||
|
destroyLoader();
|
||||||
|
if (isOnline) {
|
||||||
|
initPlugin();
|
||||||
|
} else {
|
||||||
|
document.getElementById('div_noIternet').classList.remove('hidden');
|
||||||
|
if (!interval) {
|
||||||
|
interval = setInterval(function() {
|
||||||
|
checkInternet(false);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -267,4 +275,18 @@
|
|||||||
document.getElementsByTagName('html')[0].style.zoom = zoom;
|
document.getElementsByTagName('html')[0].style.zoom = zoom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function createLoader() {
|
||||||
|
$('#loader-container').removeClass( "hidden" );
|
||||||
|
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||||
|
loader = showLoader($('#loader-container')[0], window.Asc.plugin.tr('Checking internet connection...'));
|
||||||
|
};
|
||||||
|
|
||||||
|
function destroyLoader() {
|
||||||
|
clearTimeout(loaderTimeout);
|
||||||
|
loaderTimeout = null;
|
||||||
|
$('#loader-container').addClass( "hidden" )
|
||||||
|
loader && (loader.remove ? loader.remove() : $('#loader-container')[0].removeChild(loader));
|
||||||
|
loader = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
})(window, undefined);
|
})(window, undefined);
|
||||||
|
|||||||
@ -5,5 +5,6 @@
|
|||||||
"Yes" : "Ano",
|
"Yes" : "Ano",
|
||||||
"No" : "Ne",
|
"No" : "Ne",
|
||||||
"Do you want to completely remove this plugin?" : "Chcete tento plugin úplně odstranit?",
|
"Do you want to completely remove this plugin?" : "Chcete tento plugin úplně odstranit?",
|
||||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Pokud zvolíte \"Ne\", budete moci tento plugin obnovit později na Správce Pluginů."
|
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Pokud zvolíte \"Ne\", budete moci tento plugin obnovit později na Správce Pluginů.",
|
||||||
|
"Checking internet connection..." : "Kontrola připojení k internetu..."
|
||||||
}
|
}
|
||||||
@ -5,5 +5,6 @@
|
|||||||
"Yes" : "Ja",
|
"Yes" : "Ja",
|
||||||
"No" : "Nein",
|
"No" : "Nein",
|
||||||
"Do you want to completely remove this plugin?" : "Möchten Sie dieses Plugin vollständig entfernen?",
|
"Do you want to completely remove this plugin?" : "Möchten Sie dieses Plugin vollständig entfernen?",
|
||||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Wenn Sie \"Nein\" wählen, können Sie dieses Plugin später auf dem Plugin-Verwaltung wiederherstellen."
|
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Wenn Sie \"Nein\" wählen, können Sie dieses Plugin später auf dem Plugin-Verwaltung wiederherstellen.",
|
||||||
|
"Checking internet connection..." : "Internetverbindung prüfen..."
|
||||||
}
|
}
|
||||||
@ -5,5 +5,6 @@
|
|||||||
"Yes" : "Sí",
|
"Yes" : "Sí",
|
||||||
"No" : "No",
|
"No" : "No",
|
||||||
"Do you want to completely remove this plugin?" : "¿Quieres eliminar por completo este plugin?",
|
"Do you want to completely remove this plugin?" : "¿Quieres eliminar por completo este plugin?",
|
||||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si elige \"No\", podrá restaurar este complemento más adelante en el Administrador de Complementos."
|
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si elige \"No\", podrá restaurar este complemento más adelante en el Administrador de Complementos.",
|
||||||
|
"Checking internet connection..." : "Comprobación de la conexión a Internet..."
|
||||||
}
|
}
|
||||||
@ -5,5 +5,6 @@
|
|||||||
"Yes" : "Oui",
|
"Yes" : "Oui",
|
||||||
"No" : "Aucun",
|
"No" : "Aucun",
|
||||||
"Do you want to completely remove this plugin?" : "Voulez-vous supprimer complètement ce plugin?",
|
"Do you want to completely remove this plugin?" : "Voulez-vous supprimer complètement ce plugin?",
|
||||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si vous choisissez \"Aucun\", vous pourrez restaurer ce plugin plus tard sur le Gestionnaire de Plugins."
|
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Si vous choisissez \"Aucun\", vous pourrez restaurer ce plugin plus tard sur le Gestionnaire de Plugins.",
|
||||||
|
"Checking internet connection..." : "Vérification de la connexion Internet..."
|
||||||
}
|
}
|
||||||
@ -5,5 +5,6 @@
|
|||||||
"Yes" : "Да",
|
"Yes" : "Да",
|
||||||
"No" : "Нет",
|
"No" : "Нет",
|
||||||
"Do you want to completely remove this plugin?" : "Вы хотите полность удалить этот плагин?",
|
"Do you want to completely remove this plugin?" : "Вы хотите полность удалить этот плагин?",
|
||||||
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Если вы выберете \"Нет\", вы сможете восстановить этот плагин позже в Менеджере плагинов."
|
"If you choose \"No\", you will be able to restore this plugin later in the marketplace." : "Если вы выберете \"Нет\", вы сможете восстановить этот плагин позже в Менеджере плагинов.",
|
||||||
|
"Checking internet connection..." : "Проверка интернет соединения..."
|
||||||
}
|
}
|
||||||
4
store/plugin/vendor/jQuery-2.2.2-min/jquery-v2.2.2-min.js
vendored
Normal file
4
store/plugin/vendor/jQuery-2.2.2-min/jquery-v2.2.2-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -16,12 +16,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const version = '1.0.3'; // version of store (will change it when update something in store)
|
const version = '1.0.4'; // version of store (will change it when update something in store)
|
||||||
let start = Date.now();
|
let start = Date.now();
|
||||||
|
const isLocal = ( (window.AscDesktopEditor !== undefined) && (window.location.protocol.indexOf('file') !== -1) ); // desktop detecting
|
||||||
let isPluginLoading = false; // flag plugins loading
|
let isPluginLoading = false; // flag plugins loading
|
||||||
const isDesktop = window.AscDesktopEditor !== undefined; // desktop detecting
|
|
||||||
let isOnline = true; // flag internet connection
|
let isOnline = true; // flag internet connection
|
||||||
isDesktop && checkInternet(); // check internet connection (only for desktop)
|
isLocal && checkInternet(); // check internet connection (only for desktop)
|
||||||
let interval = null; // interval for checking internet connection (if it doesn't work on launch)
|
let interval = null; // interval for checking internet connection (if it doesn't work on launch)
|
||||||
const OOMarketplaceUrl = 'https://onlyoffice.github.io/'; // url to oficial store (for local version store in desktop)
|
const OOMarketplaceUrl = 'https://onlyoffice.github.io/'; // url to oficial store (for local version store in desktop)
|
||||||
const OOIO = 'https://github.com/ONLYOFFICE/onlyoffice.github.io/'; // url to oficial github repository (for links and discussions)
|
const OOIO = 'https://github.com/ONLYOFFICE/onlyoffice.github.io/'; // url to oficial github repository (for links and discussions)
|
||||||
@ -113,7 +113,7 @@ const ioUrl = location.href.substring(0, pos);
|
|||||||
// get translation file
|
// get translation file
|
||||||
getTranslation();
|
getTranslation();
|
||||||
// fetch all plugins from config
|
// fetch all plugins from config
|
||||||
if (!isDesktop)
|
if (!isLocal)
|
||||||
fetchAllPlugins(true, false);
|
fetchAllPlugins(true, false);
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
@ -179,7 +179,7 @@ window.addEventListener('message', function(message) {
|
|||||||
|
|
||||||
if (message.updateInstalled)
|
if (message.updateInstalled)
|
||||||
showListofPlugins(false);
|
showListofPlugins(false);
|
||||||
else if ( allPlugins.length || (isDesktop && !isOnline) )
|
else if ( allPlugins.length || (isLocal && !isOnline) )
|
||||||
getAllPluginsData(true, false);
|
getAllPluginsData(true, false);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -260,14 +260,14 @@ window.addEventListener('message', function(message) {
|
|||||||
|
|
||||||
if (installed) {
|
if (installed) {
|
||||||
bHasLocal = !installed.obj.baseUrl.includes(ioUrl);
|
bHasLocal = !installed.obj.baseUrl.includes(ioUrl);
|
||||||
if (plugin && (!bHasLocal || (isDesktop && !needBackup) ) ) {
|
if (plugin && (!bHasLocal || (isLocal && !needBackup) ) ) {
|
||||||
installedPlugins = installedPlugins.filter(function(el){return el.guid !== message.guid});
|
installedPlugins = installedPlugins.filter(function(el){return el.guid !== message.guid});
|
||||||
bUpdate = true;
|
bUpdate = true;
|
||||||
} else {
|
} else {
|
||||||
installed.removed = true;
|
installed.removed = true;
|
||||||
|
|
||||||
// нужно обновить список установленных плагинов, чтобы ссылки на ресурсы были правильными
|
// нужно обновить список установленных плагинов, чтобы ссылки на ресурсы были правильными
|
||||||
if (isDesktop)
|
if (isLocal)
|
||||||
sendMessage({ type: 'getInstalled', updateInstalled: true }, '*');
|
sendMessage({ type: 'getInstalled', updateInstalled: true }, '*');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ function getAllPluginsData(bFirstRender, bshowMarketplace) {
|
|||||||
isPluginLoading = true;
|
isPluginLoading = true;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let Unloaded = [];
|
let Unloaded = [];
|
||||||
let url = isDesktop ? OOMarketplaceUrl : ioUrl;
|
let url = isLocal ? OOMarketplaceUrl : ioUrl;
|
||||||
allPlugins.forEach(function(plugin, i, arr) {
|
allPlugins.forEach(function(plugin, i, arr) {
|
||||||
count++;
|
count++;
|
||||||
if (typeof plugin !== 'object') {
|
if (typeof plugin !== 'object') {
|
||||||
@ -589,7 +589,7 @@ function getAllPluginsData(bFirstRender, bshowMarketplace) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isDesktop && installedPlugins && bFirstRender && !isOnline) {
|
if (isLocal && installedPlugins && bFirstRender && !isOnline) {
|
||||||
isPluginLoading = false;
|
isPluginLoading = false;
|
||||||
getInstalledLanguages();
|
getInstalledLanguages();
|
||||||
showMarketplace();
|
showMarketplace();
|
||||||
@ -598,7 +598,7 @@ function getAllPluginsData(bFirstRender, bshowMarketplace) {
|
|||||||
|
|
||||||
function getDiscussion(config) {
|
function getDiscussion(config) {
|
||||||
// get discussion page
|
// get discussion page
|
||||||
if (isDesktop && window.AscSimpleRequest && window.AscSimpleRequest.createRequest) {
|
if (isLocal && window.AscSimpleRequest && window.AscSimpleRequest.createRequest) {
|
||||||
makeDesktopRequest(config.discussionUrl).then(
|
makeDesktopRequest(config.discussionUrl).then(
|
||||||
function(data) {
|
function(data) {
|
||||||
if (data.status == 'success') {
|
if (data.status == 'success') {
|
||||||
@ -674,7 +674,7 @@ function showListofPlugins(bAll, sortedArr) {
|
|||||||
let arr = (sortedArr ? sortedArr : (bAll ? allPlugins : installedPlugins));
|
let arr = (sortedArr ? sortedArr : (bAll ? allPlugins : installedPlugins));
|
||||||
|
|
||||||
// получаем список backup плагинов
|
// получаем список backup плагинов
|
||||||
if (!bAll && isDesktop) {
|
if (!bAll && isLocal) {
|
||||||
var _pluginsTmp = JSON.parse(window["AscDesktopEditor"]["GetBackupPlugins"]());
|
var _pluginsTmp = JSON.parse(window["AscDesktopEditor"]["GetBackupPlugins"]());
|
||||||
|
|
||||||
if (_pluginsTmp.length) {
|
if (_pluginsTmp.length) {
|
||||||
@ -858,7 +858,7 @@ function onClickInstall(target, event) {
|
|||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
// click install button
|
// click install button
|
||||||
// we should do that because we have some problem when desktop is loading plugin
|
// we should do that because we have some problem when desktop is loading plugin
|
||||||
if (isDesktop) {
|
if (isLocal) {
|
||||||
toogleLoader(true, 'Installation');
|
toogleLoader(true, 'Installation');
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
@ -880,7 +880,7 @@ function onClickInstall(target, event) {
|
|||||||
config : (installed ? installed.obj : plugin)
|
config : (installed ? installed.obj : plugin)
|
||||||
};
|
};
|
||||||
// we should do that because we have some problem when desktop is loading plugin
|
// we should do that because we have some problem when desktop is loading plugin
|
||||||
if (isDesktop) {
|
if (isLocal) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}, 200);
|
}, 200);
|
||||||
@ -892,7 +892,7 @@ function onClickInstall(target, event) {
|
|||||||
function onClickUpdate(target) {
|
function onClickUpdate(target) {
|
||||||
// click update button
|
// click update button
|
||||||
// we should do that because we have some problem when desktop is loading plugin
|
// we should do that because we have some problem when desktop is loading plugin
|
||||||
if (isDesktop) {
|
if (isLocal) {
|
||||||
toogleLoader(true, 'Updating');
|
toogleLoader(true, 'Updating');
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
@ -908,7 +908,7 @@ function onClickUpdate(target) {
|
|||||||
config : plugin
|
config : plugin
|
||||||
};
|
};
|
||||||
// we should do that because we have some problem when desktop is loading plugin
|
// we should do that because we have some problem when desktop is loading plugin
|
||||||
if (isDesktop) {
|
if (isLocal) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
}, 200);
|
}, 200);
|
||||||
@ -920,7 +920,7 @@ function onClickUpdate(target) {
|
|||||||
function onClickRemove(target, event) {
|
function onClickRemove(target, event) {
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
// click remove button
|
// click remove button
|
||||||
if (isDesktop) {
|
if (isLocal) {
|
||||||
toogleLoader(true, 'Removal');
|
toogleLoader(true, 'Removal');
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
@ -940,7 +940,7 @@ function needBackupPlugin(guid) {
|
|||||||
// если плагин есть в стор ( и его версия <= ? ), то можем удалить, пользователь сможет поставить актуальную версию
|
// если плагин есть в стор ( и его версия <= ? ), то можем удалить, пользователь сможет поставить актуальную версию
|
||||||
// если плагина нет в стор, нужно его хранить у пользователя с возможностью восстановления
|
// если плагина нет в стор, нужно его хранить у пользователя с возможностью восстановления
|
||||||
|
|
||||||
return isDesktop ? findPlugin(true, guid) == undefined : false;
|
return isLocal ? findPlugin(true, guid) == undefined : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickUpdateAll() {
|
function onClickUpdateAll() {
|
||||||
@ -990,14 +990,14 @@ function onClickItem() {
|
|||||||
elements.divRatingLink.setAttribute('title', getTranslated('No disscussion page for this plugin.'));
|
elements.divRatingLink.setAttribute('title', getTranslated('No disscussion page for this plugin.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !plugin || ( isDesktop && installed ) ) {
|
if ( !plugin || ( isLocal && installed ) ) {
|
||||||
elements.divGitLink.classList.add('hidden');
|
elements.divGitLink.classList.add('hidden');
|
||||||
plugin = installed.obj;
|
plugin = installed.obj;
|
||||||
} else {
|
} else {
|
||||||
elements.divGitLink.classList.remove('hidden');
|
elements.divGitLink.classList.remove('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
let bCorrectUrl = isDesktop || ( !plugin.baseUrl.includes('http://') && !plugin.baseUrl.includes('file:') && !plugin.baseUrl.includes('../'));
|
let bCorrectUrl = isLocal || ( !plugin.baseUrl.includes('http://') && !plugin.baseUrl.includes('file:') && !plugin.baseUrl.includes('../'));
|
||||||
|
|
||||||
if (bCorrectUrl && plugin.variations[0].store && plugin.variations[0].store.screenshots && plugin.variations[0].store.screenshots.length) {
|
if (bCorrectUrl && plugin.variations[0].store && plugin.variations[0].store.screenshots && plugin.variations[0].store.screenshots.length) {
|
||||||
let arrScreens = plugin.variations[0].store.screenshots;
|
let arrScreens = plugin.variations[0].store.screenshots;
|
||||||
@ -1407,7 +1407,7 @@ function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
|||||||
// In desktop we have a local installed marketplace. It's why we use local routes only for desktop.
|
// In desktop we have a local installed marketplace. It's why we use local routes only for desktop.
|
||||||
let baseUrl;
|
let baseUrl;
|
||||||
|
|
||||||
if (installedPlugins && isDesktop) {
|
if (installedPlugins && isLocal) {
|
||||||
// it doesn't work when we use icons from other resource (cors problems)
|
// it doesn't work when we use icons from other resource (cors problems)
|
||||||
// it's why we use local icons only for desktop
|
// it's why we use local icons only for desktop
|
||||||
plugin = findPlugin(false, guid);
|
plugin = findPlugin(false, guid);
|
||||||
@ -1417,13 +1417,13 @@ function getImageUrl(guid, bNotForStore, bSetSize, id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( !plugin || !isDesktop ) && allPlugins) {
|
if ( ( !plugin || !isLocal ) && allPlugins) {
|
||||||
plugin = findPlugin(true, guid);
|
plugin = findPlugin(true, guid);
|
||||||
if (plugin)
|
if (plugin)
|
||||||
baseUrl = plugin.baseUrl;
|
baseUrl = plugin.baseUrl;
|
||||||
}
|
}
|
||||||
// github doesn't allow to use "http" or "file" as the URL for an image
|
// github doesn't allow to use "http" or "file" as the URL for an image
|
||||||
if ( plugin && ( baseUrl.includes('https://') || isDesktop) ) {
|
if ( plugin && ( baseUrl.includes('https://') || isLocal) ) {
|
||||||
let variation = plugin.variations[0];
|
let variation = plugin.variations[0];
|
||||||
|
|
||||||
if (!bNotForStore && variation.store && variation.store.icons) {
|
if (!bNotForStore && variation.store && variation.store.icons) {
|
||||||
@ -1517,7 +1517,7 @@ function toogleView(current, oldEl, text, bAll, bForce) {
|
|||||||
current.classList.add('btn_toolbar_active');
|
current.classList.add('btn_toolbar_active');
|
||||||
elements.linkNewPlugin.innerHTML = getTranslated(text);
|
elements.linkNewPlugin.innerHTML = getTranslated(text);
|
||||||
let toolbar = document.getElementById('toolbar_tools');
|
let toolbar = document.getElementById('toolbar_tools');
|
||||||
let flag = !isDesktop && !isOnline;
|
let flag = !isLocal && !isOnline;
|
||||||
if ( ( bAll && (!isOnline || isPluginLoading) ) || flag) {
|
if ( ( bAll && (!isOnline || isPluginLoading) ) || flag) {
|
||||||
$('.div_notification').remove();
|
$('.div_notification').remove();
|
||||||
$('.div_item').remove();
|
$('.div_item').remove();
|
||||||
@ -1535,7 +1535,7 @@ function toogleView(current, oldEl, text, bAll, bForce) {
|
|||||||
}
|
}
|
||||||
elements.linkNewPlugin.href = bAll ? (OOIO + "pulls") : "https://api.onlyoffice.com/plugin/installation";
|
elements.linkNewPlugin.href = bAll ? (OOIO + "pulls") : "https://api.onlyoffice.com/plugin/installation";
|
||||||
|
|
||||||
if (isDesktop && !bAll) {
|
if (isLocal && !bAll) {
|
||||||
elements.linkNewPlugin.href = "#";
|
elements.linkNewPlugin.href = "#";
|
||||||
elements.linkNewPlugin.onclick = function (e) {
|
elements.linkNewPlugin.onclick = function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -1699,7 +1699,7 @@ function changeAfterInstallOrRemove(bInstall, guid, bHasLocal) {
|
|||||||
|
|
||||||
function checkInternet() {
|
function checkInternet() {
|
||||||
// url for check internet connection
|
// url for check internet connection
|
||||||
let url = 'https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice.github.io/master/store/translations/langs.json';
|
let url = 'https://onlyoffice.github.io/store/translations/langs.json';
|
||||||
makeRequest(url, 'GET', null, null, true).then(
|
makeRequest(url, 'GET', null, null, true).then(
|
||||||
function() {
|
function() {
|
||||||
isOnline = true;
|
isOnline = true;
|
||||||
@ -1714,7 +1714,7 @@ function checkInternet() {
|
|||||||
div.onclick();
|
div.onclick();
|
||||||
} else if (bshowMarketplace) {
|
} else if (bshowMarketplace) {
|
||||||
toogleView(elements.btnMarketplace, elements.btnAvailablePl, messages.linkPR, true, true);
|
toogleView(elements.btnMarketplace, elements.btnAvailablePl, messages.linkPR, true, true);
|
||||||
} else if (!isDesktop) {
|
} else if (!isLocal) {
|
||||||
toogleView(elements.btnAvailablePl, elements.btnMarketplace, messages.linkManually, false, true);
|
toogleView(elements.btnAvailablePl, elements.btnMarketplace, messages.linkManually, false, true);
|
||||||
}
|
}
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
@ -1733,7 +1733,7 @@ function handeNoInternet() {
|
|||||||
|
|
||||||
let bshowMarketplace = elements.btnMarketplace && elements.btnMarketplace.classList.contains('btn_toolbar_active');
|
let bshowMarketplace = elements.btnMarketplace && elements.btnMarketplace.classList.contains('btn_toolbar_active');
|
||||||
|
|
||||||
if ( (bshowMarketplace || !isDesktop) && elements.divSelected && !elements.divSelected.classList.contains('hidden') ) {
|
if ( (bshowMarketplace || !isLocal) && elements.divSelected && !elements.divSelected.classList.contains('hidden') ) {
|
||||||
sendMessage( { type : "showButton", show : false } );
|
sendMessage( { type : "showButton", show : false } );
|
||||||
onClickBack();
|
onClickBack();
|
||||||
}
|
}
|
||||||
@ -1741,7 +1741,7 @@ function handeNoInternet() {
|
|||||||
if (!document.getElementsByClassName('div_notification')[0]) {
|
if (!document.getElementsByClassName('div_notification')[0]) {
|
||||||
if (bshowMarketplace)
|
if (bshowMarketplace)
|
||||||
toogleView(elements.btnMarketplace, elements.btnAvailablePl, messages.linkPR, true, true);
|
toogleView(elements.btnMarketplace, elements.btnAvailablePl, messages.linkPR, true, true);
|
||||||
else if (!isDesktop)
|
else if (!isLocal)
|
||||||
toogleView(elements.btnAvailablePl, elements.btnMarketplace, messages.linkManually, false, true);
|
toogleView(elements.btnAvailablePl, elements.btnMarketplace, messages.linkManually, false, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user