Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

Files at this revision

API Documentation at this revision

Comitter:
andrewboyson
Date:
Sun Jan 17 17:48:09 2021 +0000
Parent:
148:3d685db9fdd3
Child:
150:f676c14793fc
Commit message:
Modified firmware page to give upload progress.

Changed in this revision

base/firmware/web-firmware-script.inc Show annotated file Show diff for this revision Revisions of this file
base/firmware/web-firmware-script.js Show annotated file Show diff for this revision Revisions of this file
--- a/base/firmware/web-firmware-script.inc	Sun Jan 17 12:45:56 2021 +0000
+++ b/base/firmware/web-firmware-script.inc	Sun Jan 17 17:48:09 2021 +0000
@@ -22,19 +22,23 @@
 "{\n"
 "    logUpload('Upload error');\n"
 "}\n"
+"function xhrUploadProgress(e)\n"
+"{\n"
+"    logUpload('Uploading ' + e.total + ' bytes; ' + e.loaded + ' bytes so far...');\n"
+"}\n"
 "function xhrUploadStart()\n"
 "{\n"
-"    logUpload('Uploading...');\n"
+"    logUpload('Upload starting...');\n"
 "    \n"
 "    xhr = new XMLHttpRequest();\n"
 "\n"
 "    xhr.onload  = xhrUploadOnLoad;\n"
 "    xhr.onerror = xhrUploadOnError;\n"
+"    xhr.upload.onprogress = xhrUploadProgress;\n"
 "\n"
 "    xhr.open('POST', '/firmware-ajax'); //Defaults to async=true\n"
 "    xhr.send(file);\n"
 "}\n"
-"\n"
 "function startUpload()\n"
 "{\n"
 "    var fileInput = document.getElementById('fileInput');\n"
@@ -85,4 +89,5 @@
 "{\n"
 "    xhrRestartStart();\n"
 "}\n"
+"\n"
 ""
\ No newline at end of file
--- a/base/firmware/web-firmware-script.js	Sun Jan 17 12:45:56 2021 +0000
+++ b/base/firmware/web-firmware-script.js	Sun Jan 17 17:48:09 2021 +0000
@@ -22,19 +22,23 @@
 {
     logUpload('Upload error');
 }
+function xhrUploadProgress(e)
+{
+    logUpload('Uploading ' + e.total + ' bytes; ' + e.loaded + ' bytes so far...');
+}
 function xhrUploadStart()
 {
-    logUpload('Uploading...');
+    logUpload('Upload starting...');
     
     xhr = new XMLHttpRequest();
 
     xhr.onload  = xhrUploadOnLoad;
     xhr.onerror = xhrUploadOnError;
+    xhr.upload.onprogress = xhrUploadProgress;
 
     xhr.open('POST', '/firmware-ajax'); //Defaults to async=true
     xhr.send(file);
 }
-
 function startUpload()
 {
     var fileInput = document.getElementById('fileInput');