Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Revision 156:005785e4740e, committed 2021-01-24
- Comitter:
- andrewboyson
- Date:
- Sun Jan 24 18:54:27 2021 +0000
- Parent:
- 155:4df4ed4b65a2
- Child:
- 157:57bd76aa5e97
- Commit message:
- Changed firmware to distinguish between the upload and the file save on the device.; Changed ajax to give a quick update a second after a name value has been sent to give a chance for the device to have reacted.
Changed in this revision
--- a/base/firmware/web-firmware-script.inc Sun Jan 24 15:06:33 2021 +0000
+++ b/base/firmware/web-firmware-script.inc Sun Jan 24 18:54:27 2021 +0000
@@ -28,6 +28,10 @@
" 'Total ' + e.total + ' bytes\\r\\n' +\n"
" 'Sent ' + e.loaded + ' bytes');\n"
"}\n"
+"function xhrUploadComplete(e)\n"
+"{\n"
+" logUpload('Saving ' + e.loaded + ' bytes...');\n"
+"}\n"
"function xhrUploadStart()\n"
"{\n"
" logUpload('Upload starting...');\n"
@@ -37,6 +41,7 @@
" xhr.onload = xhrUploadOnLoad;\n"
" xhr.onerror = xhrUploadOnError;\n"
" xhr.upload.onprogress = xhrUploadProgress;\n"
+" xhr.upload.onload = xhrUploadComplete;\n"
"\n"
" xhr.open('POST', '/firmware-ajax'); //Defaults to async=true\n"
" xhr.send(file);\n"
--- a/base/firmware/web-firmware-script.js Sun Jan 24 15:06:33 2021 +0000
+++ b/base/firmware/web-firmware-script.js Sun Jan 24 18:54:27 2021 +0000
@@ -28,6 +28,10 @@
'Total ' + e.total + ' bytes\r\n' +
'Sent ' + e.loaded + ' bytes');
}
+function xhrUploadComplete(e)
+{
+ logUpload('Saving ' + e.loaded + ' bytes...');
+}
function xhrUploadStart()
{
logUpload('Upload starting...');
@@ -37,6 +41,7 @@
xhr.onload = xhrUploadOnLoad;
xhr.onerror = xhrUploadOnError;
xhr.upload.onprogress = xhrUploadProgress;
+ xhr.upload.onload = xhrUploadComplete;
xhr.open('POST', '/firmware-ajax'); //Defaults to async=true
xhr.send(file);
--- a/common/web-ajax-class.inc Sun Jan 24 15:06:33 2021 +0000
+++ b/common/web-ajax-class.inc Sun Jan 24 18:54:27 2021 +0000
@@ -15,7 +15,9 @@
"let ajaxXhr_ = null;\n"
"let ajaxMsCountAtAjaxSend_ = 0;\n"
"const ajaxTickMs_ = 100;\n"
+"const ajaxQuickUpdateMs_ = 1000;\n"
"const ajaxUpdateMs_ = 10000;\n"
+"let ajaxDoQuickUpdate_ = false;\n"
"\n"
"//Private utilities\n"
"function ajaxGetElementOrNull_(elementName) //Returns the element if it: exists; block is overidden; does not have focus\n"
@@ -103,12 +105,14 @@
" ajaxXhr_.open('GET', ajaxServer_, true);\n"
" }\n"
" ajaxXhr_.send();\n"
+" ajaxDoQuickUpdate_ = false;\n"
" ajaxMsCountAtAjaxSend_ = ajaxMs_;\n"
"}\n"
"function AjaxSendNameValue(name, value) //From html\n"
"{\n"
" ajaxOverrideBlockUpdateOnFocus_ = true; //Request has come from an update\n"
" ajaxSendNameValue_(name, value);\n"
+" ajaxDoQuickUpdate_ = true;\n"
"}\n"
"\n"
"//Private functions\n"
@@ -116,6 +120,10 @@
"{\n"
" ajaxMs_ += ajaxTickMs_; //Don't use Date.now() as we don't know when the PC's clock will be updated around a leap second\n"
" if (ajaxMs_ >= ajaxMsCountAtAjaxSend_ + ajaxUpdateMs_) ajaxSendNameValue_('', '');\n"
+" if (ajaxDoQuickUpdate_)\n"
+" {\n"
+" if (ajaxMs_ >= ajaxMsCountAtAjaxSend_ + ajaxQuickUpdateMs_) ajaxSendNameValue_('', '');\n"
+" }\n"
" if (ajaxOnTick_) ajaxOnTick_();\n"
"}\n"
"function ajaxInit_()\n"
--- a/common/web-ajax-class.js Sun Jan 24 15:06:33 2021 +0000
+++ b/common/web-ajax-class.js Sun Jan 24 18:54:27 2021 +0000
@@ -15,7 +15,9 @@
let ajaxXhr_ = null;
let ajaxMsCountAtAjaxSend_ = 0;
const ajaxTickMs_ = 100;
+const ajaxQuickUpdateMs_ = 1000;
const ajaxUpdateMs_ = 10000;
+let ajaxDoQuickUpdate_ = false;
//Private utilities
function ajaxGetElementOrNull_(elementName) //Returns the element if it: exists; block is overidden; does not have focus
@@ -103,12 +105,14 @@
ajaxXhr_.open('GET', ajaxServer_, true);
}
ajaxXhr_.send();
+ ajaxDoQuickUpdate_ = false;
ajaxMsCountAtAjaxSend_ = ajaxMs_;
}
function AjaxSendNameValue(name, value) //From html
{
ajaxOverrideBlockUpdateOnFocus_ = true; //Request has come from an update
ajaxSendNameValue_(name, value);
+ ajaxDoQuickUpdate_ = true; //Make the next request a quick one
}
//Private functions
@@ -116,6 +120,10 @@
{
ajaxMs_ += ajaxTickMs_; //Don't use Date.now() as we don't know when the PC's clock will be updated around a leap second
if (ajaxMs_ >= ajaxMsCountAtAjaxSend_ + ajaxUpdateMs_) ajaxSendNameValue_('', '');
+ if (ajaxDoQuickUpdate_)
+ {
+ if (ajaxMs_ >= ajaxMsCountAtAjaxSend_ + ajaxQuickUpdateMs_) ajaxSendNameValue_('', '');
+ }
if (ajaxOnTick_) ajaxOnTick_();
}
function ajaxInit_()