75 lines
1.9 KiB
JavaScript
75 lines
1.9 KiB
JavaScript
|
/* eslint-disable no-undef */
|
||
|
function httpGet(theUrl) {
|
||
|
var xmlHttp = new XMLHttpRequest();
|
||
|
xmlHttp.open("GET", theUrl, false); // false for synchronous request
|
||
|
try {
|
||
|
xmlHttp.send(null);
|
||
|
} catch (error) {
|
||
|
try {
|
||
|
if (!retryConnection) {
|
||
|
toggleModal("popup-modal-no-conn", true);
|
||
|
}
|
||
|
|
||
|
retryConnection = true;
|
||
|
} catch (error) {
|
||
|
error;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return xmlHttp.responseText;
|
||
|
}
|
||
|
|
||
|
function home() {
|
||
|
if (navigator.geolocation) {
|
||
|
setTimeout(function () {
|
||
|
navigator.geolocation.getCurrentPosition(showPosition);
|
||
|
}, 200);
|
||
|
} else {
|
||
|
console.warn("Geolocation of user could not be fetched");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function on() {
|
||
|
document.getElementById("overlay").style.display = "block";
|
||
|
}
|
||
|
|
||
|
function off() {
|
||
|
document.getElementById("overlay").style.display = "none";
|
||
|
}
|
||
|
|
||
|
function makeToastNotification(title, message) {
|
||
|
document.getElementById("notificationToast").style.display = "block";
|
||
|
document.getElementById("toast_title").innerHTML = title;
|
||
|
document.getElementById("toast_desc").innerHTML = message;
|
||
|
try {
|
||
|
setTimeout(function () {
|
||
|
document
|
||
|
.getElementById("notificationToast")
|
||
|
.classList.remove("animate-right");
|
||
|
document
|
||
|
.getElementById("notificationToast")
|
||
|
.classList.add("animate-right-back");
|
||
|
setTimeout(function () {
|
||
|
document.getElementById("notificationToast").style.display = "none";
|
||
|
setTimeout(function () {
|
||
|
document
|
||
|
.getElementById("notificationToast")
|
||
|
.classList.add("animate-right");
|
||
|
document
|
||
|
.getElementById("notificationToast")
|
||
|
.classList.remove("animate-right-back");
|
||
|
}, 50);
|
||
|
}, 500);
|
||
|
}, 2000);
|
||
|
} catch (error) {
|
||
|
console.warn(
|
||
|
"Failed to show toast notification with title: `" +
|
||
|
title +
|
||
|
"` and message: `" +
|
||
|
message +
|
||
|
"`"
|
||
|
);
|
||
|
alert(title + " \n" + message);
|
||
|
}
|
||
|
}
|