-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
197 lines (173 loc) · 6.33 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo Day Voting</title>
<style>
html, body {
font-family: -apple-system, BlinkMacSystemFont, system-ui, Arial, sans-serif;
text-align: center;
margin: 0px;
width: 100vw;
height: 100vh;
background-color: #0F0F0F;
color: white;
/* overflow: none; */
}
#loading {
font-size: 18px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#loading img {
width: 100%;
height: auto;
margin-bottom: -4vh;
}
h2, p {
opacity: .8;
}
h1,h2{
margin: 0;
}
p {
margin-bottom:1em;
margin-top:1EM;
}
#form-container {
margin-top: 20px;
width: 100%;
height: 100%;
}
iframe {
border: none;
width: 100%;
height: 100%;
animation-duration: 0.5s;
animation-name: animate-fade;
animation-delay: 0.5s;
animation-fill-mode: backwards;
}
button {
padding: 15px 15px 15px 15px;
margin: auto;
width: fit-content;
border-radius: 7px;
border: 1px solid #ffffff9f;
color:white;
background: linear-gradient(94.92deg, #477a9820 0.05%, #9b559e20 50.05%, #7d602320 100.05%);
box-shadow: -9px -8px 20px 10px rgba(118, 205, 255, 0.25), 9px 8px 20px 10px rgba(255, 197, 73, 0.25);
}
button:hover {
cursor: pointer;
}
@keyframes animate-fade {
0% { opacity: 0; }
100% { opacity: 1; }
}
.spinner {
width: 48px;
height: 48px;
border: 5px solid #FFF;
border-bottom-color: transparent;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media screen and (max-width: 700px) {
#loading {
width: 80%;
}
}
</style>
</head>
<body>
<div id="loading">
<img src="src/iOSGlow.png">
<h1>Audience Vote</h1>
<h2>Demo Day</h2>
<p>Please allow location access to verify you're in the audience</p>
<button id="share-location">Share Location</button>
</div>
<div id="form-container"></div>
<script>
// Define regions with latitude and longitude bounds
const regions = [
{
name: "Student Center",
bounds: {
latMin: 33.773635,
latMax: 33.774512,
lonMin: -84.399065,
lonMax: -84.397651
},
formUrl: "https://docs.google.com/forms/d/e/1FAIpQLSd1offPJb-FQNDcsva6ZVXbSVaHFle5Siw3pkO3DRng8cugCQ/viewform?embedded=true"
}
];
// Function to check if a point is within a region
function isWithinRegion(lat, lon, region) {
const { latMin, latMax, lonMin, lonMax } = region.bounds;
return lat >= latMin && lat <= latMax && lon >= lonMin && lon <= lonMax;
}
// function isWithinRegion(lat, lon, region) {
// const { latMin, latMax, lonMin, lonMax } = region.bounds;
// // Add a small tolerance to account for potential rounding errors
// const tolerance = 0.00001;
// return (
// lat >= latMin - tolerance &&
// lat <= latMax + tolerance &&
// lon >= lonMin - tolerance &&
// lon <= lonMax + tolerance
// );
// }
document.getElementById("share-location").addEventListener("click", locate);
// Detect user's location
function locate (e) {
const loadingText = document.getElementById("loading");
loadingText.innerHTML = "<span class='spinner'></span><p>Tap Allow in the popup</p>"
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords;
// Find the region that matches the user's location
const region = regions.find(r => isWithinRegion(latitude, longitude, r));
// Update the UI
const formContainer = document.getElementById("form-container");
loadingText.style.display = "none";
if (region) {
formContainer.innerHTML = `
<!--<p>We detected you're in <strong>${region.name}</strong>. Please fill out the form below:</p>-->
<iframe src="${region.formUrl}"></iframe>
`;
} else {
formContainer.innerHTML = `
<p>Sorry, you don't seem to be at Demo Day. Please reload the page from within the event venue.</p>
<p>Current Coordinates: ${latitude}, ${longitude}</p>
<button id="reload">Reload</button>
`;
}
}, (error) => {
document.getElementById("loading").innerHTML = '<p>Unable to detect your location. Please allow us to access your location then reload the page to unlock voting.</p> <button id="reload">Reload</button>';
console.error("Geolocation error:", error);
document.getElementById("reload").addEventListener("click", (e) => {
window.location.reload();
});
});
} else {
document.getElementById("loading").textContent = "Geolocation is not supported by your browser.";
}
}
</script>
</body>
</html>