Added support for (attempting to) suppress alerts that are meaningless if the user has aborted a machine by exiting the page before it was done loading

This commit is contained in:
Jeff Parsons 2017-06-22 15:53:34 -07:00 committed by Jeff Parsons
commit 1ce03810d3
32 changed files with 1827 additions and 1591 deletions

View file

@ -1543,6 +1543,8 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1597,6 +1599,11 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1571,6 +1571,8 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1620,6 +1622,11 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1539,6 +1539,8 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1593,6 +1595,11 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1543,6 +1543,8 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1597,6 +1599,11 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -134,6 +134,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -852,7 +853,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -862,7 +864,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -884,7 +887,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -957,7 +961,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -978,7 +983,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -1025,7 +1031,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -1037,7 +1044,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -1053,7 +1061,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -1065,7 +1084,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -1089,7 +1109,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -1110,7 +1131,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -1130,7 +1152,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -1151,7 +1174,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -1171,7 +1195,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -1193,7 +1218,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -1206,7 +1232,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -1220,7 +1247,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -1244,7 +1272,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -1266,7 +1295,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;