+ var areas = document.getElementsByClassName("autoFade");
+ for (var i = 0; i <= areas.length - 1; i++) {
+ areas[i].addEventListener("mouseup", uiEvHandler, false);
+ areas[i].addEventListener("mousemove", uiEvHandler, false);
+ areas[i].addEventListener("mousedown", uiEvHandler, false);
+ areas[i].addEventListener("mouseout", uiEvHandler, false);
+
+ areas[i].addEventListener("touchstart", uiEvHandler, false);
+ areas[i].addEventListener("touchmove", uiEvHandler, false);
+ areas[i].addEventListener("touchend", uiEvHandler, false);
+ areas[i].addEventListener("touchcancel", uiEvHandler, false);
+ areas[i].addEventListener("touchleave", uiEvHandler, false);
+ }
+
+ document.getElementById("body").addEventListener("keydown", uiEvHandler, false);
+
+ if (navigator.platform.length == "") {
+ // For Firefox OS, don't display the "save" button.
+ // Do this by setting the debugHide class for testing in debug mode.
+ document.getElementById("saveTrackButton").classList.add("debugHide");
+ }
+
+ // Set backend URL in a way that it works for testing on localhost as well as
+ // both the lantea.kairo.at and lantea-dev.kairo.at deployments.
+ if (window.location.host == "localhost") {
+ gBackendURL = window.location.protocol + '//' + window.location.host + "/lantea-backend/";
+ }
+ else {
+ gBackendURL = window.location.protocol + '//' + "backend." + window.location.host + "/";
+ }
+ // Make sure to use a different login client ID for the -dev setup.
+ if (/\-dev\./.test(window.location.host)) {
+ gAuthClientID += "-dev";
+ }
+
+ document.getElementById("libCloseButton").onclick = hideLibrary;
+
+ // Set up the login area.
+ document.getElementById("loginbtn").onclick = startLogin;
+ document.getElementById("logoutbtn").onclick = doLogout;
+ prepareLoginButton(function() {
+ // Anything that needs the backend should only be triggered from in here.
+ // That makes sure that the first call the the backend is oauth_state and no other is running in parallel.
+ // If we call multiple backend methods at once and no session is open, we create multiple sessions, which calls for confusion later on.
+
+ // Call any UI preparation that needs the backend.
+ });
+
+ gAction.addEventListener("dbinit-done", initMap, false);
+ gAction.addEventListener("mapinit-done", postInit, false);
+ console.log("starting DB init...");