Fixed recent problems introduced with my switch to addEventListener

This commit is contained in:
Jeff Parsons 2017-06-27 17:39:20 -07:00 committed by Jeff Parsons
commit 743511d5db
14 changed files with 70 additions and 88 deletions

View file

@ -103,7 +103,7 @@ class C1PSerialPort extends Component {
* @this {C1PSerialPort}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "listSerial")
* @param {HTMLElement} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
@ -120,7 +120,7 @@ class C1PSerialPort extends Component {
case "loadSerial":
this.bindings[sBinding] = control;
control.onclick = function(event) {
control.onclick = function onClickLoadSerial(event) {
if (serial.bindings["listSerial"]) {
var sFile = serial.bindings["listSerial"].value;
// serial.println("loading " + sFile + "...");
@ -137,18 +137,16 @@ class C1PSerialPort extends Component {
*/
if (!Web.isMobile() && window && 'FileReader' in window) {
this.bindings[sBinding] = control;
/*
* Enable "Mount" button only if a file is actually selected
*/
control.addEventListener('change', function() {
control.onchange = function onChangeMountSerial() {
var fieldset = control.children[0];
var files = fieldset.children[0].files;
var submit = fieldset.children[1];
submit.disabled = !files.length;
});
control.addEventListener('submit', function(event) {
};
control.onsubmit = function onSubmitMountSerial(event) {
var file = event.currentTarget[1].files[0];
var reader = new FileReader();
@ -162,7 +160,7 @@ class C1PSerialPort extends Component {
* Prevent reloading of web page after form submission
*/
return false;
});
};
}
else {
if (DEBUG) this.log("Local file support not available");