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

@ -28,15 +28,15 @@ function w(a,b){var c=!0,c=void 0===c?!1:c,d=0,e=null;if("object"==typeof resour
a,c);g.send();c||(e=g.responseText,200!=g.status&&(d=g.status||-1),b&&b(a,e,d))}}function x(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function ma(a,b,c){function d(){--a;0<=a&&(b()||(a=0));0<a?setTimeout(d,0):c()}d()}
function na(a,b){function c(){b(100===d)&&(e=setTimeout(c,d),d=100)}var d=0,e=null,g=!1;a.onmousedown=function(){g||e||(d=500,c())};a.ontouchstart=function(){e||(d=500,c())};a.onmouseup=a.onmouseout=function(){e&&(clearTimeout(e),e=null)};a.ontouchend=a.ontouchcancel=function(){e&&(clearTimeout(e),e=null);g=!0}}function oa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function y(a){z.init.push(a)}
function pa(a){if(qa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){A(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function B(a){!qa&&a?(qa=!0,ra&&sa("init"),ta&&sa("show")):qa=a}function sa(a){z[a]&&pa(z[a])}var ua=null,z={init:[],show:[],exit:[]},ra=!1,ta=!1,qa=!0;oa("onload",function(){ra=!0;pa(z.init)});oa("onpageshow",function(){ta=!0;pa(z.show)});oa(x("Opera")||x("iOS")?"onunload":"onbeforeunload",function(){pa(z.exit)});
function C(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.exports={};this.H=this.bindings={};a=this.id.indexOf(".");0>a?this.fb=this.id:(this.nb=this.id.substr(0,a),this.fb=this.id.substr(a+1));this.C={ready:!1,Ga:!1,bb:!1,N:!1,error:!1};this.eb=null;this.C.error=!1;this.ma=c||0;this.u=this.s=this.U=this.Sa=null;D.push(this)}function A(a){window&&window.alert(a)}
function C(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.exports={};this.H=this.bindings={};a=this.id.indexOf(".");0>a?this.fb=this.id:(this.nb=this.id.substr(0,a),this.fb=this.id.substr(a+1));this.C={ready:!1,Ga:!1,bb:!1,N:!1,Pe:!1,error:!1};this.eb=null;this.C.error=!1;this.ma=c||0;this.u=this.s=this.U=this.Sa=null;D.push(this)}function A(a){window&&window.alert(a)}
function va(a,b){if(void 0!==a){var c;b&&0<(c=b.indexOf("."))&&(a=b.substr(0,c+1)+a);for(c=0;c<D.length;c++)if(D[c].id===a)return D[c]}return null}function wa(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<D.length;d++)if(c)c==D[d]&&(c=null);else if(!(a!=D[d].type||b&&D[d].id.indexOf(b)))return D[d]}return null}function E(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){A(c.message+" ("+a+")")}return b}
function F(a,b){b=G(b.parentNode,"c1pjs-control");for(var c=0;c<b.length;c++)for(var d=b[c].childNodes,e=0;e<d.length;e++){var g=d[e];if(1===g.nodeType){var h=g.getAttribute("class");if(h)for(var l=h.split(" "),k=0;k<l.length;k++)switch(h=l[k],h){case "c1pjs-binding":(h=E(g))&&h.binding&&a.T(h.type,h.binding,g,h.value),k=l.length}}}}
function G(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
function xa(a){for(var b=!0,c=ya[a];c&&c.length;){var d=c.splice(0,1)[0],e=d[0],g=null;0<=za.indexOf(e)&&(g=function(){return function(){xa(a)}}());var h=Aa[e];if(h)if(!g)b=h(d[1],d[2],d[3]);else{if(!h(g,d[1],d[2],d[3]))break}else{var b=!1,l=wa(d[1],a);if(l)if(h=Ba[e])b=h(l,d[2],d[3]);else{var k=l.exports;if(k&&(h=k[e]))if(b=!0,!g)b=h.call(l,d[2],d[3]);else if(!h.call(l,g,d[2],d[3]))break}}if(!b){A("Script error: "+e+(h?" failed":" unrecognized"));break}}c&&!c.length&&delete ya[a];return b}f=C.prototype;
f.toString=function(){return this.name?this.name:this.id||this.type};
f.T=function(a,b,c){switch(b){case "clear":return this.H[b]||(this.H[b]=c,c.onclick=function(a){return function(){a.H.print&&(a.H.print.value="")}}(this)),!0;case "print":return this.H[b]||(this.Sa=this.H[b]=c,c.value="",this.l=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),this.Wa=function(a){this.l(a,this.fb)}),!0;default:return!1}};f.log=function(){};f.l=function(){};
f.status=function(a){this.l(this.fb+": "+a)};f.Wa=function(a,b,c){c=c||this.type;b||A((c?c+": ":"")+a)};function Ca(a,b){a.C.error=!0;a.Wa(b)}function H(a,b){b&&(a.C.ready?b():a.eb=b);return a.C.ready}f.X=function(a){this.C.error||(this.C.ready=!1!==a,this.C.ready&&(a=this.eb,this.eb=null,a&&a()))};function I(a,b){a.C.Ga&&(b?a.C.bb=!0:void 0===b&&a.l(a.toString()+" busy"));return a.C.Ga}
function J(a,b){if(a.C.bb)return a.C.Ga=!1,a.C.bb=!1;if(a.C.error)return a.l(a.toString()+" error"),!1;a.C.Ga=b;return a.C.Ga}function K(a,b){if(a.u){a===a.u?b|=0:b=b||a.ma;var c=a.u.ma&b;return!!b&&c===b||!!(c&a.u.Re)}return!1}window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
f.status=function(a){this.l(this.fb+": "+a)};f.Wa=function(a,b,c){if(!b){var d=wa("Computer",this.id);if(d&&d.C.Pe){console.log("ignoring notice during unload: "+a);return}}c=c||this.type;b||A((c?c+": ":"")+a)};function Ca(a,b){a.C.error=!0;a.Wa(b)}function H(a,b){b&&(a.C.ready?b():a.eb=b);return a.C.ready}f.X=function(a){this.C.error||(this.C.ready=!1!==a,this.C.ready&&(a=this.eb,this.eb=null,a&&a()))};function I(a,b){a.C.Ga&&(b?a.C.bb=!0:void 0===b&&a.l(a.toString()+" busy"));return a.C.Ga}
function J(a,b){if(a.C.bb)return a.C.Ga=!1,a.C.bb=!1;if(a.C.error)return a.l(a.toString()+" error"),!1;a.C.Ga=b;return a.C.Ga}function K(a,b){if(a.u){a===a.u?b|=0:b=b||a.ma;var c=a.u.ma&b;return!!b&&c===b||!!(c&a.u.Se)}return!1}window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
var L=window?window.PCjs.Machines:{},D=window?window.PCjs.Components:[],ya=window?window.PCjs.Commands:{},za=["hold","sleep","wait"],Aa={alert:function(a){A(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},Ba={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b<a.options.length;b++)if(a.options[b].textContent==c){a.selectedIndex!=b&&(a.selectedIndex=b);d=!0;break}return d}};
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});function Da(a){C.call(this,"C1PPanel",a);this.C.N=!1}p(Da,C);
@ -53,8 +53,8 @@ f.ca=function(a,b,c){this.a=a;this.M=b;this.sa=c-b+1;this.Ca=this.M+this.sa;this
function Ka(a,b,c){for(var d=0;d<a.R.length;d++)b>=a.R[d][0]&&b<=a.R[d][1]&&a.R[d][3].call(a.R[d][2],b,c)}function O(a,b,c,d,e){0>Ja(a.K,b,c,d,e)&&(a.fa>b&&(a.fa=b),a.ja<c&&(a.ja=c),a.K.push([b,c,d,e]))}function La(a,b,c){for(var d=0;d<a.K.length;d++)b>=a.K[d][0]&&b<=a.K[d][1]&&a.K[d][3].call(a.K[d][2],b,c)}function Ja(a,b,c,d,e){for(var g=0;g<a.length;g++)if(a[g][0]==b&&a[g][1]==c&&a[g][2]==d&&a[g][3]==e)return g;return-1}
function N(a,b,c){void 0!==b&&(a.I=b,a.H.setSpeed&&(a.H.setSpeed.innerHTML=a.Ua[2<=b?0:b+1]),a.l("running at "+a.Ua[b].toLowerCase()+" speed "+a.jb[b]),c&&a.da());a.W=0;a.Xa=la();Ma(a)}f.cb=function(){};f.da=function(){};function P(a,b,c,d){void 0!==a.H[b]&&(void 0===d&&(d=1),c="0000"+c.toString(16),a.H[b].innerHTML=c.slice(c.length-d).toUpperCase())}
function Na(a){P(a,"A",a.h,2);P(a,"X",a.w,2);P(a,"Y",a.F,2);var b=Oa(a);P(a,"C",b&1?1:0);P(a,"Z",b&2?1:0);P(a,"I",b&4?1:0);P(a,"D",b&8?1:0);P(a,"B",b&16?1:0);P(a,"V",b&64?1:0);P(a,"N",b&128?1:0);P(a,"S",a.G,4);P(a,"PC",a.f,4);a.H.speed&&a.L&&(a.H.speed.innerHTML=a.L.toFixed(1)+"Mhz")}
function Ma(a,b){var c=30;c<a.La&&(c=a.La);c<a.Ka&&(c=a.Ka);var d=1;b&&a.I>a.Pa&&a.L&&(d=a.L);d>a.Ea&&2>a.I&&(d=a.Ea);a.Pe=Math.round(1E3/30);a.ka=Math.floor(1E6/c*d);a.Ha=Math.floor(1E6/30*d);a.Za=Math.floor(1E6/a.La*d);a.Ya=Math.floor(1E6/a.Ka*d);b||(a.V=a.Ha,a.$=a.Za,a.Z=a.Ya);a.Ia=0}function Pa(a){var b=la(),c=a.Pe;a.ba&&(c=Math.round(c*a.ba/a.Ha));c-=b-a.Qe;if(b-=a.Xa)a.L=Math.round(a.W/(100*b))/10,864E5<=b&&N(a);0>c?c=0:1==a.I?a.L<=a.Ea&&(c=0):2==a.I&&(c=0);a.Ia+=a.ba;return c}
f.ua=function(){if(J(this,!0)){this.C.oa||(N(this),this.U&&this.U.start(),this.C.oa=!0,this.H.run&&(this.H.run.innerHTML="Halt"),this.da());1E6<=this.Ia&&Ma(this,!0);this.ba=0;this.Qe=la();try{do{this.step(this.ka);var a=this.O-this.D;this.W+=a;this.ba+=a;this.O=this.D=0;this.$-=this.ka;0>=this.$&&(this.$+=this.Za,this.cb());this.Z-=this.ka;0>=this.Z&&(this.Z+=this.Ya,Na(this));this.V-=this.ka;if(0>=this.V){this.V+=this.Ha;break}}while(this.C.oa)}catch(b){this.aa();this.update();J(this,!1);Ca(this,
function Ma(a,b){var c=30;c<a.La&&(c=a.La);c<a.Ka&&(c=a.Ka);var d=1;b&&a.I>a.Pa&&a.L&&(d=a.L);d>a.Ea&&2>a.I&&(d=a.Ea);a.Qe=Math.round(1E3/30);a.ka=Math.floor(1E6/c*d);a.Ha=Math.floor(1E6/30*d);a.Za=Math.floor(1E6/a.La*d);a.Ya=Math.floor(1E6/a.Ka*d);b||(a.V=a.Ha,a.$=a.Za,a.Z=a.Ya);a.Ia=0}function Pa(a){var b=la(),c=a.Qe;a.ba&&(c=Math.round(c*a.ba/a.Ha));c-=b-a.Re;if(b-=a.Xa)a.L=Math.round(a.W/(100*b))/10,864E5<=b&&N(a);0>c?c=0:1==a.I?a.L<=a.Ea&&(c=0):2==a.I&&(c=0);a.Ia+=a.ba;return c}
f.ua=function(){if(J(this,!0)){this.C.oa||(N(this),this.U&&this.U.start(),this.C.oa=!0,this.H.run&&(this.H.run.innerHTML="Halt"),this.da());1E6<=this.Ia&&Ma(this,!0);this.ba=0;this.Re=la();try{do{this.step(this.ka);var a=this.O-this.D;this.W+=a;this.ba+=a;this.O=this.D=0;this.$-=this.ka;0>=this.$&&(this.$+=this.Za,this.cb());this.Z-=this.ka;0>=this.Z&&(this.Z+=this.Ya,Na(this));this.V-=this.ka;if(0>=this.V){this.V+=this.Ha;break}}while(this.C.oa)}catch(b){this.aa();this.update();J(this,!1);Ca(this,
b.stack||b.message);return}setTimeout(function(a){return function(){a.ua()}}(this),Pa(this))}else this.update(),this.U&&this.U.stop(this.Xa,this.W)};
f.step=function(a){var b=!0;this.b=this.g=-1;var c;if(c=a&&this.u)c=this.u,c=0<c.pa.length||0<c.va.length||0<c.xa.length;this.O=this.D=a;do{a=this.a[this.f];var d;if(d=c){d=this.u;var e=a,g=!1;Qa(d,this.f,d.pa,"exec")?g=!0:(d.L++,d.B[e][1]++,d.wa[d.Ja++]=d.s.f,d.Ja>=d.wa.length&&(d.Ja=0));d=!!g}if(d){b=void 0;this.aa();break}this.f++;this.o[a].call(this);if(0<=this.b){this.b>=this.qa&&this.b<=this.ra&&Ka(this,this.b,this.f);if(d=c)d=this.u,e=!1,Qa(d,this.b,d.va,"read")&&(e=!0),d=!!e;if(d){b=!1;this.aa();
break}this.b=-1}else if(0<=this.g){this.g>=this.fa&&this.g<=this.ja&&La(this,this.g,this.f);if(d=c){d=this.u;var e=this.g,g=this.a[this.g],h=!1;(g&255)!=g&&(d.l("invalid value at "+v(e)+": "+g),h=!0);Qa(d,e,d.xa,"write")&&(h=!0);d=!!h}if(d){b=!1;this.aa();break}this.g=-1}this.D-=this.ib[a]}while(0<this.D);return b};function Ra(a){a.V=0;a.O-=a.D;a.D=0}f.aa=function(){I(this,!0);this.O-=this.D;this.D=0;this.C.oa&&(this.C.oa=!1,this.H.run&&(this.H.run.innerHTML="Run"))};
@ -135,7 +135,7 @@ f.T=function(a,b,c){var d=this;switch(b){case "listSerial":return this.H[b]=c,!0
b.name,c.result.toString(),0)};c.readAsText(b);return!1}):c.parentNode.removeChild(c),!0}return!1};f.ca=function(a,b,c,d){this.a=a;this.M=b;this.K=c-b+1;this.I=this.M+this.K;if(this.s=d)Ia(d,b,c,this,this.S),O(d,b,c,this,this.Jb);this.X()};f.ia=function(a,b){a&&!this.C.N&&(this.C.N=!0,this.U=b,this.b=M(b,"keyboard"),this.u=M(b,"debugger"))};
function mb(a,b,c,d){if(c){a.A=0;a.g=c;a.B=!0;a.o=kb;if(-1!==b.indexOf(".json",b.length-5))try{d="";var e=eval("("+c+")").bytes;for(c=0;c<e.length;c++)d+=String.fromCharCode(e[c]);a.g=d;a.B=!1}catch(g){a.l('Error processing file "'+b+'": '+g.message);return}a.U&&a.b&&a.s.C.oa?(a.l("auto-loading "+b),a.s.da(),"."!=a.g.charAt(0)?(a.o=lb,cb(a.b,"NEW\nLOAD\n")):(a.o=jb,a.U.reset(!0),cb(a.b,"ML"))):a.l(b+" ready to load")}else a.l('Error loading file "'+b+'" ('+d+")")}
f.S=function(a,b){void 0!==b&&(a&1?nb(this):this.g&&!this.A&&nb(this))};f.Jb=function(a,b){void 0!==b&&this.u&&T(this.u,this,a,b,this.u.Ke,!0)};function nb(a){if(void 0!==a.g){a.v=-1;if(a.A<a.g.length){var b=a.g.charCodeAt(a.A++)&255;a.B&&10==b&&(b=13);a.v=b}else a.g="",a.A=0,a.o==lb&&a.b&&cb(a.b," \nRUN\n"),a.o=kb;for(b=a.M+0;b<a.I;b+=2)a.a[b]=0<=a.v?ob:pb;for(b=a.M+1;b<a.I;b+=2)a.a[b]=0<=a.v?a.v:0}}var pb=0,ob=1,kb=0,lb=1,jb=2;
y(function(){for(var a=G(document,"c1pjs","serial"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new ib(d);F(d,c)}});function qb(a){C.call(this,"C1PDiskController",a);this.C.N=!1;this.reset(!0)}p(qb,C);f=qb.prototype;f.reset=function(a){rb(this);this.b=-1;a&&(this.g=[],this.g[0]={Se:0,mb:40,Nb:!0,Ba:20,na:0,Aa:-1,Ra:[]})};
y(function(){for(var a=G(document,"c1pjs","serial"),b=0;b<a.length;b++){var c=a[b],d=E(c),d=new ib(d);F(d,c)}});function qb(a){C.call(this,"C1PDiskController",a);this.C.N=!1;this.reset(!0)}p(qb,C);f=qb.prototype;f.reset=function(a){rb(this);this.b=-1;a&&(this.g=[],this.g[0]={Te:0,mb:40,Nb:!0,Ba:20,na:0,Aa:-1,Ra:[]})};
function rb(a){a.K={J:64,read:function(){},update:function(a){return function(b){void 0!==b&&(this.J=b);a.B.J&4||V(a,0,this)}}(a)};a.o={J:255,read:function(){this.update()},update:function(a){return function(b){void 0===b?b=a.o.J:sb(a,b,a.A.J);b=(b|190)&-2;if(0<=a.b&&a.g[a.b].Ra.length){var c=a.g[a.b];c.Nb&&(b&=-33);c.na||(b&=-3);10>=--c.Ba&&(0<c.Ba?(b&=-129,tb(a)):(c.Ba=100,0<=a.b&&(a.g[a.b].Aa=0,ub(a))))}this.J=b;a.B.J&4&&V(a,0,this)}}(a)};a.B={J:0,read:function(){},update:function(a){return function(b){void 0!==
b&&(this.J=b&-193);V(a,1,this);a.o.update();a.K.update()}}(a)};a.L={J:255,read:function(){},update:function(a){return function(b){void 0!==b&&(this.J=b);a.D.J&4||V(a,2,this)}}(a)};a.A={J:255,read:function(){},update:function(a){return function(b){void 0===b?b=a.A.J:sb(a,a.o.J,b);if(0<=a.b&&a.b<a.g.length){var c=a.g[a.b];c.Ra.length&&a.A.J&8&&!(b&8)&&(b&4?c.na--:c.na++,a.u&&K(a.u,a.u.Da)&&a.u.message("stepping "+(b&4?"down":"up")+" to track "+c.na),c.na>=c.mb&&(c.na=c.mb),0>c.na&&(c.na=0),c.Ba=20,
a.o.update(a.o.J|128),tb(a))}this.J=b;a.D.J&4&&V(a,2,this)}}(a)};a.D={J:0,read:function(){},update:function(a){return function(b){void 0!==b&&(this.J=b&-193);V(a,3,this);a.A.update();a.L.update()}}(a)};a.O={J:0,read:function(){},update:function(a){return function(b){void 0!==b&&(3==(b&3)&&(a.v.J=14),this.J=b);a.v.update()}}(a)};a.v={J:14,read:function(){},update:function(a){return function(b){void 0===b&&(b=a.v.J);b&=-2;0<=a.b&&0<=a.g[a.b].Aa&&(b|=1);this.J=b;V(a,16,this)}}(a)};a.I={J:0,read:function(a){return function(){ub(a)}}(a),

File diff suppressed because one or more lines are too long

View file

@ -2203,6 +2203,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -2921,7 +2922,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -2931,7 +2933,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -2953,7 +2956,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]) {
@ -3026,7 +3030,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);
}
@ -3047,7 +3052,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 : "");
@ -3094,7 +3100,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);
}
@ -3106,7 +3113,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3122,7 +3130,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);
}
@ -3134,7 +3153,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: "?
}
@ -3158,7 +3178,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;
@ -3179,7 +3200,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();
@ -3199,7 +3221,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) {
@ -3220,7 +3243,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;
@ -3240,7 +3264,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3262,7 +3287,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;
}
@ -3275,7 +3301,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;
}
@ -3289,7 +3316,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;
@ -3313,7 +3341,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);
@ -3335,7 +3364,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;

View file

@ -27,15 +27,15 @@ function ga(a){var b=a,c=a.lastIndexOf("/");0<=c&&(b=a.substr(c+1));c=b.indexOf(
function v(a,b){var c=!0,c=void 0===c?!1:c,d=0,f=null;if("object"==typeof resources&&(f=resources[a]))b&&b(a,f,d);else if(c&&"function"==typeof resources)resources(a,function(c,d){b&&b(a,c,d)});else{var g=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(g.onreadystatechange=function(){4===g.readyState&&(f=g.responseText,200==g.status||!g.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(d=g.status||-1),b&&b(a,f,d))});g.open("GET",
a,c);g.send();c||(f=g.responseText,200!=g.status&&(d=g.status||-1),b&&b(a,f,d))}}function w(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function la(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function x(a){y.init.push(a)}
function z(a){if(A)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){B(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function C(a){!A&&a?(A=!0,ma&&na("init"),oa&&na("show")):A=a}function na(a){y[a]&&z(y[a])}var pa=null,y={init:[],show:[],exit:[]},ma=!1,oa=!1,A=!0;la("onload",function(){ma=!0;z(y.init)});la("onpageshow",function(){oa=!0;z(y.show)});la(w("Opera")||w("iOS")?"onunload":"onbeforeunload",function(){z(y.exit)});
function D(a,b){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.exports={};this.B=this.bindings={};a=this.id.indexOf(".");0>a?this.va=this.id:(this.Ba=this.id.substr(0,a),this.va=this.id.substr(a+1));this.u={ready:!1,ra:!1,wa:!1,I:!1,error:!1};this.ua=null;this.u.error=!1;this.G=this.J=this.sa=null;E.push(this)}function B(a){window&&window.alert(a)}
function D(a,b){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.exports={};this.B=this.bindings={};a=this.id.indexOf(".");0>a?this.va=this.id:(this.Ba=this.id.substr(0,a),this.va=this.id.substr(a+1));this.u={ready:!1,ra:!1,wa:!1,I:!1,ce:!1,error:!1};this.ua=null;this.u.error=!1;this.G=this.J=this.sa=null;E.push(this)}function B(a){window&&window.alert(a)}
function F(a,b){if(void 0!==a){var c;b&&0<(c=b.indexOf("."))&&(a=b.substr(0,c+1)+a);for(c=0;c<E.length;c++)if(E[c].id===a)return E[c]}return null}function qa(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<E.length;d++)if(c)c==E[d]&&(c=null);else if(!(a!=E[d].type||b&&E[d].id.indexOf(b)))return E[d]}return null}function G(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){B(c.message+" ("+a+")")}return b}
function H(a,b){b=I(b.parentNode,"c1pjs-control");for(var c=0;c<b.length;c++)for(var d=b[c].childNodes,f=0;f<d.length;f++){var g=d[f];if(1===g.nodeType){var h=g.getAttribute("class");if(h)for(var l=h.split(" "),k=0;k<l.length;k++)switch(h=l[k],h){case "c1pjs-binding":(h=G(g))&&h.binding&&a.L(h.type,h.binding,g,h.value),k=l.length}}}}
function I(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var f=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)f.test(a[b].className)&&c.push(a[b]);return c}
function ra(a){for(var b=!0,c=J[a];c&&c.length;){var d=c.splice(0,1)[0],f=d[0],g=null;0<=sa.indexOf(f)&&(g=function(){return function(){ra(a)}}());var h=ta[f];if(h)if(!g)b=h(d[1],d[2],d[3]);else{if(!h(g,d[1],d[2],d[3]))break}else{var b=!1,l=qa(d[1],a);if(l)if(h=ua[f])b=h(l,d[2],d[3]);else{var k=l.exports;if(k&&(h=k[f]))if(b=!0,!g)b=h.call(l,d[2],d[3]);else if(!h.call(l,g,d[2],d[3]))break}}if(!b){B("Script error: "+f+(h?" failed":" unrecognized"));break}}c&&!c.length&&delete J[a];return b}e=D.prototype;
e.toString=function(){return this.name?this.name:this.id||this.type};
e.L=function(a,b,c){switch(b){case "clear":return this.B[b]||(this.B[b]=c,c.onclick=function(a){return function(){a.B.print&&(a.B.print.value="")}}(this)),!0;case "print":return this.B[b]||(this.sa=this.B[b]=c,c.value="",this.F=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),this.ta=function(a){this.F(a,this.va)}),!0;default:return!1}};e.log=function(){};e.F=function(){};
e.status=function(a){this.F(this.va+": "+a)};e.ta=function(a,b,c){c=c||this.type;b||B((c?c+": ":"")+a)};function va(a,b){a.u.error=!0;a.ta(b)}function K(a,b){b&&(a.u.ready?b():a.ua=b);return a.u.ready}e.R=function(a){this.u.error||(this.u.ready=!1!==a,this.u.ready&&(a=this.ua,this.ua=null,a&&a()))};function wa(a,b){if(a.u.wa)return a.u.ra=!1,a.u.wa=!1;if(a.u.error)return a.F(a.toString()+" error"),!1;a.u.ra=b;return a.u.ra}
window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
e.status=function(a){this.F(this.va+": "+a)};e.ta=function(a,b,c){if(!b){var d=qa("Computer",this.id);if(d&&d.u.ce){console.log("ignoring notice during unload: "+a);return}}c=c||this.type;b||B((c?c+": ":"")+a)};function va(a,b){a.u.error=!0;a.ta(b)}function K(a,b){b&&(a.u.ready?b():a.ua=b);return a.u.ready}e.R=function(a){this.u.error||(this.u.ready=!1!==a,this.u.ready&&(a=this.ua,this.ua=null,a&&a()))};
function wa(a,b){if(a.u.wa)return a.u.ra=!1,a.u.wa=!1;if(a.u.error)return a.F(a.toString()+" error"),!1;a.u.ra=b;return a.u.ra}window&&(window.PCjs||(window.PCjs={}),window.PCjs.Machines||(window.PCjs.Machines={}),window.PCjs.Components||(window.PCjs.Components=[]),window.PCjs.Commands||(window.PCjs.Commands={}));
var L=window?window.PCjs.Machines:{},E=window?window.PCjs.Components:[],J=window?window.PCjs.Commands:{},sa=["hold","sleep","wait"],ta={alert:function(a){B(a);return!0},sleep:function(a,b){setTimeout(a,+b);return!1}},ua={select:function(a,b,c){var d=!1;if(a=a.bindings[b])for(b=0;b<a.options.length;b++)if(a.options[b].textContent==c){a.selectedIndex!=b&&(a.selectedIndex=b);d=!0;break}return d}};
Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)});
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return f.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),f=this;c.prototype=this.prototype;b.prototype=new c;return b});function M(a){D.call(this,"C1PPanel",a);this.u.I=!1}q(M,D);
@ -132,7 +132,7 @@ e.L=function(a,b,c){var d=this;switch(b){case "listSerial":return this.B[b]=c,!0
b.name,c.result.toString(),0)};c.readAsText(b);return!1}):c.parentNode.removeChild(c),!0}return!1};e.Y=function(a,b,c,d){this.a=a;this.m=b;this.s=c-b+1;this.o=this.m+this.s;if(this.G=d)Ca(d,b,c,this,this.X),Q(d,b,c,this,this.ab);this.R()};e.$=function(a,b){a&&!this.u.I&&(this.u.I=!0,this.J=b,this.b=N(b,"keyboard"))};
function ab(a,b,c,d){if(c){a.h=0;a.c=c;a.i=!0;a.f=Za;if(-1!==b.indexOf(".json",b.length-5))try{d="";var f=eval("("+c+")").bytes;for(c=0;c<f.length;c++)d+=String.fromCharCode(f[c]);a.c=d;a.i=!1}catch(g){a.F('Error processing file "'+b+'": '+g.message);return}a.J&&a.b&&a.G.u.Z?(a.F("auto-loading "+b),a.G.ca(),"."!=a.c.charAt(0)?(a.f=$a,W(a.b,"NEW\nLOAD\n")):(a.f=Ya,a.J.reset(!0),W(a.b,"ML"))):a.F(b+" ready to load")}else a.F('Error loading file "'+b+'" ('+d+")")}
e.X=function(a,b){void 0!==b&&(a&1?bb(this):this.c&&!this.h&&bb(this))};e.ab=function(){};function bb(a){if(void 0!==a.c){a.g=-1;if(a.h<a.c.length){var b=a.c.charCodeAt(a.h++)&255;a.i&&10==b&&(b=13);a.g=b}else a.c="",a.h=0,a.f==$a&&a.b&&W(a.b," \nRUN\n"),a.f=Za;for(b=a.m+0;b<a.o;b+=2)a.a[b]=0<=a.g?cb:db;for(b=a.m+1;b<a.o;b+=2)a.a[b]=0<=a.g?a.g:0}}var db=0,cb=1,Za=0,$a=1,Ya=2;x(function(){for(var a=I(document,"c1pjs","serial"),b=0;b<a.length;b++){var c=a[b],d=G(c),d=new Xa(d);H(d,c)}});
function eb(a){D.call(this,"C1PDiskController",a);this.u.I=!1;this.reset(!0)}q(eb,D);e=eb.prototype;e.reset=function(a){fb(this);this.b=-1;a&&(this.c=[],this.c[0]={ce:0,Ga:40,cb:!0,ia:20,aa:0,ha:-1,qa:[]})};
function eb(a){D.call(this,"C1PDiskController",a);this.u.I=!1;this.reset(!0)}q(eb,D);e=eb.prototype;e.reset=function(a){fb(this);this.b=-1;a&&(this.c=[],this.c[0]={de:0,Ga:40,cb:!0,ia:20,aa:0,ha:-1,qa:[]})};
function fb(a){a.s={C:64,read:function(){},update:function(a){return function(b){void 0!==b&&(this.C=b);a.i.C&4||X(a,0,this)}}(a)};a.f={C:255,read:function(){this.update()},update:function(a){return function(b){void 0===b?b=a.f.C:gb(a,b,a.h.C);b=(b|190)&-2;if(0<=a.b&&a.c[a.b].qa.length){var c=a.c[a.b];c.cb&&(b&=-33);c.aa||(b&=-3);10>=--c.ia&&(0<c.ia?(b&=-129,hb(a)):(c.ia=100,0<=a.b&&(a.c[a.b].ha=0,ib(a))))}this.C=b;a.i.C&4&&X(a,0,this)}}(a)};a.i={C:0,read:function(){},update:function(a){return function(b){void 0!==
b&&(this.C=b&-193);X(a,1,this);a.f.update();a.s.update()}}(a)};a.v={C:255,read:function(){},update:function(a){return function(b){void 0!==b&&(this.C=b);a.j.C&4||X(a,2,this)}}(a)};a.h={C:255,read:function(){},update:function(a){return function(b){void 0===b?b=a.h.C:gb(a,a.f.C,b);if(0<=a.b&&a.b<a.c.length){var c=a.c[a.b];c.qa.length&&a.h.C&8&&!(b&8)&&(b&4?c.aa--:c.aa++,c.aa>=c.Ga&&(c.aa=c.Ga),0>c.aa&&(c.aa=0),c.ia=20,a.f.update(a.f.C|128),hb(a))}this.C=b;a.j.C&4&&X(a,2,this)}}(a)};a.j={C:0,read:function(){},
update:function(a){return function(b){void 0!==b&&(this.C=b&-193);X(a,3,this);a.h.update();a.v.update()}}(a)};a.w={C:0,read:function(){},update:function(a){return function(b){void 0!==b&&(3==(b&3)&&(a.g.C=14),this.C=b);a.g.update()}}(a)};a.g={C:14,read:function(){},update:function(a){return function(b){void 0===b&&(b=a.g.C);b&=-2;0<=a.b&&0<=a.c[a.b].ha&&(b|=1);this.C=b;X(a,16,this)}}(a)};a.o={C:0,read:function(a){return function(){ib(a)}}(a),update:function(a){return function(b){void 0!==b&&(this.C=

File diff suppressed because one or more lines are too long