Fixed recent problems introduced with my switch to addEventListener
This commit is contained in:
parent
2cb0be42f0
commit
743511d5db
14 changed files with 70 additions and 88 deletions
|
|
@ -207,12 +207,12 @@ class FDC extends Component {
|
|||
setBinding(sHTMLType, sBinding, control, sValue)
|
||||
{
|
||||
var fdc = this;
|
||||
var controlSelect = /** @type {HTMLSelectElement} */ (control);
|
||||
|
||||
switch (sBinding) {
|
||||
|
||||
case "listDisks":
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
this.bindings[sBinding] = controlSelect;
|
||||
/*
|
||||
* Since binding is a one-time initialization operation, it's also the perfect time to
|
||||
* perform whatever sorting (if any) is indicated by the FDC component's "sortBy" property.
|
||||
|
|
@ -235,8 +235,8 @@ class FDC extends Component {
|
|||
* we have a special function, displayDiskette(), that will be called at LEAST once during
|
||||
* initialization, ensuring that selectedIndex is set correctly.
|
||||
*/
|
||||
for (i = 0; i < control.options.length; i++) {
|
||||
aOptions.push(control.options[i]);
|
||||
for (i = 0; i < controlSelect.options.length; i++) {
|
||||
aOptions.push(controlSelect.options[i]);
|
||||
}
|
||||
aOptions.sort(function(a, b) {
|
||||
/*
|
||||
|
|
@ -256,16 +256,15 @@ class FDC extends Component {
|
|||
/*
|
||||
* TODO: Determine why this line blows up in IE8; are the properties of an options object not settable in IE8?
|
||||
*/
|
||||
control.options[i] = aOptions[i];
|
||||
controlSelect.options[i] = aOptions[i];
|
||||
} catch(e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
control.onchange = function onChangeListDisks(event) {
|
||||
controlSelect.onchange = function onChangeListDisks(event) {
|
||||
var controlDesc = fdc.bindings["descDisk"];
|
||||
var controlOption = control.options[control.selectedIndex];
|
||||
var controlOption = controlSelect.options[controlSelect.selectedIndex];
|
||||
if (controlDesc && controlOption) {
|
||||
var dataValue = {};
|
||||
var sValue = controlOption.getAttribute("data-value");
|
||||
|
|
@ -287,22 +286,21 @@ class FDC extends Component {
|
|||
|
||||
case "descDisk":
|
||||
case "listDrives":
|
||||
this.bindings[sBinding] = control;
|
||||
this.bindings[sBinding] = controlSelect;
|
||||
/*
|
||||
* I tried going with onclick instead of onchange, so that if you wanted to confirm what's
|
||||
* loaded in a particular drive, you could click the drive control without having to change it.
|
||||
* However, that doesn't seem to work for all browsers, so I've reverted to onchange.
|
||||
*/
|
||||
control.onchange = function onChangeListDrives(event) {
|
||||
var iDrive = Str.parseInt(control.value, 10);
|
||||
controlSelect.onchange = function onChangeListDrives(event) {
|
||||
var iDrive = Str.parseInt(controlSelect.value, 10);
|
||||
if (iDrive != null) fdc.displayDiskette(iDrive);
|
||||
};
|
||||
return true;
|
||||
|
||||
case "loadDisk":
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
control.onclick = function onClickLoadDrive(event) {
|
||||
control.onclick = function onClickLoadDisk(event) {
|
||||
var controlDisks = fdc.bindings["listDisks"];
|
||||
if (controlDisks) {
|
||||
var sDisketteName = controlDisks.options[controlDisks.selectedIndex].text;
|
||||
|
|
@ -330,10 +328,8 @@ class FDC extends Component {
|
|||
control.parentNode.removeChild(/** @type {Node} */ (control));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
control.onclick = function onClickSaveDrive(event) {
|
||||
control.onclick = function onClickSaveDisk(event) {
|
||||
var controlDrives = fdc.bindings["listDrives"];
|
||||
if (controlDrives && controlDrives.options && fdc.aDrives) {
|
||||
var iDriveSelected = Str.parseInt(controlDrives.value, 10) || 0;
|
||||
|
|
@ -371,20 +367,17 @@ class FDC extends Component {
|
|||
control.parentNode.removeChild(/** @type {Node} */ (control));
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
/*
|
||||
* Enable "Mount" button only if a file is actually selected
|
||||
*/
|
||||
control.addEventListener('change', function() {
|
||||
control.onchange = function onChangeMountDisk() {
|
||||
var fieldset = control.children[0];
|
||||
var files = fieldset.children[0].files;
|
||||
var submit = fieldset.children[1];
|
||||
submit.disabled = !files.length;
|
||||
});
|
||||
|
||||
control.onsubmit = function(event) {
|
||||
};
|
||||
control.onsubmit = function onSubmitMountDisk(event) {
|
||||
var file = event.currentTarget[1].files[0];
|
||||
if (file) {
|
||||
var sDiskettePath = file.name;
|
||||
|
|
@ -1147,7 +1140,7 @@ class FDC extends Component {
|
|||
if (DEBUG) this.println("loading disk " + sDiskettePath + "...");
|
||||
|
||||
while (this.loadDrive(iDrive, sDisketteName, sDiskettePath, false, file) < 0) {
|
||||
if (!window.confirm("Click OK to reload the original disk.\n(WARNING: All disk changes will be discarded)")) {
|
||||
if (!window.confirm("Click OK to reload the original disk and discard any changes.")) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
|
|
@ -1524,7 +1517,7 @@ class FDC extends Component {
|
|||
addDiskHistory(sDisketteName, sDiskettePath, disk)
|
||||
{
|
||||
var i;
|
||||
this.assert(!!sDiskettePath);
|
||||
// this.assert(!!sDiskettePath);
|
||||
for (i = 0; i < this.aDiskHistory.length; i++) {
|
||||
if (this.aDiskHistory[i][1] == sDiskettePath) {
|
||||
var nChanges = disk.restore(this.aDiskHistory[i][2]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue