Fixed a few lingering code inspection warnings and typos

This commit is contained in:
Jeff Parsons 2017-08-08 17:30:28 -07:00 committed by Jeff Parsons
commit 2fc2872386
11 changed files with 669 additions and 680 deletions

View file

@ -905,22 +905,23 @@ class DebuggerX86 extends Debugger {
switch (sBinding) {
case "debugInput":
this.bindings[sBinding] = control;
this.controlDebug = control;
var controlInput = /** @type {HTMLInputElement} */ (control);
this.bindings[sBinding] = controlInput;
this.controlDebug = controlInput;
/*
* For halted machines, this is fine, but for auto-start machines, it can be annoying.
*
* control.focus();
* controlInput.focus();
*/
control.onkeydown = function onKeyDownDebugInput(event) {
controlInput.onkeydown = function onKeyDownDebugInput(event) {
var sCmd;
if (event.keyCode == Keys.KEYCODE.CR) {
sCmd = control.value;
control.value = "";
sCmd = controlInput.value;
controlInput.value = "";
dbg.doCommands(sCmd, true);
}
else if (event.keyCode == Keys.KEYCODE.ESC) {
control.value = sCmd = "";
controlInput.value = sCmd = "";
}
else {
if (event.keyCode == Keys.KEYCODE.UP) {
@ -931,8 +932,8 @@ class DebuggerX86 extends Debugger {
}
if (sCmd != null) {
var cch = sCmd.length;
control.value = sCmd;
control.setSelectionRange(cch, cch);
controlInput.value = sCmd;
controlInput.setSelectionRange(cch, cch);
}
}
if (sCmd != null && event.preventDefault) event.preventDefault();

View file

@ -201,6 +201,7 @@ class Keyboard extends Component {
*/
var kbd = this;
var id = sHTMLType + '-' + sBinding;
var controlText = /** @type {HTMLTextAreaElement} */ (control);
if (this.bindings[id] === undefined) {
switch (sBinding) {
@ -214,13 +215,13 @@ class Keyboard extends Component {
*
* this.bindings[id] = control;
*/
control.onkeydown = function onKeyDown(event) {
controlText.onkeydown = function onKeyDown(event) {
return kbd.onKeyDown(event, true);
};
control.onkeypress = function onKeyPressKbd(event) {
controlText.onkeypress = function onKeyPressKbd(event) {
return kbd.onKeyPress(event);
};
control.onkeyup = function onKeyUp(event) {
controlText.onkeyup = function onKeyUp(event) {
return kbd.onKeyDown(event, false);
};
return true;
@ -258,8 +259,8 @@ class Keyboard extends Component {
*/
var sCode = sBinding.toUpperCase().replace(/-/g, '_');
if (Keyboard.CLICKCODES[sCode] !== undefined && sHTMLType == "button") {
this.bindings[id] = control;
control.onclick = function(kbd, sKey, simCode) {
this.bindings[id] = controlText;
controlText.onclick = function(kbd, sKey, simCode) {
return function onKeyboardBindingClick(event) {
if (!COMPILED && kbd.messageEnabled()) kbd.printMessage(sKey + " clicked", Messages.KEYS);
event.preventDefault(); // preventDefault() is necessary...
@ -273,7 +274,7 @@ class Keyboard extends Component {
}
else if (Keyboard.SOFTCODES[sBinding] !== undefined) {
this.cSoftCodes++;
this.bindings[id] = control;
this.bindings[id] = controlText;
var fnDown = function(kbd, sKey, simCode) {
return function onKeyboardBindingDown(event) {
event.preventDefault(); // preventDefault() is necessary...
@ -288,11 +289,11 @@ class Keyboard extends Component {
};
}(this, sBinding, Keyboard.SOFTCODES[sBinding]);
if ('ontouchstart' in window) {
control.ontouchstart = fnDown;
control.ontouchend = fnUp;
controlText.ontouchstart = fnDown;
controlText.ontouchend = fnUp;
} else {
control.onmousedown = fnDown;
control.onmouseup = control.onmouseout = fnUp;
controlText.onmousedown = fnDown;
controlText.onmouseup = controlText.onmouseout = fnUp;
}
return true;
}

View file

@ -59,7 +59,7 @@ if (NODE) {
* @property {number} portBase
* @property {number} nIRQ
* @property {string|null} consoleOutput
* @property {Object} controlIOBuffer (DOM element bound to the port for rudimentary output; see transmitByte())
* @property {HTMLTextAreaElement} controlIOBuffer (DOM element bound to the port for rudimentary output; see transmitByte())
* @unrestricted
*/
class SerialPort extends Component {
@ -114,8 +114,6 @@ class SerialPort extends Component {
* consoleOutput becomes a string that records serial port output if the 'binding' property is set to the
* reserved name "console". Nothing is written to the console, however, until a linefeed (0x0A) is output
* or the string length reaches a threshold (currently, 1024 characters).
*
* @type {string|null}
*/
this.consoleOutput = null;
@ -130,8 +128,6 @@ class SerialPort extends Component {
* serial input, DOS *transmits* the appropriate characters back to the terminal via COM2.
*
* As a result, controlIOBuffer only needs to be updated by the transmitByte() function.
*
* @type {Object}
*/
this.controlIOBuffer = null;
@ -214,13 +210,13 @@ class SerialPort extends Component {
switch (sBinding) {
case SerialPort.sIOBuffer:
this.bindings[sBinding] = this.controlIOBuffer = control;
this.bindings[sBinding] = this.controlIOBuffer = /** @type {HTMLTextAreaElement} */ (control);
/*
* By establishing an onkeypress handler here, we make it possible for DOS commands like
* "CTTY COM1" to more or less work (use "CTTY CON" to restore control to the DOS console).
*/
control.onkeydown = function onKeyDown(event) {
this.controlIOBuffer.onkeydown = function onKeyDown(event) {
/*
* This is required in addition to onkeypress, because it's the only way to prevent
* BACKSPACE (keyCode 8) from being interpreted by the browser as a "Back" operation;
@ -242,7 +238,7 @@ class SerialPort extends Component {
return true;
};
control.onkeypress = function onKeyPress(event) {
this.controlIOBuffer.onkeypress = function onKeyPress(event) {
/*
* Browser-independent keyCode extraction; refer to onKeyPress() and the other key event
* handlers in keyboard.js.
@ -266,7 +262,7 @@ class SerialPort extends Component {
* itself no longer needs the "readonly" attribute; we primarily need to remove it for iOS browsers,
* so that the soft keyboard will activate, but it shouldn't hurt to remove the attribute for all browsers.
*/
control.removeAttribute("readonly");
this.controlIOBuffer.removeAttribute("readonly");
return true;

View file

@ -1314,7 +1314,7 @@ Card.FEAT_CTRL = {
*/
Card.MISC = {
PORT_WRITE: 0x3C2, // write port address (EGA and VGA)
PORT_READ: 0x3CC, // read port addresss (VGA only)
PORT_READ: 0x3CC, // read port address (VGA only)
IO_SELECT: 0x01, // 0 sets CRT ports to 0x3Bn, 1 sets CRT ports to 0x3Dn
ENABLE_RAM: 0x02, // 0 disables video RAM, 1 enables
CLOCK_SELECT: 0x0C, // 0x0: 14Mhz I/O clock, 0x4: 16Mhz on-board clock, 0x8: external clock, 0xC: unused