-
Notifications
You must be signed in to change notification settings - Fork 1
/
zoo_map.tmpl
251 lines (225 loc) · 6.2 KB
/
zoo_map.tmpl
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<html>
<head>
$HEADER$
<style>
@font-face {
font-family: RussoOne;
src: url("fonts/RussoOne-Regular.ttf");
font-display: swap;
}
@font-face {
font-family: Raleway;
src: url("fonts/Raleway-Regular.ttf");
font-display: swap;
}
#full_page_container {
display: grid;
row-gap: 10px;
background-color: black;
}
@media only screen and (min-width: 800px) {
/* Left side of screen 400px */
#full_page_container {
grid-template-columns: 400px auto;
grid-template-rows: 100px calc(100vh - 100px);
grid-template-areas:
"zoo_logo zoo_map"
"patrons zoo_map";
}
#zoo_logo img { width: 400px; }
#patron_list p { font-size: x-large; }
}
@media only screen and (max-width: 799px) {
#full_page_container {
grid-template-columns: 1fr;
grid-template-rows: 100px 200px calc(100vh - 300px);
grid-template-areas:
"zoo_logo"
"patrons"
"zoo_map";
}
#zoo_logo img {
width: 100%;
height: 100px;
margin: auto;
}
#patron_list p { font-size: large; }
}
#patron_list {
overflow: auto;
grid-area: patrons;
background: black;
}
#patron_list p {
text-align: center;
color: white;
font-family: Raleway;
}
@media only screen and (min-width: 800px) {
#patron_list p {
padding: 20px;
}
}
ul#patrons {
font-size: medium;
list-style-type: none;
width: fit-content;
}
ul#patrons li {
color: white;
margin: 5px 0;
border-left: 4px solid #062a42;
transition: 0.5s;
position: relative;
left: 0;
padding-left: 5px;
font-family: RussoOne;
}
ul#patrons li:hover, .patron.hover {
border-left: 4px solid #9f1c34;
background: #9f1c34;
cursor: pointer;
left: 10px;
color: white;
}
#zoo_map {
grid-area: zoo_map;
}
#zoo_logo {
grid-area: zoo_logo;
}
#zoo_logo img {
object-fit: contain;
background: black;
padding: 10px;
}
.leaflet-container {
background: #333;
}
.leaflet-tooltip-pane {
font-size: large;
}
/* This part changes the scrollbar track (the part behind the scrollbar) */
::-webkit-scrollbar-track {
background: #1E1E1E; /* Dark grey color, you can choose any color you like */
}
/* This part changes the scrollbar handle */
::-webkit-scrollbar-thumb {
background: #555; /* Medium grey color, this is the actual scrollbar */
}
/* You can also change the scrollbar width and height */
::-webkit-scrollbar {
width: 12px; /* Width of the vertical scrollbar */
height: 12px; /* Height of the horizontal scrollbar */
}
</style>
</head>
<body>
<div id = "full_page_container">
<div id = "patron_list">
<p>Thank you for all of our existing patrons</p>
<ul id="patrons">
</ul>
</div>
<div id = "zoo_map">
$BODY$
</div>
<div id = "zoo_logo">
<img src="images/NALZS_2B_Side_stack.png" alt="NALZS Logo">
</div>
</div>
</body>
<script>
$SCRIPT$
function addOutlineToRectangle(event){
const patronName = event.target.innerHTML;
for(const patron of patrons){
if(patron.name == patronName) {
highlightRectangle(patron.rectangle);
}
}
}
function highlightRectangle(rectangle){
removeAllOutlines();
rectangle.options.color = "#9f1c34";
rectangle.options.stroke = true;
rectangle.options.weight = 4;
rectangle.remove()
rectangle.addTo(mapObj);
}
function removeOutline(event) {
const patronName = event.target.innerHTML;
for(const patron of patrons){
if(patron.name == patronName) {
const rectangle = patron.rectangle;
removeOutlineFromRectangle(rectangle);
}
}
}
function removeOutlineFromRectangle(rectangle) {
rectangle.options.color = "";
rectangle.options.stroke = false;
rectangle.options.weight = 0;
rectangle.remove()
rectangle.addTo(mapObj);
}
function panAndZoom(event){
const patronName = event.target.innerHTML;
const patron = patrons.find((p) => p.name == patronName); // zoom to the first one
const rectangle = patron.rectangle;
mapObj.flyTo(rectangle.getCenter(), 3);
}
function onlyUnique(value, index, array) {
return array.map((p) => p.name).indexOf(value.name) === index;
}
function highlightName(name){
removeAllHighlights();
for(const patron of document.getElementsByClassName("patron")){
if(patron.innerHTML === name){
patron.classList.add("hover")
}
}
}
function goToPatron(name) {
highlightName(name);
for(const patron of document.getElementsByClassName("patron")) {
if(patron.innerHTML === name){
patronList = document.getElementById("patron_list");
patronList.scrollTo({top: patron.offsetTop - patronList.offsetTop - 20, behavior: "smooth"});
}
}
}
function unhighlightName(name){
for(const patron of document.getElementsByClassName("patron")){
if(patron.innerHTML === name){
patron.classList.remove("hover")
}
}
}
function removeAllOutlines(){
for(const patron of patrons.filter(onlyUnique)){
removeOutlineFromRectangle(patron.rectangle);
}
}
function removeAllHighlights(){
for(const patron of patrons) {
unhighlightName(patron.name);
}
}
for(const patron of patrons.filter(onlyUnique)){
const listItem = document.createElement("li");
listItem.innerHTML = patron.name;
listItem.classList.add("patron")
listItem.addEventListener("mouseover", addOutlineToRectangle);
listItem.addEventListener("touch", (e) => { highlightName(patron.name); highlightRectangle(patron.rectangle); panAndZoom(e); });
listItem.addEventListener("click", (e) => { highlightName(patron.name); highlightRectangle(patron.rectangle); panAndZoom(e); });
document.getElementById("patrons").appendChild(listItem)
}
for(const patron of patrons) {
patron.rectangle.addEventListener("mouseover", () => { highlightName(patron.name)});
patron.rectangle.addEventListener("touch", (e) => { highlightRectangle(patron.rectangle); highlightName(patron.name); goToPatron(patron.name); });
patron.rectangle.addEventListener("click", (e) => { highlightRectangle(patron.rectangle); highlightName(patron.name); goToPatron(patron.name); });
}
</script>
</html>