Initial commit
This commit is contained in:
50
themes/keepit/node_modules/algoliasearch/src/browser/migration-layer/load-v2.js
generated
vendored
Normal file
50
themes/keepit/node_modules/algoliasearch/src/browser/migration-layer/load-v2.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = loadV2;
|
||||
|
||||
function loadV2(buildName) {
|
||||
var loadScript = require('load-script');
|
||||
var v2ScriptUrl = '//cdn.jsdelivr.net/algoliasearch/2/' + buildName + '.min.js';
|
||||
|
||||
var message = '-- AlgoliaSearch `latest` warning --\n' +
|
||||
'Warning, you are using the `latest` version string from jsDelivr to load the AlgoliaSearch library.\n' +
|
||||
'Using `latest` is no more recommended, you should load //cdn.jsdelivr.net/algoliasearch/2/algoliasearch.min.js\n\n' +
|
||||
'Also, we updated the AlgoliaSearch JavaScript client to V3. If you want to upgrade,\n' +
|
||||
'please read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n' +
|
||||
'-- /AlgoliaSearch `latest` warning --';
|
||||
|
||||
if (window.console) {
|
||||
if (window.console.warn) {
|
||||
window.console.warn(message);
|
||||
} else if (window.console.log) {
|
||||
window.console.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
// If current script loaded asynchronously,
|
||||
// it will load the script with DOMElement
|
||||
// otherwise, it will load the script with document.write
|
||||
try {
|
||||
// why \x3c? http://stackoverflow.com/a/236106/147079
|
||||
document.write('\x3Cscript>window.ALGOLIA_SUPPORTS_DOCWRITE = true\x3C/script>');
|
||||
|
||||
if (window.ALGOLIA_SUPPORTS_DOCWRITE === true) {
|
||||
document.write('\x3Cscript src="' + v2ScriptUrl + '">\x3C/script>');
|
||||
scriptLoaded('document.write')();
|
||||
} else {
|
||||
loadScript(v2ScriptUrl, scriptLoaded('DOMElement'));
|
||||
}
|
||||
} catch (e) {
|
||||
loadScript(v2ScriptUrl, scriptLoaded('DOMElement'));
|
||||
}
|
||||
}
|
||||
|
||||
function scriptLoaded(method) {
|
||||
return function log() {
|
||||
var message = 'AlgoliaSearch: loaded V2 script using ' + method;
|
||||
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user