-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
132 lines (109 loc) · 3.48 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Location Form</title>
<!-- Import Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Import Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet">
<!-- Custom CSS -->
<style>
body {
font-family: 'Roboto', sans-serif;
font-weight: 300;
}
.container-center {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
}
.btn-container {
display: flex;
flex-direction: column;
}
.btn {
min-width: 88px;
font-weight: 400;
text-transform: uppercase;
letter-spacing: inherit;
}
.btn-primary {
background-color: #5677fc;
}
.btn-primary:hover {
background-color: #4e6cef;
}
.btn-custom {
color: #777;
text-decoration: none;
}
.btn-custom:hover,
.btn-custom:focus {
color: #555;
}
</style>
</head>
<body>
<div class="container-center">
<h4 id="note">You're going to a form that requests your current location.</h4>
<br>
<div class="btn-container">
<button type="button" class="btn btn-primary" onclick="getLocation()">Auto Detect My Location</button>
<button type="button" class="btn btn-link btn-custom" onclick="skip()">I'll Put It Manually</button>
</div>
</div>
<!-- Import Bootstrap JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<!-- Custom Functions -->
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const note = urlParams.get('note');
window.onload = function() {
if (note !== null) {
document.getElementById("note").innerText = decodeURIComponent(note);
}
}
const formId = urlParams.get('formId');
const gpsEntry = urlParams.get('gpsEntry');
const formType = urlParams.get('formType');
let unfilledForm, prefilledForm;
if (formType === 'google') {
unfilledForm = "https://docs.google.com/forms/d/e/" + formId + "/viewform";
} else if (formType === 'tally') {
unfilledForm = "https://tally.so/r/" + formId;
} else {
console.error('Invalid form type. Please provide a valid formType query parameter (either "google" or "tally").');
}
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getPosition);
} else {
skip();
}
}
function getPosition(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var gmap = "https://google.com/maps?q="+ lat +","+ lon;
if (formType === 'google') {
prefilledForm = unfilledForm + "?entry." + gpsEntry + "=" + encodeURIComponent(gmap);
} else if (formType === 'tally') {
prefilledForm = unfilledForm + "?" + gpsEntry + "=" + encodeURIComponent(gmap);
} else {
console.error('Invalid form type. Please provide a valid formType query parameter (either "google" or "tally").');
}
location.href = prefilledForm;
}
function skip(){
location.href = unfilledForm;
}
</script>
</body>
</html>