From fdaf08dbc34cd93d2800100959ca1f2b0d75ea5d Mon Sep 17 00:00:00 2001
From: Robert Kaiser <robert@widebook.box.kairo.at>
Date: Sun, 18 Aug 2013 19:17:41 +0200
Subject: [PATCH] try to fix upload error, make initial draw faster

---
 js/map.js         | 9 ++++++---
 js/ui.js          | 2 +-
 manifest.appcache | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/js/map.js b/js/map.js
index dc3ad9c..5e65ed6 100644
--- a/js/map.js
+++ b/js/map.js
@@ -162,14 +162,17 @@ function loadPrefs(aEvent) {
       gAction.dispatchEvent(throwEv);
     });
     gWaitCounter++;
-    var trackLoadStarted = false;
+    var trackLoadStarted = false; redrawBase = 100;
     gTrackStore.getListStepped(function(aTPoint) {
       if (aTPoint) {
         // Add in front and return new length.
         var tracklen = gTrack.unshift(aTPoint);
-        // Redraw track every 100 values (initial paint will do first anyhow).
-        if (tracklen % 100 == 0)
+        // Redraw track periodically, larger distance the longer it gets.
+        // Initial paint will do initial track drawing.
+        if (tracklen % redrawBase == 0) {
           drawTrack();
+          redrawBase = tracklen;
+        }
       }
       else {
         // Last point received.
diff --git a/js/ui.js b/js/ui.js
index 352f7e7..5d2c7b0 100644
--- a/js/ui.js
+++ b/js/ui.js
@@ -337,7 +337,7 @@ function uploadTrack() {
   // then ask for credentials, and then send again.
   var hXHR = new XMLHttpRequest();
   hXHR.onreadystatechange = function() {
-    if (hXHR.readyState == 4 && (XHR.status == 200 || hXHR.status == 400)) {
+    if (hXHR.readyState == 4 && (hXHR.status == 200 || hXHR.status == 400)) {
       // 400 is Bad Request, but that's expected as this was empty.
       // So far so good, init actual upload.
       var XHR = new XMLHttpRequest();
diff --git a/manifest.appcache b/manifest.appcache
index ef33d92..13f95d3 100644
--- a/manifest.appcache
+++ b/manifest.appcache
@@ -1,6 +1,6 @@
 CACHE MANIFEST
 
-# 2013-08-15
+# 2013-08-17
 manifest.webapp
 js/map.js
 js/ui.js
-- 
2.43.0