Code cleanup

This commit is contained in:
Jeff Parsons 2016-02-11 15:44:10 -08:00
commit b6cf972131
36 changed files with 561 additions and 227 deletions

View file

@ -1 +1 @@
<div class="pcbuild" id="{{ include.id }}"></div>
<div class="buildpc" id="{{ include.id }}"></div>

View file

@ -64,7 +64,7 @@ here and in markout.js. Examples include 'autopower' ('autoPower') and 'automou
{% endif %}
<script type="text/javascript">{{ machine_embed }}('{{ machine.id }}','{{ machine_config }}','{{ machine_template }}','{{ machine_parms }}');</script>
{% if page.build %}
<script type="text/javascript" src="{{ site.baseurl }}/modules/pcbuild/lib/build.js"></script>
<script type="text/javascript" src="{{ site.baseurl }}/modules/build/lib/build.js"></script>
<script type="text/javascript">buildPC("{{ page.build }}");</script>
{% endif %}
{% endfor %}

View file

@ -21,7 +21,7 @@ could only be used in PC, XT, and AT-compatible systems. I'll refer to it here
The VGA ROM used here is assumed to have come from an original IBM VGA. It's unknown if IBM ever made any
revisions to the VGA ROM. With the introduction of the PS/2 family and the VGA, IBM decided to no longer publish
the source code for its ROMs, so I've created some assemblable source code from the IBM VGA ROM
[here](/devices/pc/video/ibm/vga/ibm-vga.nasm).
[here](/devices/pc/video/ibm/vga/).
I've finally started debugging a machine configuration that uses the IBM VGA ROM. Since the VGA and the 80386 are
contemporaries, I'm using an [80386 machine configuration](/devices/pc/machine/compaq/deskpro386/vga/2048kb/machine.xml).

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

451
modules/build/lib/build.js Normal file
View file

@ -0,0 +1,451 @@
/**
* @fileoverview PCjs Build Options
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Feb-10
*
* Copyright © 2012-2016 Jeff Parsons <Jeff@pcjs.org>
*
* This file is part of the JavaScript Machines Project (aka JSMachines) at <http://jsmachines.net/>
* and <http://pcjs.org/>.
*
* JSMachines is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* JSMachines is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with JSMachines.
* If not, see <http://www.gnu.org/licenses/gpl.html>.
*
* You are required to include the above copyright notice in every source code file of every
* copy or modified version of this work, and to display that copyright notice on every screen
* that loads or runs any version of this software (see Computer.COPYRIGHT).
*
* Some JSMachines files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of the
* JSMachines Project for purposes of the GNU General Public License, and the author does not claim
* any copyright as to their contents.
*/
"use strict";
/*
* This file provides all the UI options for building a functional PCjs PC.
*/
var typeAddress = {
type: "address"
};
var typeBoolean = {
type: "boolean"
};
var typeNumber = {
type: "number"
};
var typePath = {
type: "string"
};
var typeString = {
type: "string"
};
var typeElement = {
type: "element"
};
var machineOptions = {
'ibm5150': "IBM PC (Model 5150)",
'ibm5160': "IBM PC XT (Model 5160)",
'ibm5170': "IBM PC AT (Model 5170)",
'deskpro386': "COMPAQ DeskPro 386"
};
var videoLEDCapsLock = {
'control': {
_type: typeElement,
'type': {
_type: typeString,
_value: "led"
},
'label': {
_type: typeString,
_value: "Caps"
},
'binding': {
_type: typeString,
_value: "caps-lock"
},
'pad-left': {
_type: typeString,
_value: "8px"
}
}
};
var videoLEDNumLock = {
'control': {
_type: typeElement,
'type': {
_type: typeString,
_value: "led"
},
'label': {
_type: typeString,
_value: "Num"
},
'binding': {
_type: typeString,
_value: "num-lock"
},
'pad-left': {
_type: typeString,
_value: "8px"
}
}
};
var videoLEDScrollLock = {
'control': {
_type: typeElement,
'type': {
_type: typeString,
_value: "led"
},
'label': {
_type: typeString,
_value: "Scroll"
},
'binding': {
_type: typeString,
_value: "scroll-lock"
},
'pad-left': {
_type: typeString,
_value: "8px"
}
}
};
var videoLEDContainer = {
_type: typeElement,
_value: [videoLEDCapsLock, videoLEDNumLock, videoLEDScrollLock],
'type': {
_type: typeString,
_value: "container"
},
'pos': {
_type: typeString,
_value: "right"
}
};
var videoCGALEDContainer = {
'title': {
_type: typeElement,
_value: "Color Display"
},
'control': videoLEDContainer
};
var videoCGALEDMenu = {
'menu': {
_type: typeElement,
_value: videoCGALEDContainer
}
};
var machineElements = {
'name': {
_type: typeElement,
_desc: "Machine Description",
_value: "IBM PC"
},
'computer': {
_type: typeElement,
_desc: "General Computer Features",
_value: null,
'buswidth': {
_type: typeNumber,
_desc: "Bus width",
_opts: {
20: "20-bit bus",
24: "24-bit bus",
32: "32-bit bus"
}
},
'resume': {
_type: typeNumber,
_desc: "Resume option",
_opts: {
0: "Resume Disabled",
1: "Resume Enabled",
2: "Resume with Prompt"
}
}
},
'ram': {
_type: typeElement,
_desc: "Read-Write Memory (Conventional or Extended)",
_multi: true,
_value: [
{
'id': "ramLow",
'addr': "0x00000"
}
],
'id': {
_type: typeString
},
'addr': {
_type: typeAddress
},
'size': {
_type: typeNumber
}
},
'rom': {
_type: typeElement,
_desc: "Read-Only Memory",
_multi: true,
_value: [
{
'id': "romBASIC",
'addr': "0xf6000",
'size': "0x8000",
'file': "/devices/pc/rom/5150/basic/BASIC100.json"
},
{
'id': "romBIOS",
'addr': "0xfe000",
'size': "0x2000",
'file': "/devices/pc/rom/5150/bios/1981-04-24/PCBIOS-REV1.json"
}
],
'addr': {
_type: typeAddress
},
'size': {
_type: typeNumber
},
'file': {
_type: typePath
}
},
'video': {
_type: typeElement,
_desc: "Video Adapter",
_multi: false,
_opts: {
'cga': {
'screenwidth': {
_type: typeNumber,
_opts: [960]
},
'screenheight': {
_type: typeNumber,
_opts: [480]
},
'scale': {
_type: typeBoolean,
_opts: [true]
},
'charset': {
_type: typePath,
_opts: ["/devices/pc/video/ibm/cga/ibm-cga.json"]
},
'pos': {
_type: typeString,
_opts: ["center"]
},
'padding': {
_type: typeString,
_opts: ["8px"]
},
'controls': videoCGALEDMenu
}
}
}
};
var pcElements = {
'machine': {
_desc: "Machine",
_type: typeElement,
_opts: machineOptions,
_value: machineElements,
'id': {
_type: typeString
},
'class': {
_type: typeString,
_value: "pc"
},
'border': {
_type: typeNumber,
_value: "1"
},
'pos': {
_type: typeString,
_value: "center"
},
'background': {
_type: typeString,
_value: "#FAEBD7"
}
}
};
/*
* As we build a PC, elements will be added to pcState that mirror the template structures above. Also,
* as choices are made, the identifier of that choice will be added as the 'id' of the corresponding element.
*
* 'machine': {
* 'id': "ibm5150",
* 'class': "pc",
* 'border': "1",
* 'pos': "center"
* 'background': "#FAEBD7"
* 'name': {
* },
* 'computer': {
* },
* 'ram': {
* }
* // ...
* }
*/
var pcState = {};
/**
* findNewItem(state, template)
*
* @param {Object} state (eg, pcState)
* @param {Object} template (eg, pcElements)
* @return {Object|null} (eg, state['machine'])
*/
function findNewItem(state, template)
{
for (var item in template) {
if (item.charAt(0) == '_') continue;
if (state[item] === undefined) {
state[item] = {
_template: template[item]
};
return state[item];
}
if (typeof template[item] == "object") {
var itemNext = findNewItem(state[item], template[item]);
if (itemNext) return itemNext;
}
}
if (template._type == typeElement && template._value && typeof template._value == "object") {
return findNewItem(state, template._value);
}
return null;
}
/**
* setNewItem(idHTML, eHTML, item)
*
* @param {string} idHTML
* @param {Object} eHTML
* @param {Object} item (ie, a node in pcState with a _template that contains _opts)
*/
function setNewItem(idHTML, eHTML, item)
{
/*
* First, remove any old options...
*
while (eHTML.firstChild) {
eHTML.removeChild(eHTML.firstChild);
}
*/
/*
* Next, add a new set of options....
*/
var value;
var opts = item._template._opts;
if (!opts) {
value = item._template._value;
if (value) {
populateItem(item, null);
}
else {
/*
* Add an input field to prompt for the value...
*/
}
setTimeout(function() { buildPC(idHTML) }, 0);
}
else {
var eSelect = document.createElement("select");
var eOption = document.createElement("option");
eOption['value'] = "none";
eOption.textContent = "Select a " + item._template._desc + "...";
eSelect.appendChild(eOption);
for (value in opts) {
eOption = document.createElement("option");
eOption['value'] = value;
eOption.textContent = opts[value];
eSelect.appendChild(eOption);
}
eSelect.onchange = function(event) {
var id = eSelect.value;
if (id != "none" && id != item.id) {
populateItem(item, id);
setTimeout(function() { buildPC(idHTML) }, 0);
}
};
eHTML.appendChild(eSelect);
}
}
/**
* populateItem(item, id)
*
* @param {Object} item (eg, state['machine'])
* @param {string|null} id for item
*/
function populateItem(item, id)
{
if (id) item.id = id;
for (var prop in item._template) {
if (prop == '_value' && !id) {
item[prop] = item._template[prop];
}
if (prop.charAt(0) != '_') {
var attr = item._template[prop];
if (item[prop] === undefined && typeof attr._value == "string") {
item[prop] = attr._value;
}
}
}
}
/**
* buildPC(idHTML)
*
* @param {string} idHTML (the ID of the DIV where build UI options should be presented)
*/
function buildPC(idHTML)
{
var eHTML = document.getElementById(idHTML);
if (eHTML) {
var item = findNewItem(pcState, pcElements);
if (item) {
setNewItem(idHTML, eHTML, item);
}
}
}

View file

@ -265,7 +265,7 @@ C1PComputer.power = function(computer)
*/
C1PComputer.init = function()
{
var aeComputers = Component.getElementsByClass(window.document, C1PJSCLASS, "computer");
var aeComputers = Component.getElementsByClass(document, C1PJSCLASS, "computer");
for (var iComputer=0; iComputer < aeComputers.length; iComputer++) {

View file

@ -3879,7 +3879,7 @@ C1PCPU.prototype.opUndefined = function()
*/
C1PCPU.init = function()
{
var aeCPUs = Component.getElementsByClass(window.document, C1PJSCLASS, "cpu");
var aeCPUs = Component.getElementsByClass(document, C1PJSCLASS, "cpu");
for (var iCPU=0; iCPU < aeCPUs.length; iCPU++) {
var eCPU = aeCPUs[iCPU];
var parmsCPU = Component.getComponentParms(eCPU);

View file

@ -2202,7 +2202,7 @@ if (DEBUGGER) {
*/
C1PDebugger.init = function()
{
var aeDbg = Component.getElementsByClass(window.document, C1PJSCLASS, "debugger");
var aeDbg = Component.getElementsByClass(document, C1PJSCLASS, "debugger");
for (var iDbg=0; iDbg < aeDbg.length; iDbg++) {
var eDbg = aeDbg[iDbg];
var parmsDbg = Component.getComponentParms(eDbg);

View file

@ -1254,7 +1254,7 @@ C1PDiskController.prototype.writePort = function(port, reg)
*/
C1PDiskController.init = function()
{
var aeDC = Component.getElementsByClass(window.document, C1PJSCLASS, "disk");
var aeDC = Component.getElementsByClass(document, C1PJSCLASS, "disk");
for (var iDC=0; iDC < aeDC.length; iDC++) {
var eDC = aeDC[iDC];
var parmsDC = Component.getComponentParms(eDC);

View file

@ -1094,7 +1094,7 @@ C1PKeyboard.prototype.updateMemory = function(fPropagate, addr, bWrite)
*/
C1PKeyboard.init = function()
{
var aeKbd = Component.getElementsByClass(window.document, C1PJSCLASS, "keyboard");
var aeKbd = Component.getElementsByClass(document, C1PJSCLASS, "keyboard");
for (var iKbd=0; iKbd < aeKbd.length; iKbd++) {
var eKbd = aeKbd[iKbd];
var parmsKbd = Component.getComponentParms(eKbd);

View file

@ -112,7 +112,7 @@ C1PPanel.prototype.setPower = function(fOn, cmp)
C1PPanel.init = function()
{
var fReady = false;
var aePanels = Component.getElementsByClass(window.document, C1PJSCLASS, "panel");
var aePanels = Component.getElementsByClass(document, C1PJSCLASS, "panel");
for (var iPanel=0; iPanel < aePanels.length; iPanel++) {
var ePanel = aePanels[iPanel];
var parmsPanel = Component.getComponentParms(ePanel);

View file

@ -83,7 +83,7 @@ C1PRAM.prototype.setBuffer = function(abMemory, start, end, cpu)
*/
C1PRAM.init = function()
{
var aeRAM = Component.getElementsByClass(window.document, C1PJSCLASS, "ram");
var aeRAM = Component.getElementsByClass(document, C1PJSCLASS, "ram");
for (var iRAM=0; iRAM < aeRAM.length; iRAM++) {
var eRAM = aeRAM[iRAM];
var parmsRAM = Component.getComponentParms(eRAM);

View file

@ -229,7 +229,7 @@ C1PROM.prototype.copyImage = function()
*/
C1PROM.init = function()
{
var aeROM = Component.getElementsByClass(window.document, C1PJSCLASS, "rom");
var aeROM = Component.getElementsByClass(document, C1PJSCLASS, "rom");
for (var iROM=0; iROM < aeROM.length; iROM++) {
var eROM = aeROM[iROM];
var parmsROM = Component.getComponentParms(eROM);

View file

@ -391,7 +391,7 @@ C1PSerialPort.prototype.updateMemory = function()
*/
C1PSerialPort.init = function()
{
var aeSerial = Component.getElementsByClass(window.document, C1PJSCLASS, "serial");
var aeSerial = Component.getElementsByClass(document, C1PJSCLASS, "serial");
for (var iSerial=0; iSerial < aeSerial.length; iSerial++) {
var eSerial = aeSerial[iSerial];
var parmsSerial = Component.getComponentParms(eSerial);

View file

@ -533,7 +533,7 @@ C1PVideo.prototype.updateWindow = function(col, row, b)
*/
C1PVideo.init = function()
{
var aeVideo = Component.getElementsByClass(window.document, C1PJSCLASS, "video");
var aeVideo = Component.getElementsByClass(document, C1PJSCLASS, "video");
for (var iVideo=0; iVideo < aeVideo.length; iVideo++) {
var eVideo = aeVideo[iVideo];
var parmsVideo = Component.getComponentParms(eVideo);
@ -547,7 +547,7 @@ C1PVideo.init = function()
* I've since settled on a better work-around in keyboard.js, so I've stopped worrying about how to make
* "autocapitalize" work here.
*/
var eCanvas = window.document.createElement("canvas");
var eCanvas = document.createElement("canvas");
if (eCanvas === undefined || !eCanvas.getContext) {
eVideo.innerHTML = "<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";
return;

View file

@ -1908,7 +1908,7 @@ HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done)
this.addFilesToHTML(asFiles, sScriptEmbed);
if (buildOptions.id) {
asFiles = [];
asFiles.push("/modules/pcbuild/lib/build.js");
asFiles.push("/modules/build/lib/build.js");
sScriptEmbed = '<script type="text/javascript">buildPC("' + buildOptions.id + '")</script>';
this.addFilesToHTML(asFiles, sScriptEmbed);
}

View file

@ -1134,7 +1134,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over
}
sBlock = sBlock.replace(/\{%\s*include\s+build\.html\s+id=(["'])(.*?)\1\s*%}/g, '<div class="pcbuild" id=$1$2$1></div>');
sBlock = sBlock.replace(/\{%\s*include\s+build\.html\s+id=(["'])(.*?)\1\s*%}/g, '<div class="buildpc" id=$1$2$1></div>');
/*
* Start looking for Markdown-style machine links now...

View file

@ -1,117 +0,0 @@
/**
* @fileoverview PCjs Build Options
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Feb-10
*
* Copyright © 2012-2016 Jeff Parsons <Jeff@pcjs.org>
*
* This file is part of the JavaScript Machines Project (aka JSMachines) at <http://jsmachines.net/>
* and <http://pcjs.org/>.
*
* JSMachines is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* JSMachines is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with JSMachines.
* If not, see <http://www.gnu.org/licenses/gpl.html>.
*
* You are required to include the above copyright notice in every source code file of every
* copy or modified version of this work, and to display that copyright notice on every screen
* that loads or runs any version of this software (see Computer.COPYRIGHT).
*
* Some JSMachines files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of the
* JSMachines Project for purposes of the GNU General Public License, and the author does not claim
* any copyright as to their contents.
*/
"use strict";
/*
* This file provides all the UI options for building a functional PCjs PC.
*/
var typeAddress = {
type: "address"
};
var typeBoolean = {
type: "boolean"
};
var typeNumber = {
type: "number"
};
var typePath = {
type: "string"
};
var typeString = {
type: "string"
};
var machineTypes = {
'5150': "IBM PC (Model 5150)",
'5160': "IBM PC XT (Model 5160)",
'5170': "IBM PC AT (Model 5170)",
'deskpro386': "COMPAQ DeskPro 386"
};
var aMachineElements = {
'machine': {
choices: machineTypes
},
'name': {
desc: "Machine Description"
},
'computer': {
desc: "General Computer Features",
'buswidth': {
type: typeNumber,
values: [20, 24, 32]
},
'resume': {
type: typeNumber,
value: [0, 1, 2],
descs: ["Resume Disabled", "Resume Enabled", "Resume with Prompt"]
}
},
'ram': {
desc: "Read-Write Memory (Conventional or Extended)",
'addr': {
type: typeAddress
},
'size': {
type: typeNumber
}
},
'rom': {
desc: "Read-Only Memory",
'addr': {
type: typeAddress
},
'size': {
type: typeNumber
},
'file': {
type: typePath
}
}
};
/**
* buildPC(idElement)
*
* @param {string} idElement (the ID of the DIV where build UI options should be presented)
*/
function buildPC(idElement)
{
alert("build.js loaded: " + idElement);
}

View file

@ -5379,7 +5379,7 @@ ChipSet.aPortOutput5170 = {
*/
ChipSet.init = function()
{
var aeChipSet = Component.getElementsByClass(window.document, PCJSCLASS, "chipset");
var aeChipSet = Component.getElementsByClass(document, PCJSCLASS, "chipset");
for (var iChip = 0; iChip < aeChipSet.length; iChip++) {
var eChipSet = aeChipSet[iChip];
var parmsChipSet = Component.getComponentParms(eChipSet);

View file

@ -344,7 +344,7 @@ Computer.prototype.getMachineID = function()
*
* @param {string} sParm
* @param {Object} [parmsComponent]
* @return {Object|number|string|boolean|null|undefined}
* @return {string|null}
*/
Computer.prototype.getMachineParm = function(sParm, parmsComponent)
{
@ -1371,7 +1371,7 @@ Computer.init = function()
*/
if (!COMPILED && XMLVERSION) Computer.APPVERSION = XMLVERSION;
var aeMachines = Component.getElementsByClass(window.document, PCJSCLASS + "-machine");
var aeMachines = Component.getElementsByClass(document, PCJSCLASS + "-machine");
for (var iMachine = 0; iMachine < aeMachines.length; iMachine++) {
@ -1421,7 +1421,7 @@ Computer.init = function()
*/
Computer.show = function()
{
var aeComputers = Component.getElementsByClass(window.document, PCJSCLASS, "computer");
var aeComputers = Component.getElementsByClass(document, PCJSCLASS, "computer");
for (var iComputer = 0; iComputer < aeComputers.length; iComputer++) {
var eComputer = aeComputers[iComputer];
var parmsComputer = Component.getComponentParms(eComputer);
@ -1470,7 +1470,7 @@ Computer.show = function()
*/
Computer.exit = function()
{
var aeComputers = Component.getElementsByClass(window.document, PCJSCLASS, "computer");
var aeComputers = Component.getElementsByClass(document, PCJSCLASS, "computer");
for (var iComputer = 0; iComputer < aeComputers.length; iComputer++) {
var eComputer = aeComputers[iComputer];
var parmsComputer = Component.getComponentParms(eComputer);

View file

@ -8131,7 +8131,7 @@ if (DEBUGGER) {
*/
Debugger.init = function()
{
var aeDbg = Component.getElementsByClass(window.document, PCJSCLASS, "debugger");
var aeDbg = Component.getElementsByClass(document, PCJSCLASS, "debugger");
for (var iDbg = 0; iDbg < aeDbg.length; iDbg++) {
var eDbg = aeDbg[iDbg];
var parmsDbg = Component.getComponentParms(eDbg);

View file

@ -592,7 +592,7 @@ FDC.prototype.powerUp = function(data, fRepower)
}
controlDrives.textContent = "";
for (var iDrive = 0; iDrive < this.nDrives; iDrive++) {
var controlOption = window.document.createElement("option");
var controlOption = document.createElement("option");
controlOption['value'] = iDrive;
/*
* TODO: This conversion of drive number to drive letter, starting with A:, is very simplistic
@ -1416,7 +1416,7 @@ FDC.prototype.addDiskette = function(sName, sPath)
for (var i = 0; i < controlDisks.options.length; i++) {
if (controlDisks.options[i].value == sPath) return;
}
var controlOption = window.document.createElement("option");
var controlOption = document.createElement("option");
controlOption['value'] = sPath;
controlOption.textContent = sName;
controlDisks.appendChild(controlOption);
@ -2518,7 +2518,7 @@ FDC.aPortOutput = {
* any associated HTML controls to the new component.
*/
FDC.init = function() {
var aeFDC = Component.getElementsByClass(window.document, PCJSCLASS, "fdc");
var aeFDC = Component.getElementsByClass(document, PCJSCLASS, "fdc");
for (var iFDC = 0; iFDC < aeFDC.length; iFDC++) {
var eFDC = aeFDC[iFDC];
var parmsFDC = Component.getComponentParms(eFDC);

View file

@ -3001,7 +3001,7 @@ HDC.aATCPortOutput = {
*/
HDC.init = function()
{
var aeHDC = Component.getElementsByClass(window.document, PCJSCLASS, "hdc");
var aeHDC = Component.getElementsByClass(document, PCJSCLASS, "hdc");
for (var iHDC = 0; iHDC < aeHDC.length; iHDC++) {
var eHDC = aeHDC[iHDC];
var parmsHDC = Component.getComponentParms(eHDC);

View file

@ -2312,7 +2312,7 @@ Keyboard.prototype.keySimulate = function(simCode, fDown)
*/
Keyboard.init = function()
{
var aeKbd = Component.getElementsByClass(window.document, PCJSCLASS, "keyboard");
var aeKbd = Component.getElementsByClass(document, PCJSCLASS, "keyboard");
for (var iKbd = 0; iKbd < aeKbd.length; iKbd++) {
var eKbd = aeKbd[iKbd];
var parmsKbd = Component.getComponentParms(eKbd);

View file

@ -717,7 +717,7 @@ Mouse.prototype.notifyMCR = function(bMCR)
*/
Mouse.init = function()
{
var aeMouse = Component.getElementsByClass(window.document, PCJSCLASS, "mouse");
var aeMouse = Component.getElementsByClass(document, PCJSCLASS, "mouse");
for (var iMouse = 0; iMouse < aeMouse.length; iMouse++) {
var eMouse = aeMouse[iMouse];
var parmsMouse = Component.getComponentParms(eMouse);

View file

@ -294,13 +294,13 @@ Panel.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
this.cxDump = this.cxReg;
this.cyDump = ((this.canvas.height * Panel.LIVEDUMP.CY) / Panel.LIVECANVAS.CY) | 0;
this.canvasLiveMem = window.document.createElement("canvas");
this.canvasLiveMem = document.createElement("canvas");
this.canvasLiveMem.width = Panel.LIVEMEM.CX;
this.canvasLiveMem.height = Panel.LIVEMEM.CY;
this.contextLiveMem = this.canvasLiveMem.getContext("2d");
this.imageLiveMem = this.contextLiveMem.createImageData(this.canvasLiveMem.width, this.canvasLiveMem.height);
this.canvasLiveRegs = window.document.createElement("canvas");
this.canvasLiveRegs = document.createElement("canvas");
this.canvasLiveRegs.width = Panel.LIVEREGS.CX;
this.canvasLiveRegs.height = Panel.LIVEREGS.CY;
this.contextLiveRegs = this.canvasLiveRegs.getContext("2d");
@ -969,7 +969,7 @@ Panel.prototype.centerText = function(sText)
Panel.init = function()
{
var fReady = false;
var aePanels = Component.getElementsByClass(window.document, PCJSCLASS, "panel");
var aePanels = Component.getElementsByClass(document, PCJSCLASS, "panel");
for (var iPanel=0; iPanel < aePanels.length; iPanel++) {
var ePanel = aePanels[iPanel];
var parmsPanel = Component.getComponentParms(ePanel);

View file

@ -503,7 +503,7 @@ ParallelPort.aPortOutput = {
*/
ParallelPort.init = function()
{
var aeParallel = Component.getElementsByClass(window.document, PCJSCLASS, "parallel");
var aeParallel = Component.getElementsByClass(document, PCJSCLASS, "parallel");
for (var iParallel = 0; iParallel < aeParallel.length; iParallel++) {
var eParallel = aeParallel[iParallel];
var parmsParallel = Component.getComponentParms(eParallel);

View file

@ -266,7 +266,7 @@ RAM.prototype.restore = function(data)
*/
RAM.init = function()
{
var aeRAM = Component.getElementsByClass(window.document, PCJSCLASS, "ram");
var aeRAM = Component.getElementsByClass(document, PCJSCLASS, "ram");
for (var iRAM = 0; iRAM < aeRAM.length; iRAM++) {
var eRAM = aeRAM[iRAM];
var parmsRAM = Component.getComponentParms(eRAM);

View file

@ -405,7 +405,7 @@ ROM.prototype.cloneROM = function(addr)
*/
ROM.init = function()
{
var aeROM = Component.getElementsByClass(window.document, PCJSCLASS, "rom");
var aeROM = Component.getElementsByClass(document, PCJSCLASS, "rom");
for (var iROM = 0; iROM < aeROM.length; iROM++) {
var eROM = aeROM[iROM];
var parmsROM = Component.getComponentParms(eROM);

View file

@ -897,7 +897,7 @@ SerialPort.aPortOutput = {
*/
SerialPort.init = function()
{
var aeSerial = Component.getElementsByClass(window.document, PCJSCLASS, "serial");
var aeSerial = Component.getElementsByClass(document, PCJSCLASS, "serial");
for (var iSerial = 0; iSerial < aeSerial.length; iSerial++) {
var eSerial = aeSerial[iSerial];
var parmsSerial = Component.getComponentParms(eSerial);

View file

@ -3232,7 +3232,7 @@ Video.prototype.onFocusChange = function(fFocus)
*
* if (fFocus) {
* window.scrollTo(0, 0);
* window.document.body.scrollTop = 0;
* document.body.scrollTop = 0;
* }
*/
this.fHasFocus = fFocus;
@ -4221,7 +4221,7 @@ Video.prototype.createFontColor = function(font, iColor, rgbColor, nDouble, offD
* We still have to use putImageData() to build the font canvas, but that's a one-time operation.
*/
var rgbOff = [0x00, 0x00, 0x00, 0x00];
var canvasFont = window.document.createElement("canvas");
var canvasFont = document.createElement("canvas");
canvasFont.width = font.cxCell << 4;
canvasFont.height = (font.cyCell << 4);
var contextFont = canvasFont.getContext("2d");
@ -4780,7 +4780,7 @@ Video.prototype.setDimensions = function()
* Allocate the off-screen buffers
*/
this.imageScreenBuffer = this.contextScreen.createImageData(this.cxBuffer, this.cyBuffer);
this.canvasScreenBuffer = window.document.createElement("canvas");
this.canvasScreenBuffer = document.createElement("canvas");
this.canvasScreenBuffer.width = this.cxBuffer;
this.canvasScreenBuffer.height = this.cyBuffer;
this.contextScreenBuffer = this.canvasScreenBuffer.getContext("2d");
@ -7116,12 +7116,12 @@ Video.aVGAPortOutput = {
*/
Video.init = function()
{
var aeVideo = Component.getElementsByClass(window.document, PCJSCLASS, "video");
var aeVideo = Component.getElementsByClass(document, PCJSCLASS, "video");
for (var iVideo = 0; iVideo < aeVideo.length; iVideo++) {
var eVideo = aeVideo[iVideo];
var parmsVideo = Component.getComponentParms(eVideo);
var eCanvas = window.document.createElement("canvas");
var eCanvas = document.createElement("canvas");
if (eCanvas === undefined || !eCanvas.getContext) {
eVideo.innerHTML = "<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";
return;
@ -7176,14 +7176,14 @@ Video.init = function()
* clearly see the overlaid semi-transparent input field, but none of the input characters were passed along,
* with the exception of the "Go" (Enter) key.
*
* var eInput = window.document.createElement("input");
* var eInput = document.createElement("input");
* eInput.setAttribute("type", "password");
* eInput.setAttribute("style", "position:absolute; left:0; top:0; width:100%; height:100%; opacity:0.5");
* eVideo.appendChild(eInput);
*
* See this Chromium issue for more information: https://code.google.com/p/chromium/issues/detail?id=118639
*/
var eTextArea = window.document.createElement("textarea");
var eTextArea = document.createElement("textarea");
/*
* As noted in keyboard.js, the keyboard on an iOS device tends to pop up with the SHIFT key depressed,

View file

@ -4358,7 +4358,7 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
*/
X86CPU.init = function()
{
var aeCPUs = Component.getElementsByClass(window.document, PCJSCLASS, "cpu");
var aeCPUs = Component.getElementsByClass(document, PCJSCLASS, "cpu");
for (var iCPU = 0; iCPU < aeCPUs.length; iCPU++) {
var eCPU = aeCPUs[iCPU];
var parmsCPU = Component.getComponentParms(eCPU);

View file

@ -3363,7 +3363,7 @@ X86FPU.afnPreserveExceptions = [
*/
X86FPU.init = function()
{
var aeFPUs = Component.getElementsByClass(window.document, PCJSCLASS, "fpu");
var aeFPUs = Component.getElementsByClass(document, PCJSCLASS, "fpu");
for (var iFPU = 0; iFPU < aeFPUs.length; iFPU++) {
var eFPU = aeFPUs[iFPU];
var parmsFPU = Component.getComponentParms(eFPU);

View file

@ -51,7 +51,7 @@
"use strict";
/* global window: true, DEBUG: true */
/* global document: true, window: true, DEBUG: true */
if (NODE) {
require("./defines");
@ -494,7 +494,7 @@ Component.bindExternalControl = function(component, sControl, sBinding, sType)
}
};
if (window && !window.document.ELEMENT_NODE) window.document.ELEMENT_NODE = 1;
if (document && !document.ELEMENT_NODE) document.ELEMENT_NODE = 1;
/**
* Component.bindComponentControls(component, element, sAppClass)
@ -513,7 +513,7 @@ Component.bindComponentControls = function(component, element, sAppClass)
for (var iNode = 0; iNode < aeChildNodes.length; iNode++) {
var control = aeChildNodes[iNode];
if (control.nodeType !== window.document.ELEMENT_NODE) {
if (control.nodeType !== document.ELEMENT_NODE) {
continue;
}
var sClass = control.getAttribute("class");

View file

@ -32,7 +32,7 @@
"use strict";
/* global window: true, XSLTProcessor: false, APPNAME: false, APPVERSION: false, DEBUG: true */
/* global document: true, window: true, XSLTProcessor: false, APPNAME: false, APPVERSION: false, DEBUG: true */
if (NODE) {
var Component;
@ -189,11 +189,13 @@ function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
* 'ActiveXObject' crud has gone away; but of course, this code must remain in place if
* we want to continue supporting older Internet Explorer browsers (ie, back to IE9).
*/
/** @namespace window.ActiveXObject */
if (window.ActiveXObject || 'ActiveXObject' in window) { // second test is required for IE11 on Windows 8.1
xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc['loadXML'](sXML);
} else {
/** @namespace window.DOMParser */
xmlDoc = (new window.DOMParser()).parseFromString(sXML, "text/xml");
}
} catch(e) {
@ -356,7 +358,7 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sParms)
};
try {
eMachine = window.document.getElementById(idElement);
eMachine = document.getElementById(idElement);
if (eMachine) {
var sAppClass = sName.toLowerCase(); // eg, "pcjs" or "c1pjs"
if (!sXSLFile) {
@ -420,10 +422,10 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sParms)
displayError("transformNodeToObject failed");
}
}
else if (window.document.implementation && window.document.implementation.createDocument) {
else if (document.implementation && document.implementation.createDocument) {
var xsltProcessor = new XSLTProcessor();
xsltProcessor['importStylesheet'](xsl);
var eFragment = xsltProcessor['transformToFragment'](xml, window.document);
var eFragment = xsltProcessor['transformToFragment'](xml, document);
if (eFragment) {
/*
* This fails in Microsoft Edge...