-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
178 lines (177 loc) · 6.26 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Rob Ashton, leaflet demo</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
<link rel="manifest" href="favicon/site.webmanifest">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
crossorigin=""></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<script src="scripts/rainbowvis.js"></script>
<script src="scripts/Tooltip.js"></script>
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
<script src="scripts/model.js"></script>
</head>
<body>
<content>
<header>
Naomi Leaflet Demo
</header>
<section>
<nav>
<form id="filtersForm" autocomplete="off">
Age group:
<p>
<input id="15-49" type="radio" name="ageGroup" value="15-49" checked/>
<label for="15-49">15-49</label>
</p>
<p>
<input id="0-14" type="radio" name="ageGroup" value="0-14"/>
<label for="0-14">0-14</label>
</p>
<p>
<input id="15-24" type="radio" name="ageGroup" value="15-24"/>
<label for="15-24">15-24</label>
</p>
<p>
<input id="15-64" type="radio" name="ageGroup" value="15-64"/>
<label for="15-64">15-64</label>
</p>
<p>
<input id="15+" type="radio" name="ageGroup" value="15+"/>
<label for="15+">15+</label>
</p>
<p>
<input id="50+" type="radio" name="ageGroup" value="50+"/>
<label for="50+">50+</label>
</p>
Sex:
<p>
<input id="both" type="radio" name="sex" value="both" checked/>
<label for="both">Both</label>
</p>
<p>
<input id="male" type="radio" name="sex" value="male"/>
<label for="male">Male</label>
</p>
<p>
<input id="female" type="radio" name="sex" value="female"/>
<label for="female">Female</label>
</p>
</form>
Region:
<div class="custom-select" style="width:200px;">
<select id="regionSelect">
<option value="All">All</option>
<option value="Northern">Northern</option>
<option value="Central">Central</option>
<option value="Southern">Southern</option>
</select>
</div>
Admin level:
<div class="custom-select" style="width:200px;">
<select id="adminLevelSelect">
<option value="0">0</option>
<option value="1">1</option>
<option value="2" selected="selected">2</option>
</select>
</div>
</nav>
<article>
<div id="map"></div>
</article>
</section>
</content>
<script src="scripts/main.js"></script>
<script>
var x, i, j, selElmnt, a, b, c;
/*look for any elements with the class "custom-select":*/
x = document.getElementsByClassName("custom-select");
for (i = 0; i < x.length; i++) {
selElmnt = x[i].getElementsByTagName("select")[0];
/*for each element, create a new DIV that will act as the selected item:*/
a = document.createElement("DIV");
a.setAttribute("class", "select-selected");
a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
x[i].appendChild(a);
/*for each element, create a new DIV that will contain the option list:*/
b = document.createElement("DIV");
b.setAttribute("class", "select-items select-hide");
for (j = 0; j < selElmnt.length; j++) {
/*for each option in the original select element,
create a new DIV that will act as an option item:*/
c = document.createElement("DIV");
c.innerHTML = selElmnt.options[j].innerHTML;
c.addEventListener("click", function(e) {
/*when an item is clicked, update the original select box,
and the selected item:*/
var y, i, k, s, h;
s = this.parentNode.parentNode.getElementsByTagName("select")[0];
h = this.parentNode.previousSibling;
for (i = 0; i < s.length; i++) {
if (s.options[i].innerHTML == this.innerHTML) {
s.selectedIndex = i;
if (s.id == "regionSelect") {
$("#regionSelect").change();
} else if (s.id == "adminLevelSelect") {
$("#adminLevelSelect").change();
}
h.innerHTML = this.innerHTML;
y = this.parentNode.getElementsByClassName("same-as-selected");
for (k = 0; k < y.length; k++) {
y[k].removeAttribute("class");
}
this.setAttribute("class", "same-as-selected");
break;
}
}
h.click();
});
b.appendChild(c);
}
x[i].appendChild(b);
a.addEventListener("click", function(e) {
/*when the select box is clicked, close any other select boxes,
and open/close the current select box:*/
e.stopPropagation();
closeAllSelect(this);
this.nextSibling.classList.toggle("select-hide");
this.classList.toggle("select-arrow-active");
});
}
function closeAllSelect(elmnt) {
/*a function that will close all select boxes in the document,
except the current select box:*/
var x, y, i, arrNo = [];
x = document.getElementsByClassName("select-items");
y = document.getElementsByClassName("select-selected");
for (i = 0; i < y.length; i++) {
if (elmnt == y[i]) {
arrNo.push(i)
} else {
y[i].classList.remove("select-arrow-active");
}
}
for (i = 0; i < x.length; i++) {
if (arrNo.indexOf(i)) {
x[i].classList.add("select-hide");
}
}
}
/*if the user clicks anywhere outside the select box,
then close all select boxes:*/
document.addEventListener("click", closeAllSelect);
</script>
</body>
</html>