1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/scripts/apploader.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-11 19:53:11 +02:00
(function() {
function injectScriptElement(src, onload) {
if (!src) {
return;
}
2019-05-22 14:49:57 -04:00
2020-08-11 19:53:11 +02:00
const script = document.createElement('script');
2020-08-25 10:12:35 +09:00
if (window.dashboardVersion) {
src += `?v=${window.dashboardVersion}`;
2020-08-11 19:53:11 +02:00
}
script.src = src;
script.setAttribute('async', '');
2020-08-11 19:53:11 +02:00
if (onload) {
script.onload = onload;
}
2020-08-11 19:53:11 +02:00
document.head.appendChild(script);
}
2020-08-11 19:53:11 +02:00
function loadSite() {
injectScriptElement(
'./libraries/alameda.js',
function() {
// onload of require library
injectScriptElement('./scripts/site.js');
}
);
}
2020-08-11 19:53:11 +02:00
try {
Promise.resolve();
} catch (ex) {
// this checks for several cases actually, typical is
// Promise() being missing on some legacy browser, and a funky one
// is Promise() present but buggy on WebOS 2
window.Promise = undefined;
2020-08-25 10:12:35 +09:00
window.Promise = undefined;
2020-08-11 19:53:11 +02:00
}
2020-08-25 10:12:35 +09:00
if (!window.Promise) {
2020-08-11 19:53:11 +02:00
// Load Promise polyfill if they are not natively supported
injectScriptElement(
'./libraries/npo.js',
loadSite
);
} else {
loadSite();
}
})();