Added command to select RL11 drive
This commit is contained in:
parent
c59dd06914
commit
edf22928b9
3 changed files with 62 additions and 15 deletions
|
|
@ -83,6 +83,10 @@ class RL11 extends Component {
|
|||
* Define all the properties to be initialized by initController()
|
||||
*/
|
||||
this.regRLCS = this.regRLBA = this.regRLDA = this.tmpRLDA = this.regRLMP = this.regRLBE = 0;
|
||||
|
||||
this['exports'] = {
|
||||
'selectDrive': this.selectDrive
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -756,15 +760,20 @@ class RL11 extends Component {
|
|||
/**
|
||||
* displayDisk(iDrive, fUpdateDrive)
|
||||
*
|
||||
* This ensures that the selected disk matches the drive's sDiskPath property, and if fUpdateDrive is set,
|
||||
* it also ensures that the selected drive matches the specified drive number.
|
||||
*
|
||||
* @this {RL11}
|
||||
* @param {number} iDrive (unvalidated)
|
||||
* @param {number} iDrive
|
||||
* @param {boolean} [fUpdateDrive] is true to update the drive list to match the specified drive (eg, the auto-mount case)
|
||||
* @return {boolean} true if successful, false if not
|
||||
*/
|
||||
displayDisk(iDrive, fUpdateDrive)
|
||||
{
|
||||
/*
|
||||
* First things first: validate iDrive.
|
||||
*/
|
||||
var fSuccess = false;
|
||||
if (iDrive >= 0 && iDrive < this.aDrives.length) {
|
||||
var drive = this.aDrives[iDrive];
|
||||
var controlDisks = this.bindings["listDisks"];
|
||||
|
|
@ -774,9 +783,24 @@ class RL11 extends Component {
|
|||
*/
|
||||
if (controlDisks && controlDrives && controlDisks.options && controlDrives.options) {
|
||||
/*
|
||||
* Next, make sure the drive whose disk we're updating is the currently selected drive.
|
||||
* Next, update the drive if the caller has requested it.
|
||||
*/
|
||||
var i;
|
||||
if (fUpdateDrive) {
|
||||
this.assert(iDrive == drive.iDrive);
|
||||
for (i = 0; i < controlDrives.options.length; i++) {
|
||||
if (Str.parseInt(controlDrives.options[i].value, 10) == drive.iDrive) {
|
||||
if (controlDrives.selectedIndex != i) {
|
||||
controlDrives.selectedIndex = i;
|
||||
}
|
||||
fSuccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Next, make sure the drive whose disk we're updating is the currently selected drive.
|
||||
*/
|
||||
var iDriveSelected = Str.parseInt(controlDrives.value, 10);
|
||||
var sTargetPath = (drive.fLocal? RL11.SOURCE.LOCAL : drive.sDiskPath);
|
||||
if (!isNaN(iDriveSelected) && iDriveSelected == iDrive) {
|
||||
|
|
@ -785,23 +809,39 @@ class RL11 extends Component {
|
|||
if (controlDisks.selectedIndex != i) {
|
||||
controlDisks.selectedIndex = i;
|
||||
}
|
||||
fSuccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == controlDisks.options.length) controlDisks.selectedIndex = 0;
|
||||
}
|
||||
if (fUpdateDrive) {
|
||||
for (i = 0; i < controlDrives.options.length; i++) {
|
||||
if (Str.parseInt(controlDrives.options[i].value, 10) == drive.iDrive) {
|
||||
if (controlDrives.selectedIndex != i) {
|
||||
controlDrives.selectedIndex = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* selectDrive(sDrive)
|
||||
*
|
||||
* Used to programmatically select a drive by name.
|
||||
*
|
||||
* @this {RL11}
|
||||
* @param {number} sDrive
|
||||
* @return {boolean} true if successful, false if not
|
||||
*/
|
||||
selectDrive(sDrive)
|
||||
{
|
||||
var controlDrives = this.bindings["listDrives"];
|
||||
if (controlDrives && controlDrives.options) {
|
||||
var nDrives = controlDrives.options.length;
|
||||
for (var i = 0; i < nDrives; i++) {
|
||||
if (controlDrives.options[i].innerHTML == sDrive) {
|
||||
var iDrive = Str.parseInt(controlDrives.options[i].value, 10);
|
||||
return this.displayDisk(iDrive, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ function commandMachine(idMachine, sType, sCommand, sValue)
|
|||
var fnCommand = exports[sCommand];
|
||||
if (fnCommand) {
|
||||
//noinspection JSUnresolvedFunction
|
||||
fnCommand.call(component, sValue);
|
||||
if (!fnCommand.call(component, sValue)) {
|
||||
window.alert("Error calling " + idMachine + "." + sType + "." + sCommand + "(" + sValue + ")");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue