-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (30 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { DataFetch } from "./fetch.js";
import { carouselFetch } from "./config.js";
import { SliderTemplate } from "./template/slider.js";
import { CardMenuTemplate } from "./template/cardMenu.js";
import { initCarouselCardSlider } from "./carousel/main.js";
import { initSearch } from "./search/main.js";
import { _$ } from "./util.js";
export function init() {
const carouselService = new DataFetch(carouselFetch);
carouselService
.fetchData()
.then(carouselData => initTemplate(carouselData))
.then(() => startAmazonService())
.catch(err => console.error(err));
}
function initTemplate(carouselData) {
const CAROUSEL_AREA = "#carousel";
const dataArea = _$(CAROUSEL_AREA);
const cardMenuData = new CardMenuTemplate(carouselData.menuData);
const sliderData = new SliderTemplate(carouselData.contentData);
let data = "";
data += cardMenuData.render();
data += sliderData.render();
dataArea.innerHTML = data;
}
function startAmazonService() {
initCarouselCardSlider();
initSearch();
}
window.addEventListener("DOMContentLoaded", init);