update 4page
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Loads home-hero-carousel.section.html into #home-hero-carousel-module
|
||||
*/
|
||||
(function () {
|
||||
var MODULE_URL = '/pages/modules/home-hero-carousel.section.html';
|
||||
|
||||
function loadHomeHeroCarouselModule() {
|
||||
var container = document.getElementById('home-hero-carousel-module');
|
||||
if (!container) return;
|
||||
|
||||
fetch(MODULE_URL, { credentials: 'same-origin' })
|
||||
.then(function (res) {
|
||||
if (!res.ok) throw new Error('Failed to load ' + MODULE_URL);
|
||||
return res.text();
|
||||
})
|
||||
.then(function (html) {
|
||||
container.innerHTML = html;
|
||||
var ensureScript = function () {
|
||||
if (window.AifoHomeHeroCarouselInit) {
|
||||
var root = container.querySelector('[data-home-hero-carousel]');
|
||||
if (root) window.AifoHomeHeroCarouselInit(root);
|
||||
return;
|
||||
}
|
||||
var script = document.createElement('script');
|
||||
script.src = '/js/home-hero-carousel.js';
|
||||
script.onload = function () {
|
||||
var root = container.querySelector('[data-home-hero-carousel]');
|
||||
if (root && window.AifoHomeHeroCarouselInit) {
|
||||
window.AifoHomeHeroCarouselInit(root);
|
||||
}
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
};
|
||||
ensureScript();
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error('[home-hero-carousel-module.js]', err);
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', loadHomeHeroCarouselModule);
|
||||
} else {
|
||||
loadHomeHeroCarouselModule();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user