2020-02-27 13:45:29 +01:00
|
|
|
/**
|
|
|
|
* Internal Helper Module
|
2020-03-20 08:14:31 +01:00
|
|
|
* Belongs to Decentraleyes/LocalCDN.
|
2020-02-27 13:45:29 +01:00
|
|
|
*
|
|
|
|
* @author Thomas Rientjes
|
2020-03-20 08:14:31 +01:00
|
|
|
* @author nobody42
|
2020-02-27 13:45:29 +01:00
|
|
|
* @since 2017-10-26
|
|
|
|
* @license MPL 2.0
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helpers
|
|
|
|
*/
|
|
|
|
|
|
|
|
var helpers = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
helpers.insertI18nContentIntoDocument = function (document) {
|
|
|
|
|
|
|
|
let scriptDirection, i18nElements;
|
|
|
|
|
|
|
|
scriptDirection = helpers.determineScriptDirection(navigator.language);
|
|
|
|
i18nElements = document.querySelectorAll('[data-i18n-content]');
|
|
|
|
|
|
|
|
i18nElements.forEach(function (i18nElement) {
|
|
|
|
|
|
|
|
let i18nMessageName = i18nElement.getAttribute('data-i18n-content');
|
|
|
|
|
|
|
|
i18nElement.innerText = chrome.i18n.getMessage(i18nMessageName);
|
|
|
|
i18nElement.setAttribute('dir', scriptDirection);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.insertI18nTitlesIntoDocument = function (document) {
|
|
|
|
|
|
|
|
let scriptDirection, i18nElements;
|
|
|
|
|
|
|
|
scriptDirection = helpers.determineScriptDirection(navigator.language);
|
|
|
|
i18nElements = document.querySelectorAll('[data-i18n-title]');
|
|
|
|
|
|
|
|
i18nElements.forEach(function (i18nElement) {
|
|
|
|
|
|
|
|
let i18nMessageName = i18nElement.getAttribute('data-i18n-title');
|
|
|
|
|
|
|
|
i18nElement.setAttribute('title', chrome.i18n.getMessage(i18nMessageName));
|
|
|
|
i18nElement.setAttribute('dir', scriptDirection);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.languageIsFullySupported = function (language) {
|
|
|
|
|
|
|
|
let languageSupported, supportedLanguages;
|
|
|
|
|
|
|
|
languageSupported = false;
|
|
|
|
|
|
|
|
supportedLanguages = [
|
|
|
|
'ar', 'bg', 'zh', 'cs', 'da', 'nl', 'en', 'eo', 'et', 'fi',
|
|
|
|
'fr', 'de', 'el', 'he', 'hu', 'is', 'id', 'it', 'ja', 'ko',
|
|
|
|
'nb', 'pl', 'pt', 'ro', 'ru', 'es', 'sv', 'tr'
|
|
|
|
];
|
|
|
|
|
|
|
|
for (let supportedLanguage of supportedLanguages) {
|
|
|
|
|
|
|
|
if (language.search(supportedLanguage) !== -1) {
|
|
|
|
languageSupported = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return languageSupported;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.normalizeDomain = function (domain) {
|
|
|
|
|
|
|
|
domain = domain.toLowerCase().trim();
|
|
|
|
|
|
|
|
if (domain.startsWith(Address.WWW_PREFIX)) {
|
|
|
|
domain = domain.slice(Address.WWW_PREFIX.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return domain;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.extractDomainFromUrl = function (url = '', normalize) {
|
|
|
|
|
|
|
|
let extractedDomain;
|
|
|
|
|
|
|
|
try {
|
|
|
|
extractedDomain = new URL(url).host;
|
|
|
|
} catch (exception) {
|
|
|
|
extractedDomain = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (url.startsWith(Address.CHROME)) {
|
|
|
|
extractedDomain = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extractedDomain === '') {
|
|
|
|
extractedDomain = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extractedDomain !== null && normalize === true) {
|
|
|
|
extractedDomain = helpers.normalizeDomain(extractedDomain);
|
|
|
|
}
|
|
|
|
|
|
|
|
return extractedDomain;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.extractFilenameFromPath = function (path) {
|
|
|
|
|
|
|
|
let pathSegments, filename;
|
|
|
|
|
|
|
|
pathSegments = path.split('/');
|
|
|
|
filename = pathSegments[pathSegments.length - 1];
|
|
|
|
|
|
|
|
return filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.generateRandomHexString = function (length) {
|
|
|
|
|
|
|
|
let randomValues, randomHexString;
|
|
|
|
|
|
|
|
randomValues = crypto.getRandomValues(new Uint8Array(length));
|
|
|
|
randomHexString = '';
|
|
|
|
|
|
|
|
for (let value of randomValues) {
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-bitwise
|
|
|
|
let hexValue = (0 ^ value & 15 >> 0 / 4).toString(16);
|
|
|
|
randomHexString += hexValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return randomHexString;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.determineCdnName = function (domainName) {
|
|
|
|
|
|
|
|
switch (domainName) {
|
|
|
|
|
|
|
|
case 'ajax.googleapis.com':
|
|
|
|
return 'Google Hosted Libraries';
|
|
|
|
case 'ajax.aspnetcdn.com':
|
|
|
|
return 'Microsoft Ajax CDN';
|
|
|
|
case 'ajax.microsoft.com':
|
|
|
|
return 'Microsoft Ajax CDN [Deprecated]';
|
|
|
|
case 'cdnjs.cloudflare.com':
|
|
|
|
return 'CDNJS (Cloudflare)';
|
|
|
|
case 'code.jquery.com':
|
|
|
|
return 'jQuery CDN (MaxCDN)';
|
|
|
|
case 'cdn.jsdelivr.net':
|
2020-03-16 15:25:18 +01:00
|
|
|
return 'jsDelivr (Cloudflare)';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'yastatic.net':
|
|
|
|
return 'Yandex CDN';
|
|
|
|
case 'yandex.st':
|
|
|
|
return 'Yandex CDN [Deprecated]';
|
|
|
|
case 'apps.bdimg.com':
|
|
|
|
return 'Baidu CDN';
|
|
|
|
case 'libs.baidu.com':
|
|
|
|
return 'Baidu CDN [Deprecated]';
|
|
|
|
case 'lib.sinaapp.com':
|
|
|
|
return 'Sina Public Resources';
|
|
|
|
case 'upcdn.b0.upaiyun.com':
|
|
|
|
return 'UpYun Library';
|
|
|
|
case 'cdn.bootcss.com':
|
|
|
|
return 'BootCDN';
|
|
|
|
case 'sdn.geekzu.org':
|
|
|
|
return 'Geekzu Public Service [Mirror]';
|
|
|
|
case 'ajax.proxy.ustclug.org':
|
|
|
|
return 'USTC Linux User Group [Mirror]';
|
2020-03-16 15:25:18 +01:00
|
|
|
case 'unpkg.com':
|
|
|
|
return 'UNPKG (Cloudflare)';
|
2020-02-27 17:23:39 +01:00
|
|
|
case 'stackpath.bootstrapcdn.com':
|
|
|
|
return 'StackPath BootstrapCDN';
|
2020-03-12 09:23:55 +01:00
|
|
|
case 'maxcdn.bootstrapcdn.com':
|
|
|
|
return 'MaxCDN Bootstrap CDN';
|
2020-03-13 17:51:50 +01:00
|
|
|
case 'use.fontawesome.com':
|
|
|
|
return 'Font Awesome CDN';
|
2020-03-25 08:52:40 +01:00
|
|
|
case 'ajax.cloudflare.com':
|
|
|
|
return 'Cloudflare CDN';
|
2020-03-25 15:31:33 +01:00
|
|
|
case 'akamai-webcdn.kgstatic.net':
|
|
|
|
return 'Akamai WebCDN';
|
2020-02-27 13:45:29 +01:00
|
|
|
default:
|
|
|
|
return 'Unknown';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.determineResourceName = function (filename) {
|
|
|
|
|
|
|
|
switch (filename) {
|
|
|
|
|
|
|
|
case 'angular.min.jsm':
|
|
|
|
return 'AngularJS';
|
2020-02-29 08:15:48 +01:00
|
|
|
case 'angular-animate.min.jsm':
|
|
|
|
return 'AngularJS Animate';
|
|
|
|
case 'angular-cookies.min.jsm':
|
|
|
|
return 'AngularJS Cookies';
|
|
|
|
case 'angular-sanitize.min.jsm':
|
|
|
|
return 'AngularJS Sanitize';
|
|
|
|
case 'angular-touch.min.jsm':
|
|
|
|
return 'AngularJS Touch';
|
2020-03-28 11:15:53 +01:00
|
|
|
case 'animate.min.cssm':
|
2020-03-26 07:20:34 +01:00
|
|
|
return 'Animate CSS'
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'backbone-min.jsm':
|
|
|
|
return 'Backbone.js';
|
2020-03-25 08:52:40 +01:00
|
|
|
case 'bootstrap.min.cssm':
|
|
|
|
return 'Bootstrap CSS';
|
2020-03-28 11:15:53 +01:00
|
|
|
case 'bootstrap.min.css':
|
|
|
|
return 'Bootstrap CSS';
|
2020-03-25 08:52:40 +01:00
|
|
|
case 'bootstrap.min.jsm':
|
|
|
|
return 'Bootstrap JS';
|
2020-03-26 07:22:09 +01:00
|
|
|
case 'bootstrap-slider.min.jsm':
|
|
|
|
return 'bootstrap-slider JS';
|
2020-03-25 08:52:40 +01:00
|
|
|
case 'bootstrap-slider.min.cssm':
|
2020-03-26 07:22:09 +01:00
|
|
|
return 'bootstrap-slider CSS';
|
2020-03-26 10:16:29 +01:00
|
|
|
case 'clipboard.min.jsm':
|
|
|
|
return 'clipboard.js';
|
2020-03-26 11:04:21 +01:00
|
|
|
case 'd3.min.jsm':
|
|
|
|
return 'D3.js';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'dojo.jsm':
|
|
|
|
return 'Dojo';
|
|
|
|
case 'ember.min.jsm':
|
|
|
|
return 'Ember.js';
|
|
|
|
case 'ext-core.jsm':
|
|
|
|
return 'Ext Core';
|
2020-03-28 18:56:07 +01:00
|
|
|
case 'flv.min.jsm':
|
|
|
|
return 'flv.js';
|
2020-03-24 09:42:24 +01:00
|
|
|
case 'font-awesome.min.cssm':
|
2020-03-13 17:51:50 +01:00
|
|
|
return 'Font Awesome';
|
2020-03-24 09:42:24 +01:00
|
|
|
case 'all.cssm':
|
2020-03-12 06:42:31 +01:00
|
|
|
return 'Font Awesome';
|
2020-03-28 19:00:46 +01:00
|
|
|
case 'hls.min.jsm':
|
|
|
|
return 'hls.js';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'jquery.min.jsm':
|
|
|
|
return 'jQuery';
|
|
|
|
case 'jquery-ui.min.jsm':
|
|
|
|
return 'jQuery UI';
|
2020-03-26 10:57:32 +01:00
|
|
|
case 'jquery.blockUI.min.jsm':
|
|
|
|
return 'jQuery Block UI';
|
2020-03-26 07:41:01 +01:00
|
|
|
case 'jquery.validate.min.jsm':
|
2020-03-26 08:08:26 +01:00
|
|
|
return 'jQuery jeditable';
|
|
|
|
case 'jquery.jeditable.min.jsm':
|
2020-03-26 07:41:01 +01:00
|
|
|
return 'jQuery Validation Plugin';
|
2020-03-26 09:41:51 +01:00
|
|
|
case 'js.cookie.min.jsm':
|
|
|
|
return 'JavaScript Cookie';
|
2020-03-26 07:33:27 +01:00
|
|
|
case 'lazysizes.min.jsm':
|
|
|
|
return 'lazysizes';
|
2020-03-25 15:31:33 +01:00
|
|
|
case 'lozad.min.jsm':
|
2020-03-24 07:48:45 +01:00
|
|
|
return 'lozad.js';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'modernizr.min.jsm':
|
|
|
|
return 'Modernizr';
|
2020-03-24 08:11:03 +01:00
|
|
|
case 'moment.min.jsm':
|
|
|
|
return 'Modernizr';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'mootools-yui-compressed.jsm':
|
|
|
|
return 'MooTools';
|
2020-03-26 09:41:14 +01:00
|
|
|
case 'p2p-media-loader-core.min.jsm':
|
|
|
|
return 'P2P Media Loader Core';
|
2020-03-24 08:45:14 +01:00
|
|
|
case 'page.min.jsm':
|
|
|
|
return 'page.js';
|
2020-03-26 11:18:10 +01:00
|
|
|
case 'plyr.min.cssm':
|
|
|
|
return 'plyr CSS';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'prototype.jsm':
|
|
|
|
return 'Prototype';
|
2020-03-25 08:52:40 +01:00
|
|
|
case 'rocket-loader.min.jsm':
|
2020-03-26 07:48:48 +01:00
|
|
|
return 'Rocket Loader';
|
|
|
|
case 'rickshaw.min.jsm':
|
|
|
|
return 'rickshaw JS';
|
|
|
|
case 'rickshaw.min.cssm':
|
|
|
|
return 'rickshaw CSS';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'scriptaculous.jsm':
|
|
|
|
return 'Scriptaculous';
|
2020-03-26 10:57:11 +01:00
|
|
|
case 'spin.min.jsm':
|
|
|
|
return 'spin.js';
|
2020-03-27 09:00:14 +01:00
|
|
|
case 'store.legacy.min.jsm':
|
|
|
|
return 'Store.js';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'swfobject.jsm':
|
|
|
|
return 'SWFObject';
|
2020-03-26 07:24:37 +01:00
|
|
|
case 'toastr.min.cssm':
|
|
|
|
return 'toastr.js';
|
|
|
|
case 'toastr.min.jsm':
|
|
|
|
return 'toastr.js';
|
2020-02-27 13:45:29 +01:00
|
|
|
case 'underscore-min.jsm':
|
|
|
|
return 'Underscore.js';
|
|
|
|
case 'webfont.jsm':
|
|
|
|
return 'Web Font Loader';
|
2020-03-26 10:38:02 +01:00
|
|
|
case 'adapter.min.jsm':
|
|
|
|
return 'WebRTC adapter';
|
2020-03-24 08:45:14 +01:00
|
|
|
case 'vue.jsm':
|
|
|
|
return 'Vue.js';
|
2020-03-26 07:25:20 +01:00
|
|
|
case 'wow.min.jsm':
|
|
|
|
return 'WOW';
|
2020-02-27 13:45:29 +01:00
|
|
|
default:
|
|
|
|
return 'Unknown';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-03-24 08:03:08 +01:00
|
|
|
helpers.determineBundle = function (path = '') {
|
|
|
|
if (path.includes('findify')) {
|
|
|
|
return 'Findify';
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-27 13:45:29 +01:00
|
|
|
helpers.determineScriptDirection = function (language) {
|
|
|
|
|
|
|
|
let rightToLeftLanguages, scriptDirection;
|
|
|
|
|
|
|
|
rightToLeftLanguages = ['ar', 'he'];
|
|
|
|
|
|
|
|
if (rightToLeftLanguages.indexOf(language) === -1) {
|
|
|
|
scriptDirection = 'ltr';
|
|
|
|
} else {
|
|
|
|
scriptDirection = 'rtl';
|
|
|
|
}
|
|
|
|
|
|
|
|
return scriptDirection;
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.formatNumber = function (number) {
|
|
|
|
|
|
|
|
if (typeof number === 'number') {
|
|
|
|
return number.toLocaleString();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
helpers.formatVersion = function (version) {
|
|
|
|
|
|
|
|
if (version.indexOf('beta') === -1) {
|
|
|
|
return version;
|
|
|
|
} else {
|
|
|
|
return 'BETA';
|
|
|
|
}
|
|
|
|
};
|
2020-03-16 14:50:13 +01:00
|
|
|
|
2020-03-26 09:41:14 +01:00
|
|
|
helpers.setLastVersion = function (type, version) {
|
2020-03-16 14:50:13 +01:00
|
|
|
|
2020-03-26 09:41:14 +01:00
|
|
|
let requestVersion;
|
2020-03-29 07:24:24 +02:00
|
|
|
|
|
|
|
if(version !== null && version !== undefined) {
|
2020-03-26 09:41:14 +01:00
|
|
|
requestVersion = version.toString();
|
2020-03-29 07:24:24 +02:00
|
|
|
} else if (version === null) {
|
|
|
|
return 'latest';
|
2020-03-24 07:48:45 +01:00
|
|
|
}
|
2020-03-16 14:50:13 +01:00
|
|
|
if (type.includes('/angularjs/1.')) {
|
|
|
|
version = '1.7.9';
|
2020-03-26 07:20:34 +01:00
|
|
|
} else if (type.includes('/animate.css/3.')) {
|
|
|
|
version = '3.7.2';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/backbone.js/0.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '0.9.10';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/backbone.js/1.')) {
|
|
|
|
version = '1.4.0';
|
|
|
|
} else if (type.includes('/bootstrap.js/3.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '3.3.7';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/bootstrap.js/4.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '4.4.1';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/bootstrap.css/3.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '3.3.7';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/bootstrap.css/4.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '4.4.1';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/bootstrap-slider/10.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '10.6.2';
|
2020-03-26 10:16:29 +01:00
|
|
|
} else if (type.includes('/clipboard.js/2.')) {
|
|
|
|
version = '2.0.6';
|
2020-03-26 08:14:09 +01:00
|
|
|
} else if (type.includes('/d3/3.')) {
|
|
|
|
version = '3.5.17';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/dojo/1.')) {
|
2020-03-17 06:33:55 +01:00
|
|
|
version = '1.14.1';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/ember.js/1.')) {
|
2020-03-17 07:06:26 +01:00
|
|
|
version = '1.13.13';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/ember.js/2.')) {
|
2020-03-17 07:06:26 +01:00
|
|
|
version = '2.18.2';
|
|
|
|
} else if (type.includes('/ember.js/3.')) {
|
|
|
|
version = '3.12.3';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/ext-core/3.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '3.1.0';
|
2020-03-24 08:03:08 +01:00
|
|
|
} else if (type.includes('findify')) {
|
|
|
|
version = '6.9.15';
|
2020-03-28 18:56:07 +01:00
|
|
|
} else if (type.includes('/flv.js/')) {
|
|
|
|
version = '1.5.0';
|
2020-03-25 12:11:53 +01:00
|
|
|
} else if (type.includes('/fontawesome/3.')) {
|
|
|
|
version = '3.2.1';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/fontawesome/4.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '4.7.0';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/fontawesome/5.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '5.7.2';
|
2020-03-28 19:00:46 +01:00
|
|
|
} else if (type.includes('/hls.js/')) {
|
|
|
|
version = '0.13.2';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/jquery/1.')) {
|
2020-03-20 08:14:31 +01:00
|
|
|
version = ( helpers.compareVersion('1.8.3', requestVersion )) ? '1.8.3' : '1.12.4';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/jquery/2.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '2.2.4';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/jquery/3.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '3.4.1';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/jqueryui/1.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '1.11.4';
|
2020-03-26 10:57:32 +01:00
|
|
|
} else if (type.includes('/jquery.blockUI/2.')) {
|
|
|
|
version = '2.70';
|
2020-03-26 07:41:01 +01:00
|
|
|
} else if (type.includes('/jquery-validate/1.')) {
|
|
|
|
version = '1.19.1';
|
2020-03-26 08:08:26 +01:00
|
|
|
} else if (type.includes('/jquery-jeditable/1.')) {
|
|
|
|
version = '1.8.0';
|
2020-03-26 09:41:51 +01:00
|
|
|
} else if (type.includes('/js-cookie/2.')) {
|
|
|
|
version = '2.2.1';
|
2020-03-26 08:08:26 +01:00
|
|
|
} else if (type.includes('/lazysizes/4.')) {
|
2020-03-26 07:33:27 +01:00
|
|
|
version = '4.1.8';
|
2020-03-24 07:48:45 +01:00
|
|
|
} else if (type.includes('lozad')) {
|
|
|
|
version = '1.14.0';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/modernizr/2.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '2.8.3';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/moment.js/2.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '2.24.0';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/mootools/1.')) {
|
2020-03-17 07:37:28 +01:00
|
|
|
version = '1.6.0';
|
2020-03-26 09:41:14 +01:00
|
|
|
} else if (type.includes('p2p-media-loader-core')) {
|
|
|
|
version = '0.6.2';
|
2020-03-24 08:45:14 +01:00
|
|
|
} else if (type.includes('/page.js/1.')) {
|
|
|
|
version = '1.7.1';
|
2020-03-26 11:18:10 +01:00
|
|
|
} else if (type.includes('/plyr/3.')) {
|
|
|
|
version = '3.5.10';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/prototype/1.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '1.7.3.0';
|
2020-03-26 08:08:26 +01:00
|
|
|
} else if (type.includes('/rickshaw/1.')) {
|
2020-03-26 07:48:48 +01:00
|
|
|
version = '1.6.6';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/scriptaculous/1.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '1.9.0';
|
2020-03-26 10:57:11 +01:00
|
|
|
} else if (type.includes('/spin.js/2.')) {
|
|
|
|
version = '2.3.2';
|
2020-03-27 09:00:14 +01:00
|
|
|
} else if (type.includes('/store.js/2.')) {
|
|
|
|
version = '2.0.4';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/swfobject/2.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '2.2';
|
2020-03-26 07:23:43 +01:00
|
|
|
} else if (type.includes('/twitter-bootstrap/3.')) {
|
|
|
|
version = '3.4.1';
|
2020-03-26 07:24:37 +01:00
|
|
|
} else if (type.includes('/toastr.js/2.')) {
|
|
|
|
version = '2.1.4';
|
2020-03-17 06:27:45 +01:00
|
|
|
} else if (type.includes('/underscore.js/1.')) {
|
2020-03-16 14:50:13 +01:00
|
|
|
version = '1.9.1';
|
2020-03-24 08:45:14 +01:00
|
|
|
} else if (type.includes('/vue/1.')) {
|
|
|
|
version = '1.0.28';
|
2020-03-27 17:10:29 +01:00
|
|
|
} else if (type.includes('/vue/2.')) {
|
|
|
|
version = '2.6.11';
|
2020-03-24 10:02:12 +01:00
|
|
|
} else if (type.includes('webfont')) {
|
2020-03-17 07:43:51 +01:00
|
|
|
version = '1.6.28';
|
2020-03-26 10:38:02 +01:00
|
|
|
} else if (type.includes('/webrtc-adapter/6.')) {
|
|
|
|
version = '6.4.8';
|
2020-03-26 07:25:20 +01:00
|
|
|
} else if (type.includes('/wow/1.')) {
|
|
|
|
version = '1.1.2';
|
2020-03-16 14:50:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return version;
|
|
|
|
};
|
2020-03-20 08:14:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
helpers.compareVersion = function (v1, v2) {
|
|
|
|
/**
|
|
|
|
* compareVersion( '1.5.7' , '1.5.8' ) is TRUE
|
|
|
|
* compareVersion( '1.5.8' , '1.5.7' ) is FALSE
|
|
|
|
* compareVersion( '1.5.7' , '1.5.7' ) is TRUE
|
|
|
|
*/
|
|
|
|
v1 = v1.split('.');
|
|
|
|
v2 = v2.split('.');
|
|
|
|
const k = Math.min(v1.length, v2.length);
|
|
|
|
for (let i = 0; i < k; ++ i) {
|
|
|
|
v1[i] = parseInt(v1[i], 10);
|
|
|
|
v2[i] = parseInt(v2[i], 10);
|
|
|
|
if (v1[i] > v2[i]) return true;
|
|
|
|
if (v1[i] < v2[i]) return false;
|
|
|
|
}
|
|
|
|
return v1.length == v2.length ? true: (v1.length < v2.length ? false : true);
|
|
|
|
}
|