-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulate.js
87 lines (82 loc) · 2.48 KB
/
populate.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function make_event(event, eventNo) {
/*
<button class="collapsible">
<p>event_name - level</p>
<p><em>start_time - end_time</em></p>
</button>
<div class="event">
<p>discription</p>
<\div>
*/
var events = document.getElementById("events");
var button = document.createElement("button");
button.setAttribute("class", "collapsible");
var nameField = document.createElement("p");
var names = document.createTextNode(event.name + " - " + event.ability);
nameField.appendChild(names);
var timeField = document.createElement("p");
var timeItal = document.createElement("em");
var time = document.createTextNode(event.start + " - " + event.end);
timeItal.appendChild(time);
timeField.appendChild(timeItal);
button.appendChild(nameField);
button.appendChild(timeField);
var info = document.createElement("div");
info.setAttribute("class", "event");
var textField = document.createElement("p");
var text = document.createTextNode(event.description);
textField.appendChild(text);
info.appendChild(textField);
events.appendChild(button);
events.appendChild(info);
if (eventNo == 0) {
button.style.margin = 0;
}
button.addEventListener("click", function() {
if (info.style.maxHeight){
info.style.maxHeight = null;
} else {
info.style.maxHeight = info.scrollHeight + "px";
}
});
}
function make_style(style) {
var events = document.getElementById("styles");
var button = document.createElement("button");
button.setAttribute("class", "style");
var styleName = document.createTextNode(style.name);
button.appendChild(styleName);
events.appendChild(button);
}
const events = [
{
"name": "Zouk Social",
"ability": "All",
"start": "7:00pm",
"end": "7:30pm",
"company": "Cloud 9 Zouk",
"description": "Come join us for a fun evening of social dancing! Open to those of all ages and abilities."
},
{
"name": "Salsa Class",
"ability": "Intermediate",
"start": "6:00pm",
"end": "7:00pm",
"company": "50/50",
"description": "Come try our exciting block of classes."
}
];
const styles = [
{
"name": "Zouk"
},
{
"name": "Salsa"
}
]
for (var i = 0; i < styles.length; i++) {
make_style(styles[i]);
}
for (var i = 0; i < events.length; i++) {
make_event(events[i], i);
}