-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
61 lines (43 loc) · 1.35 KB
/
main.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
61
import {Todo, TodoList} from './model.js'
import { Controller } from './controller.js'
import { TableView } from './tableView.js';
import { TileView } from './tileView.js';
var c = new Controller();
var td = new TodoList();
var todoTableView = new TableView();
var todoTileView = new TileView();
var currentView = "tableView";
function showView(view) {
const tableView = document.getElementById("tableViewContainer");
const tileView = document.getElementById("tileViewContainer");
if(view === "tableView") {
c.setView(todoTableView);
tableView.style.display = "block";
tileView.style.display = "none";
} else if (view === "tileView") {
c.setView(todoTileView);
tableView.style.display = "none";
tileView.style.display = "block";
} else {
console.error("Unknown view");
}
}
function changeView() {
if(currentView === "tableView") {
showView("tileView");
currentView = "tileView";
changeViewButton.innerText = "Show tileview";
} else {
showView("tableView");
currentView = "tableView";
changeViewButton.innerText = "Show tableview";
}
c.updateView();
}
const changeViewButton = document.getElementById("changeViewButton");
changeViewButton.onclick = () => changeView();
c.setModel(td);
todoTableView.setController(c);
todoTileView.setController(c);
showView("tableView");
todoTileView.update();