Setting the stage for a resource status update mechanism

This commit is contained in:
Jeff Parsons 2017-06-27 16:01:00 -07:00 committed by Jeff Parsons
commit 2cb0be42f0
36 changed files with 872 additions and 773 deletions

View file

@ -147,7 +147,7 @@ class C1PComputer extends Component {
* @this {C1PComputer}
* @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, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -516,7 +516,7 @@ class C1PCPU extends Component {
* @this {C1PCPU}
* @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, "run")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -497,7 +497,7 @@ class C1PDebugger extends Component {
* @this {C1PDebugger}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -667,7 +667,7 @@ class C1PDiskController extends Component {
* @this {C1PDiskController}
* @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, "listDisk")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -398,7 +398,7 @@ class C1PKeyboard extends Component {
* @this {C1PKeyboard}
* @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, "esc", "ctrl-c")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -64,7 +64,7 @@ class C1PPanel extends Component {
* @this {C1PPanel}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

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 {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/
@ -148,7 +148,7 @@ class C1PSerialPort extends Component {
submit.disabled = !files.length;
});
control.onsubmit = function(event) {
control.addEventListener('submit', function(event) {
var file = event.currentTarget[1].files[0];
var reader = new FileReader();
@ -162,7 +162,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");

View file

@ -121,9 +121,9 @@ class C1PVideo extends Component {
*
* @this {C1PVideo}
* @param {Object} parmsVideo
* @param {Object} canvas
* @param {Object} context
* @param {Object} imgChars
* @param {HTMLCanvasElement} canvas
* @param {CanvasRenderingContext2D} context
* @param {HTMLImageElement} imgChars
*/
constructor(parmsVideo, canvas, context, imgChars)
{
@ -218,7 +218,7 @@ class C1PVideo extends Component {
* @this {C1PVideo}
* @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, "refresh")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/
@ -580,7 +580,7 @@ class C1PVideo extends Component {
* 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 = document.createElement("canvas");
var eCanvas = /** @type {HTMLCanvasElement} */ (document.createElement("canvas"));
if (eCanvas === undefined || !eCanvas.getContext) {
eVideo.innerHTML = "<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";
return;
@ -619,7 +619,7 @@ class C1PVideo extends Component {
* document.createElement('img') would.
*/
var imgCharSet = new Image();
var eContext = eCanvas.getContext("2d");
var eContext = /** @type {CanvasRenderingContext2D} */ (eCanvas.getContext("2d"));
var video = new C1PVideo(parmsVideo, eCanvas, eContext, imgCharSet);
imgCharSet.onload = function(video, sCharSet) {
return function() {

View file

@ -68,7 +68,7 @@ class Panel8080 extends Component {
* @this {Panel8080}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -312,6 +312,7 @@ class Computer extends Component {
/**
* getMachineID()
*
* @this {Computer}
* @return {string}
*/
getMachineID()
@ -324,6 +325,7 @@ class Computer extends Component {
*
* If no explicit machine parms were provided, then we check for 'parms' in the bundled resources (if any).
*
* @this {Computer}
* @param {Object} [parmsMachine]
*/
setMachineParms(parmsMachine)
@ -351,6 +353,7 @@ class Computer extends Component {
* 'state' back to the caller (ie, the name of the resource), so that the caller will then attempt to load the 'state'
* resource to obtain the actual state.
*
* @this {Computer}
* @param {string} sParm
* @param {Object} [parmsComponent]
* @return {string|undefined}
@ -374,6 +377,7 @@ class Computer extends Component {
/**
* saveMachineParms()
*
* @this {Computer}
* @return {string|null}
*/
saveMachineParms()
@ -384,6 +388,7 @@ class Computer extends Component {
/**
* getUserID()
*
* @this {Computer}
* @return {string}
*/
getUserID()
@ -391,6 +396,28 @@ class Computer extends Component {
return this.sUserID || "";
}
/**
* setResourceStatus(sMessage)
*
* @this {Computer}
* @param {string} sMessage
*/
setResourceStatus(sMessage)
{
// var video = this.aVideo[0];
// if (video) {
// var eTextArea = video.getTextArea();
// if (eTextArea) {
// eTextArea.style.opacity = "1";
// eTextArea.style.color = "#ffffff";
// eTextArea.style.lineHeight = "1";
// eTextArea.style.fontSize = "large";
// eTextArea.style.background = "rgba(0, 0, 0, .5)";
// eTextArea.value = sMessage;
// }
// }
}
/**
* doneLoad(sURL, sStateData, nErrorCode)
*
@ -1152,6 +1179,8 @@ class Computer extends Component {
/**
* resetUserID()
*
* @this {Computer}
*/
resetUserID()
{
@ -1162,6 +1191,7 @@ class Computer extends Component {
/**
* queryUserID(fPrompt)
*
* @this {Computer}
* @param {boolean} [fPrompt]
* @returns {string|null|undefined}
*/
@ -1250,6 +1280,7 @@ class Computer extends Component {
/**
* saveServerState(sUserID, sState)
*
* @this {Computer}
* @param {string} sUserID
* @param {string|null} sState
*/

View file

@ -226,7 +226,7 @@ class Panel extends Component {
* @this {Panel}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/
@ -247,8 +247,8 @@ class Panel extends Component {
}
if (fPanel) {
this.canvas = control;
this.context = this.canvas.getContext("2d");
this.canvas = /** @type {HTMLCanvasElement} */ (control);
this.context = /** @type {CanvasRenderingContext2D} */ (this.canvas.getContext("2d"));
/*
* Employ the same gross onresize() hack for IE9/IE10 that we had to use for the Video canvas
@ -259,7 +259,7 @@ class Panel extends Component {
canvas.style.height = (((canvas.clientWidth * cy) / cx) | 0) + "px";
};
}(this.canvas, this.canvas.width, this.canvas.height);
this.canvas.onresize();
this.canvas.onresize(null);
}
this.xMem = this.yMem = 0;

View file

@ -85,7 +85,6 @@ class ROM extends Component {
* Most ROMs are not aliased, in which case the 'alias' property should have the default value of null.
*/
this.addrAlias = parmsROM['alias'];
this.sFilePath = parmsROM['file'];
/*
* The 'notify' property can now (as of v1.18.2) contain an array of parameters that the notified
@ -107,10 +106,12 @@ class ROM extends Component {
this.idNotify = this.idNotify.substr(0, i);
}
}
if (this.sFilePath) {
var sFileURL = this.sFilePath;
var sFileName = Str.getBaseName(sFileURL);
if (DEBUG) this.log('load("' + sFileURL + '")');
this.sFileURL = this.sFilePath = parmsROM['file'];
if (this.sFileURL) {
var sFileName = Str.getBaseName(this.sFileURL);
if (DEBUG) this.log('load("' + this.sFileURL + '")');
/*
* If the selected ROM file has a ".json" extension, then we assume it's pre-converted
* JSON-encoded ROM data, so we load it as-is; ditto for ROM files with a ".hex" extension.
@ -118,12 +119,8 @@ class ROM extends Component {
*/
var sFileExt = Str.getExtension(sFileName);
if (sFileExt != DumpAPI.FORMAT.JSON && sFileExt != DumpAPI.FORMAT.HEX) {
sFileURL = Web.getHost() + DumpAPI.ENDPOINT + '?' + DumpAPI.QUERY.FILE + '=' + this.sFilePath + '&' + DumpAPI.QUERY.FORMAT + '=' + DumpAPI.FORMAT.BYTES + '&' + DumpAPI.QUERY.DECIMAL + '=true';
this.sFileURL = Web.getHost() + DumpAPI.ENDPOINT + '?' + DumpAPI.QUERY.FILE + '=' + this.sFilePath + '&' + DumpAPI.QUERY.FORMAT + '=' + DumpAPI.FORMAT.BYTES + '&' + DumpAPI.QUERY.DECIMAL + '=true';
}
var rom = this;
Web.getResource(sFileURL, null, true, function(sURL, sResponse, nErrorCode) {
rom.doneLoad(sURL, sResponse, nErrorCode);
});
}
}
@ -138,10 +135,17 @@ class ROM extends Component {
*/
initBus(cmp, bus, cpu, dbg)
{
var rom = this;
this.cmp = cmp;
this.bus = bus;
this.cpu = cpu;
this.dbg = dbg;
this.copyROM();
if (this.sFileURL) {
this.cmp.setResourceStatus(this.sFileURL);
Web.getResource(this.sFileURL, null, true, function(sURL, sResponse, nErrorCode) {
rom.doneLoad(sURL, sResponse, nErrorCode);
});
}
}
/**

View file

@ -2171,10 +2171,10 @@ class Video extends Component {
*
* @this {Video}
* @param {Object} parmsVideo
* @param {Object} [canvas]
* @param {Object} [context]
* @param {Object} [textarea]
* @param {Object} [container]
* @param {HTMLCanvasElement} [canvas]
* @param {CanvasRenderingContext2D} [context]
* @param {HTMLTextAreaElement} [textarea]
* @param {HTMLElement} [container]
*/
constructor(parmsVideo, canvas, context, textarea, container)
{
@ -2231,7 +2231,7 @@ class Video extends Component {
this.canvasScreen = canvas;
this.contextScreen = context;
this.textareaScreen = textarea;
this.inputTextArea = textarea;
this.inputScreen = textarea || canvas || null;
/*
@ -2472,7 +2472,7 @@ class Video extends Component {
for (var s in this.bindings) {
if (s.indexOf("lock") > 0) this.kbd.setBinding("led", s, this.bindings[s]);
}
this.kbd.setBinding(this.textareaScreen? "textarea" : "canvas", "screen", this.inputScreen);
this.kbd.setBinding(this.inputTextArea? "textarea" : "canvas", "screen", this.inputScreen);
}
this.bEGASwitches = 0x09; // our default "switches" setting (see aEGAMonitorSwitches)
@ -2587,6 +2587,19 @@ class Video extends Component {
return this.inputScreen;
}
/**
* getTextArea()
*
* This is an interface used by the Computer component, so that it can display resource status messages.
*
* @this {Video}
* @return {HTMLTextAreaElement|undefined}
*/
getTextArea()
{
return this.inputTextArea;
}
/**
* doFullScreen()
*
@ -6691,7 +6704,7 @@ class Video extends Component {
var eVideo = aeVideo[iVideo];
var parmsVideo = Component.getComponentParms(eVideo);
var eCanvas = document.createElement("canvas");
var eCanvas = /** @type {HTMLCanvasElement} */ (document.createElement("canvas"));
if (eCanvas === undefined || !eCanvas.getContext) {
eVideo.innerHTML = "<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";
return;
@ -6724,7 +6737,7 @@ class Video extends Component {
eChild.style.height = (((eParent.clientWidth * cy) / cx) | 0) + "px";
};
}(eVideo, eCanvas, parmsVideo['screenWidth'], parmsVideo['screenHeight']);
eVideo.onresize();
eVideo.onresize(null);
}
/*
* The following is a related hack that allows the user to force the screen to use a particular aspect
@ -6787,7 +6800,7 @@ class Video extends Component {
*
* See this Chromium issue for more information: https://code.google.com/p/chromium/issues/detail?id=118639
*/
var eTextArea = document.createElement("textarea");
var eTextArea = /** @type {HTMLTextAreaElement} */ (document.createElement("textarea"));
/*
* As noted in keyboard.js, the keyboard on an iOS device tends to pop up with the SHIFT key depressed,
@ -6812,7 +6825,7 @@ class Video extends Component {
/*
* Now we can create the Video object, record it, and wire it up to the associated document elements.
*/
var eContext = eCanvas.getContext("2d");
var eContext = /** @type {CanvasRenderingContext2D} */ (eCanvas.getContext("2d"));
var video = new Video(parmsVideo, eCanvas, eContext, eTextArea /* || eInput */, eVideo);
/*

View file

@ -306,7 +306,7 @@ class PanelPDP10 extends Component {
* @this {PanelPDP10}
* @param {string|null} sType is the type of the HTML control (eg, "button", "textarea", "register", "flag", "rled", etc)
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -310,7 +310,7 @@ class PanelPDP11 extends Component {
* @this {PanelPDP11}
* @param {string|null} sType is the type of the HTML control (eg, "button", "textarea", "register", "flag", "rled", etc)
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -491,7 +491,7 @@ class Component {
/**
* Component.getComponentParms(element)
*
* @param {Object} element from the DOM
* @param {HTMLElement} element from the DOM
*/
static getComponentParms(element)
{
@ -541,7 +541,7 @@ class Component {
* Component.bindComponentControls(component, element, sAppClass)
*
* @param {Component} component
* @param {Object} element from the DOM
* @param {HTMLElement} element from the DOM
* @param {string} sAppClass
*/
static bindComponentControls(component, element, sAppClass)
@ -590,7 +590,7 @@ class Component {
* TODO: This should probably be moved into weblib.js at some point, along with the control binding functions above,
* to keep all the browser-related code together.
*
* @param {Object} element from the DOM
* @param {HTMLDocument|HTMLElement|Node} element from the DOM
* @param {string} sClass
* @param {string} [sObjClass]
* @return {Array|NodeList}
@ -883,7 +883,7 @@ class Component {
* @this {Component}
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
* @param {HTMLElement} 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
*/

View file

@ -212,6 +212,7 @@
opacity: 0;
border: 0;
padding: 0;
resize: none;
line-height: 0; /* try to prevent Safari on iOS from always displaying a blinking cursor */
}
.pcjs-reference {