reset upload status when starting upload; load track in reverse order and once we...
[lantea.git] / js / ui.js
index 560f48c9d8f0f461ac620f0b53cc79a23263ae8e..f0d2b189b0d97773caed08ecc7d61b741420600b 100644 (file)
--- a/js/ui.js
+++ b/js/ui.js
@@ -307,11 +307,19 @@ function saveTrackDump() {
 }
 
 function uploadTrack() {
+  // Hide all areas in the dialog.
   var dia = document.getElementById("dialogArea");
   var areas = dia.children;
   for (var i = 0; i <= areas.length - 1; i++) {
     areas[i].style.display = "none";
   }
+  // Reset all the fields in the status area.
+  document.getElementById("uploadStatusCloseButton").disabled = true;
+  document.getElementById("uploadInProgress").style.display = "block";
+  document.getElementById("uploadSuccess").style.display = "none";
+  document.getElementById("uploadErrorMsg").textContent = "";
+  document.getElementById("uploadError").style.display = "none";
+  // Now show the status area.
   document.getElementById("uploadStatus").style.display = "block";
 
   // See http://wiki.openstreetmap.org/wiki/Api06#Uploading_traces
@@ -445,6 +453,24 @@ var gTrackStore = {
     }
   },
 
+  getListStepped: function(aCallback) {
+    if (!mainDB)
+      return;
+    var transaction = mainDB.transaction([this.objStore]);
+    var objStore = transaction.objectStore(this.objStore);
+    // Use cursor in reverse direction (so we get the most recent position first)
+    objStore.openCursor(null, "prev").onsuccess = function(event) {
+      var cursor = event.target.result;
+      if (cursor) {
+        aCallback(cursor.value);
+        cursor.continue();
+      }
+      else {
+        aCallback(null);
+      }
+    };
+  },
+
   push: function(aValue, aCallback) {
     if (!mainDB)
       return;