move track to its own canvas, make painting current position actually work, delay...
[lantea.git] / js / ui.js
index 9c97cd600891127443be8b07c66d8b686113cd42..e347b99842732bcf3b1540e8308228acf44fe4db 100644 (file)
--- a/js/ui.js
+++ b/js/ui.js
@@ -7,6 +7,7 @@ var iDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || w
 var mainDB;
 
 var gUIHideCountdown = 0;
 var mainDB;
 
 var gUIHideCountdown = 0;
+var gWaitCounter = 0;
 
 window.onload = function() {
   var mSel = document.getElementById("mapSelector");
 
 window.onload = function() {
   var mSel = document.getElementById("mapSelector");
@@ -39,7 +40,24 @@ window.onload = function() {
 
   initDB();
   initMap();
 
   initDB();
   initMap();
-  resizeAndDraw();
+
+  var loopCnt = 0;
+  var waitForInitAndDraw = function() {
+    if ((gWaitCounter <= 0) || (loopCnt > 100)) {
+      if (gWaitCounter <= 0)
+        gWaitCounter = 0;
+      else
+        document.getElementById("debug").textContent = "Loading prefs failed.";
+
+      gMapPrefsLoaded = true;
+      resizeAndDraw();
+      setTracking(document.getElementById("trackCheckbox"));
+    }
+    else
+      setTimeout(waitForInitAndDraw, 100);
+    loopCnt++;
+  };
+  waitForInitAndDraw();
 }
 
 window.onresize = function() {
 }
 
 window.onresize = function() {