-
Notifications
You must be signed in to change notification settings - Fork 7
/
list.html
138 lines (115 loc) · 2.99 KB
/
list.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
<!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>
.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;
}
#activity {
font-size: 200%;
}
input[type=checkbox] {
width: 2em;
height: 2em;
}
</style>
<body>
<div id="wrap">
<div id="content">
<div id="content-inner">
<div id="title">
<center>All Dances</center>
</div>
<div id=activity>
<input id=show_inactive type=checkbox> <label for=show_inactive>Show Inactive Dances</label>
</div>
<div id="dances">
</div>
</div>
</div>
</div>
<a id=back href="about.html"><div id="footer"><center>back</center></div></a>
<script>
var dances = document.getElementById("dances");
function reload() {
while (dances.firstChild) {
dances.removeChild(dances.firstChild);
}
fetch("dances_locs.json", function(response) {
load_dances(JSON.parse(response));
});
}
document.body.onload = reload;
show_inactive.onclick = reload;
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 add_dance(location, link, schedule, active) {
if (!active && !show_inactive.checked) return;
var div = document.createElement("div");
div.className = "dance";
var act = "";
if (show_inactive.checked) {
act = active ? "Active" : "<i>Likely Inactive</i>";
act += "<br>";
}
div.innerHTML = '<div class="dance-internal">'
+ location + ', ' + schedule + '<br>'
+ act
+ '<a href="' + link + '">' + link + '</a></div>';
dances.appendChild(div);
}
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],
dance_locations[i][7]);
}
}
(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>