-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
270 lines (235 loc) · 10.2 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-VEVHWBPKXD"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-VEVHWBPKXD");
</script>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover"
/>
<!-- Socials -->
<meta name="title" content="mGira" />
<meta name="og:title" content="mGira" />
<meta name="image" content="https://app.mgira.pt/assets/images/mGira_social.png" />
<meta name="og:image" content="https://app.mgira.pt/assets/images/mGira_social.png" />
<meta name="og:url" content="https://app.mgira.pt" />
<meta
name="description"
content="Uma melhor aplicação para o sistema de bicicletas partilhadas GIRA. Experimenta já!"
/>
<meta
property="og:description"
content="Uma melhor aplicação para o sistema de bicicletas partilhadas GIRA. Experimenta já!"
/>
<meta name="author" content="afonsosousah" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="pt_PT" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="#ffffff" />
<title>mGira</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ol.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" />
<link rel="stylesheet" href="assets/style.css?v=0.1.0" />
<!-- iOS icons -->
<link rel="apple-touch-icon" sizes="40x40" href="assets/icons/ios/40.png" />
<link rel="apple-touch-icon" sizes="58x58" href="assets/icons/ios/58.png" />
<link rel="apple-touch-icon" sizes="60x60" href="assets/icons/ios/60.png" />
<link rel="apple-touch-icon" sizes="76x76" href="assets/icons/ios/76.png" />
<link rel="apple-touch-icon" sizes="80x80" href="assets/icons/ios/80.png" />
<link rel="apple-touch-icon" sizes="87x87" href="assets/icons/ios/87.png" />
<link rel="apple-touch-icon" sizes="114x114" href="assets/icons/ios/114.png" />
<link rel="apple-touch-icon" sizes="120x120" href="assets/icons/ios/120.png" />
<link rel="apple-touch-icon" sizes="128x128" href="assets/icons/ios/128.png" />
<link rel="apple-touch-icon" sizes="136x136" href="assets/icons/ios/136.png" />
<link rel="apple-touch-icon" sizes="152x152" href="assets/icons/ios/152.png" />
<link rel="apple-touch-icon" sizes="167x167" href="assets/icons/ios/167.png" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/icons/ios/180.png" />
<link rel="apple-touch-icon" sizes="192×192" href="assets/icons/ios/192.png" />
<link rel="apple-touch-icon" sizes="1024×1024" href="assets/icons/ios/1024.png" />
<!-- JS imports -->
<script src="scripts/bikeSerialNumberMapping.js?v=0.1.0"></script>
<script src="scripts/tokenRefresh.js?v=0.1.0"></script>
<script src="scripts/requests.js?v=0.1.0"></script>
<script src="scripts/user.js?v=0.1.0"></script>
<script src="scripts/bikes.js?v=0.1.0"></script>
<script src="scripts/stations.js?v=0.1.0"></script>
<script src="scripts/map.js?v=0.1.0"></script>
<script src="scripts/routing.js?v=0.1.0"></script>
<script src="scripts/navigation.js?v=0.1.0"></script>
<script src="scripts/dialogs.js?v=0.1.0"></script>
<script src="scripts/extras.js?v=0.1.0"></script>
<script src="scripts/swipe.js?v=0.1.0"></script>
<script src="scripts/version.js?v=0.1.0"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
<script type="module" src="https://unpkg.com/[email protected]/dist/ors-js-client.js"></script>
<script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js "></script>
</head>
<body onload="initMap();">
<!-- Map -->
<div id="map"></div>
<div id="mapOverlay"></div>
<!-- Zoom controls -->
<div id="zoomControls">
<div id="zoomPlusButton" onclick="zoomIn()">
<i class="bi bi-plus"></i>
</div>
<div id="zoomMinusButton" onclick="zoomOut()">
<i class="bi bi-dash"></i>
</div>
<div id="getLocationButton" onclick="getLocation()">
<i class="bi bi-crosshair"></i>
</div>
</div>
<!-- Logo -->
<img id="logo" src="assets/images/mGira_big.png" alt="big logo" />
<!-- Navigation button -->
<div id="navigationButton" onclick="showSearchBar()">
<i class="bi bi-sign-turn-right"></i>
</div>
<!-- User picture -->
<div id="userPicture" onclick="openUserSettings()">
<div id="userInitials"></div>
</div>
<!-- Dev info -->
<div id="devInfo">
<div id="posAngles"></div>
<div id="headingSource"></div>
<div id="heading"></div>
<div id="headingOffset"></div>
<div id="distanceBetweenUpdates"></div>
<div id="speedMS"></div>
</div>
<!-- Scripts -->
<script>
// Register the web app service worker
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("scripts/serviceworker.js");
}
// Check if location permission is given
navigator.permissions.query({ name: "geolocation" }).then(result => {
if (result.state === "granted") {
// Don't do anything
} else if (result.state === "prompt") {
console.log("Location permission will be prompted");
} else {
alert("Location permission was denied");
}
});
// Request persistent storage for site
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then(isPersisted => console.log(`Persisted storage granted: ${isPersisted}`));
}
// Import eruda on eruda flag set to true
if (/eruda=true/.test(window.location)) {
document.write("<scr" + 'ipt src="//cdn.jsdelivr.net/npm/eruda"></scr' + "ipt>");
document.write("<scr" + "ipt>eruda.init();</scr" + "ipt>");
//const erudaBtn = document.querySelector(".eruda-entry-btn");
//console.log(erudaBtn);
//erudaBtn?.style.top = "2vh";
}
// Check if the user has set customProxy. if not, use default proxy
const tempCustomProxy = getCookie("customProxy");
if (tempCustomProxy) {
console.log("Using custom proxy");
proxyURL = decodeURI(tempCustomProxy);
} else {
console.log("Using default proxy");
proxyURL = null;
}
// Check if user has custom minimum distance to station
const minimumDistanceToStationCookie = getCookie("minimumDistanceToStation");
if (minimumDistanceToStationCookie) {
console.log("Using user defined minimum distance to station");
minimumDistanceToStation = Number(minimumDistanceToStationCookie); // convert to int
} else {
console.log("Using default minimum distance to station");
minimumDistanceToStation = 50;
}
// Prevent resize on keyboard open
let initialWindowHeight = window.innerHeight;
document.addEventListener("focusin", e => {
if (isInputElement(e.target) && (!document.body.style.height.includes("px") || !document.body.style.height)) {
document.body.style.height = initialWindowHeight + "px";
window.scrollTo(0, document.body.scrollHeight); // scroll to the bottom of the page
}
});
document.addEventListener("focusout", e => {
if (isInputElement(e.target)) {
document.body.style.height = "100%";
}
});
function isInputElement(ele) {
return (ele && ele.tagName === "INPUT") || ele.tagName === "TEXTAREA" || ele.getAttribute("contenteditable")
? ele.getAttribute("contenteditable")?.toString() === "true"
: false;
}
// define a custom alert box
if (document.getElementById) {
window.alert = (message, title = `<i class="bi bi-exclamation-triangle"></i>`) => {
// set timeout so that if the user clicks on the place where the button is, it doesn't get automatically clicked
setTimeout(() => createCustomAlert(message, title), 50);
};
}
// Prevent system back button exiting the app
window.addEventListener("load", () => window.history.pushState({}, ""));
// Handle system back button
window.addEventListener("popstate", () => {
// Back button was pressed
window.history.pushState({}, "");
// Get elements
let stationMenu = document.getElementById("stationMenu");
let bikeListMenu = document.getElementById("bikeMenu");
let tripHistoryMenu = document.getElementById("tripHistory");
let statisticsMenu = document.getElementById("statisticsMenu");
// Hide search place menu if it is showing
hidePlaceSearchMenu();
// Hide user menu
if (!tripHistoryMenu && !statisticsMenu) hideUserSettings();
// Hide trip history menu
if (tripHistoryMenu) hideTripHistory();
// Hide statistics menu
if (statisticsMenu) hideStatisticsMenu();
// Hide bike list menu if it is showing
if (bikeListMenu) {
bikeListMenu.classList.add("smooth-slide-to-bottom");
setTimeout(() => bikeListMenu.remove(), 500); // remove element after animation
return; // prevent station card from being hidden if there was a bike list menu
}
// Hide station card if it is showing
if (stationMenu) {
stationMenu.classList.add("smooth-slide-to-left");
setTimeout(() => hideStationMenu(), 500); // remove element after animation
document.getElementById("zoomControls").classList.add("smooth-slide-down-zoom-controls"); // move zoom controls back down
}
});
// Hide station card if the user clicks/taps on the map
document.getElementById("map").addEventListener("click", () => {
// Hide station card if it is showing
let menu = document.getElementById("stationMenu");
let name = document.getElementById("stationName"); // use this to check if the card is loaded or we are opening a new one
if (menu && name) {
hideStationMenu();
}
});
// Show dev info on click on logo
document.getElementById("logo").addEventListener("click", () => {
const devInfo = document.getElementById("devInfo");
if (devInfo.style.display && devInfo.style.display !== "none") devInfo.style.display = "none";
else devInfo.style.display = "flex";
});
</script>
</body>
</html>