-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (51 loc) · 2.18 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Display from './components/Display/Display.js';
import SlideBar from './components/SlideBar/SlideBar.js';
import {default as STORE} from './components/Store/Store.js';
import sideBarReducer from './components/SlideBar/SlideBarReducer.js';
import {default as slideBarActionCreators} from './components/SlideBar/ActionCreators.js';
const slidebarDiv = document.getElementById('slidebar__div');
const displayDiv = document.getElementById('display__div');
// sample index.js code for selected example
// need to find a proper solution for rendering the dom element
function domCreator(component) {
const domParser = new DOMParser();
const doc = domParser.parseFromString(component.render(), 'text/html');
return doc.body.firstChild;
}
let display = new Display({ value: 0 });
console.log(display);
let displayElement = domCreator(display);
display.setRefs('display', displayElement);
displayDiv.appendChild(displayElement);
display.setSubscriber('dis1', display.listner);
display = new Display({ value: 0 });
console.log(display);
displayElement = domCreator(display);
display.setRefs('display', displayElement);
displayDiv.appendChild(displayElement);
display.setSubscriber('dis2', display.listner);
display = new Display({ value: 0 });
console.log(display);
displayElement = domCreator(display);
display.setRefs('display', displayElement);
displayDiv.appendChild(displayElement);
display.setSubscriber('dis3', display.listner);
display = new Display({ value: 0 });
console.log(display);
displayElement = domCreator(display);
display.setRefs('display', displayElement);
displayDiv.appendChild(displayElement);
display.setSubscriber('dis4', display.listner);
display = new Display({ value: 0 });
console.log(display);
displayElement = domCreator(display);
display.setRefs('display', displayElement);
displayDiv.appendChild(displayElement);
display.setSubscriber('dis5', display.listner);
const slidebar = new SlideBar({ min: 0, max: 100, value: 0});
const slideBaElement = domCreator(slidebar);
slidebar.setReducer('SlideBar', sideBarReducer);
slideBaElement.addEventListener('input', (event) => {
STORE.dispatch(slideBarActionCreators(event.target.value));
});
slidebarDiv.appendChild(slideBaElement);