-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
58 lines (45 loc) · 1.62 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
function buildUseCase() {
const year = state.themeYear;
const mode = state.useCaseType;
const projectName = state.projectName;
switch (mode) {
case 'light':
return new ThemeUseCase(projectName, { year, mode }, `Light Hacktoberfest ${year} Theme`);
case 'dark':
return new ThemeUseCase(projectName, { year, mode }, `Dark Hacktoberfest ${year} Theme`);
case 'default':
default:
return new HacktoberfestUseCase(projectName, `Default Theme`);
}
}
function changeUseCase() {
state.useCase = buildUseCase();
state.useCase.display();
}
const inputProjectName = document.getElementById('project-name-input');
inputProjectName.oninput = function (event) {
state.projectName = event.target.value;
state.useCase.updateCellsLabel(state.projectName);
};
const selectThemeYear = document.getElementById('theme-year-select');
selectThemeYear.oninput = function (event) {
state.themeYear = event.target.value;
changeUseCase();
};
document.getElementById('choose-use-case-panel').onchange = () => {
state.useCaseType = document.querySelector("input[type='radio'][name='use-case-type']:checked").value;
changeUseCase();
}
// Initialize state
const state = {
projectName: inputProjectName.value,
useCaseType: 'dark',
themeYear: selectThemeYear.value,
useCase: undefined
}
// Update state of radio buttons
document.getElementById(`btn-${state.useCaseType}`).checked = true;
document.addEventListener('DOMContentLoaded', function () {
// Waiting for the displayed page before to load diagram & display data
changeUseCase();
})