-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.html
84 lines (75 loc) · 2.28 KB
/
demo.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<title>ColumnView Demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" src="dist/all.js"></script>
<script type="text/javascript" src="demo-data.js"></script>
<link rel="stylesheet" type="text/css" href="dist/column-view.css">
<link rel="stylesheet" type="text/css" href="demo.css">
</head>
<body>
<button id="backBtn">back</button>
<div id="column-view" class="column-view">
<style type="text/css"></style>
<div class="carriage"></div>
</div>
<script type="text/javascript">
function sourceEvent(value, cb) {
var event = data.events[value.slice(1)]
var div = document.createElement("div");
div.classList.add("event");
div.innerHTML = "<h2>"+event.name+"</h2>"+event.type+"<br />"+event.lecturer+"<br /><p>"+event.description+"</p>";
cb({dom: div});
}
function sourceNode(value, cb) {
var node = data.tree[value];
var childIDs = node[1];
if (childIDs.length == 0) {
sourceEmpty(value, cb);
return;
}
var children = childIDs.map(function(id) {
if (!node[2]) {
var n = data.tree[id];
var value = id;
return {name : n[0], value: value};
} else {
var n = data.events[id];
var value = "e" + id;
return {name : n.name, value: value};
}
})
cb({items: children});
}
function sourceEmpty(value, cb) {
var div = document.createElement("div");
div.innerHTML = "empty";
cb({dom: div});
}
function source(value, cb) {
// console.log("source", value);
var sourceFn = value[0] == 'e' ? sourceEvent : sourceNode;
sourceFn(value, cb);
};
var columnView = document.getElementById("column-view");
var backBtn = document.getElementById("backBtn");
backBtn.disabled = true;
var cv = new ColumnView(
columnView,
{
source: source,
path: [data.rootID, 7287, 7511, "e14331"],
onChange: function() {
backBtn.disabled = !this.canMoveBack();
},
layout: "no-mobile"
}
);
backBtn.addEventListener("click", function() {
cv.back();
})
</script>
</body>
</html>