-
Notifications
You must be signed in to change notification settings - Fork 7
/
list-by-day.html
200 lines (171 loc) · 4.32 KB
/
list-by-day.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html> <head>
<title>Try Contra Dancing</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="simple.css">
</head>
<style>
#content-inner {
margin-top: 100px;
background-color: white;
}
.day {
padding-top: 18px;
font-size: 32px;
font-family: sans-serif;
height: 75px;
color: white;
background: #444;
}
.dance {
padding-left: 40px;
width: 100%;
font-size: 20px;
padding: 3px;
overflow: scroll;
}
.dance:nth-child(odd) {
background-color: #DDD;
}
.dance-internal {
margin: 10px;
}
.dances {
padding-bottom: 5px;
}
</style>
<body>
<div id="wrap">
<div id="content">
<div id="content-inner">
<div id="title">
<center>Days</center>
</div>
<div class="day">
<center>Sunday</center>
</div>
<div class=dances id="sunday">
</div>
<div class="day">
<center>Monday</center>
</div>
<div class=dances id="monday">
</div>
<div class="day">
<center>Tuesday</center>
</div>
<div class=dances id="tuesday">
</div>
<div class="day">
<center>Wedsnesday</center>
</div>
<div class=dances id="wednesday">
</div>
<div class="day">
<center>Thursday</center>
</div>
<div class=dances id="thursday">
</div>
<div class="day">
<center>Friday</center>
</div>
<div class=dances id="friday">
</div>
<div class="day">
<center>Saturday</center>
</div>
<div class=dances id="saturday">
</div>
</div>
</div>
</div>
<a id=back href="about.html">
<div id="footer">
<center>back</center>
</div>
</a>
<script>
var sunday = document.getElementById("sunday");
var monday = document.getElementById("monday");
var tuesday = document.getElementById("tuesday");
var wednesday = document.getElementById("wednesday");
var thursday = document.getElementById("thursday");
var friday = document.getElementById("friday");
var saturday = document.getElementById("saturday");
document.body.onload = function() {
fetch("dances_locs.json", function(response) {
load_dances(JSON.parse(response));
});
};
function fetch(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState==4 && xhr.status==200) {
callback(xhr.responseText);
}
};
xhr.open("GET",url,true);
xhr.send();
}
function build_div(location, link, schedule) {
var div = document.createElement("div");
div.className = "dance";
div.innerHTML = '<div class="dance-internal">'
+ location + ', ' + schedule + '<br>'
+ '<a href="' + link + '">' + link + '</a></div>';
return div;
}
function add_dance(location, link, schedule, distance) {
if (schedule.indexOf("Sunday") != -1) {
sunday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Monday") != -1) {
monday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Tuesday") != -1) {
tuesday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Wednesday") != -1) {
wednesday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Thursday") != -1) {
thursday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Friday") != -1) {
friday.appendChild(build_div(location, link, schedule));
}
if (schedule.indexOf("Saturday") != -1) {
saturday.appendChild(build_div(location, link, schedule));
}
}
function load_dances(dance_locations) {
dance_locations.sort(function(a, b) {
var loc_a = a[1];
var loc_b = b[1];
var state_a = loc_a.split(" ")[loc_a.split(" ").length-1];
var state_b = loc_b.split(" ")[loc_b.split(" ").length-1];
var c_a = [state_a, loc_a, a];
var c_b = [state_b, loc_b, b];
if (c_a < c_b) {
return -1;
} else if (c_a == c_b) {
return 0;
} else {
return 1;
}
});
for (var i = 0 ; i < dance_locations.length ; i++) {
add_dance(dance_locations[i][1],
dance_locations[i][0],
dance_locations[i][2],
"");
}
}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45031405-1', 'trycontra.com');
ga('send', 'pageview');
</script>
</body> </html>