Disable local file upload if FileReader support is not available.
This commit is contained in:
parent
4c2624785f
commit
008c51f352
1 changed files with 20 additions and 13 deletions
|
|
@ -125,21 +125,28 @@ C1PSerialPort.prototype.setBinding = function(c, t, s, e)
|
||||||
}(this);
|
}(this);
|
||||||
return true;
|
return true;
|
||||||
case "uploadSerial":
|
case "uploadSerial":
|
||||||
this.bindings[s] = e;
|
// Check for availability of FileReader
|
||||||
var serial = this;
|
if (window.FileReader && window.File && window.FileList && window.Blob ) {
|
||||||
e.onsubmit = function (event) {
|
var serial = this;
|
||||||
var file = event.currentTarget[1].files[0];
|
this.bindings[s] = e;
|
||||||
|
e.onsubmit = function (event) {
|
||||||
|
var file = event.currentTarget[1].files[0];
|
||||||
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function () {
|
reader.onload = function () {
|
||||||
// serial.println("uploading " + file.name + "...");
|
// serial.println("uploading " + file.name + "...");
|
||||||
serial.loadFile(file.name, reader.result, 0);
|
serial.loadFile(file.name, reader.result, 0);
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
|
||||||
|
// Prevent reloading of web page after form submission
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
}
|
||||||
|
else {
|
||||||
// Prevent reloading of web page after form submission
|
this.println("FileReader support not available, disabling local file upload");
|
||||||
return false;
|
e.parentNode.removeChild(e);
|
||||||
};
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue