Avoid deprecation warnings regarding image smoothing, by carefully checking for properties in order of least to most deprecatable (what a delightful process)

This commit is contained in:
Jeff Parsons 2016-05-04 13:16:37 -07:00
commit cf596ee224
10 changed files with 349 additions and 343 deletions

View file

@ -94,13 +94,13 @@ function Cd(a){if(!ib(a))if(!a.G)D(a);else if(a.w&&a.B){a.u||(a.u=a.w.length);if
function Dd(a,b){if(rb(a.B,b,a.u,a.J?1:Qb)){var c;for(c=0;c<a.w.length;c++)wb(a.B,b+c,a.w[c]);if(a.J&&256==b){for(c=0;c<Bd.length;c++)wb(a.B,Bd[c],118);Cc(a.b,function(a){return function(b){if(0<=Bd.indexOf(b)){var c=!1,h=a.b,g=a.F;if(5==b)switch(c=!0,h.O){case 2:Ed(a,String.fromCharCode(h.R));break;case 9:for(var l=Jc(h),k="",n=255;n--;){var p=a.b.X(l++);if(36==p)break;k+=String.fromCharCode(p)}Ed(a,k);break;default:c=!1}c?td.call(h):g&&(a.g("\nCP/M vector "+r(b)),F(h,b),g.da());b=!0}else b=!1;return b}}(a));
Ec(a.b,b)}return!0}return!1}function Ed(a,b){b=b.replace(/\r/g,"");a.ta&&(a.ta.value+=b,a.ta.scrollTop=a.ta.scrollHeight)}Ia(function(){for(var a=C(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new zd(d);bb(d,c)}});function Fd(a){v.call(this,"RAM",a,Fd);this.C=a.addr;this.u=a.size;this.w=!1}Va(Fd);m=Fd.prototype;m.Ia=function(a,b,c,d){this.B=b;this.b=c;this.F=d;D(this)};m.Ba=function(a,b){b||this.reset();return!0};m.Aa=function(a){return a?this.save():!0};
m.reset=function(){!this.w&&this.u&&rb(this.B,this.C,this.u,1)&&(this.w=!0);this.w||t("No RAM allocated")};m.save=function(){return null};m.restore=function(){return!0};Ia(function(){for(var a=C(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Fd(d);bb(d,c)}});function Gd(a){v.call(this,"Keyboard",a,Gd,65536);D(this)}Va(Gd);Ia(function(){for(var a=C(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Gd(d);bb(d,c)}});
function Hd(a,b,c,d,e){var f=this;this.wa=wa("Gecko/");var h=["","moz","webkit","ms"];v.call(this,"Video",a,Hd,262144);this.ha=a.screenWidth;this.aa=a.screenHeight;this.qa=a.bufferAddr;this.H=a.bufferCols;this.Y=a.bufferRows;this.ia=a.bufferBits||1;this.qb=a.bufferLeft||0;if(this.C=a.bufferRotate)this.C=this.C%360,0<this.C&&(this.C-=360),-90!=this.C&&(this.na("unsupported buffer rotation: "+this.C),this.C=0);this.Zb=a.interruptRate;this.Ea=a.refreshRate||60;this.K=b;this.L=c;this.Ca=d||b||null;b=
a.smoothing;(c=Qa.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",this.L[d]=b;if(this.G=a.screenRotate)this.G=this.G%360,0<this.G&&(this.G-=360),-90!=this.G?(this.na("unsupported screen rotation: "+this.G),this.G=0):(this.L.translate(0,this.aa),this.L.rotate(this.G*Math.PI/180),this.L.scale(this.aa/this.ha,this.ha/this.aa));this.ba=1<<this.ia;this.W=Array(this.ba+2);this.W[0]=[0,0,0,255];this.W[1]=[255,255,255,255];this.W[this.ba+
0]=[255,255,0,255];this.W[this.ba+1]=[0,255,0,255];a=this.H;b=this.Y;this.C&&(a=this.Y,b=this.H);this.xa=this.L.createImageData(a,b);this.J=document.createElement("canvas");this.J.width=a;this.J.height=b;this.pb=this.J.getContext("2d");if(this.u=e)if(this.u.Pa=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.u.Pa){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Id(f,document.fullscreenElement||
document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement?!0:!1)},!1);break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){Id(f,null)},!1);break}}}Va(Hd);
Hd.prototype.Ia=function(a,b,c,d){this.w=a;this.B=b;this.b=c;this.F=d;this.oa=(this.H*this.ia>>3)*this.Y;rb(this.B,this.qa,this.oa,3)&&(this.Fa=this.oa>>1,this.Ga=16/this.ia|0,this.sa=!1,void 0===this.fa||this.fa.length!=this.Fa)&&(this.fa=Array(this.Fa));D(this)};Hd.prototype.pa=function(a,b,c){var d=this;switch(b){case "fullScreen":return this.T[b]=c,this.u&&this.u.Pa?c.onclick=function(){d.Pa()}:c.parentNode.removeChild(c),!0}return!1};
Hd.prototype.Pa=function(){var a=!1;if(this.u){if(this.u.Pa){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.ha/this.aa;b>c&&(a=Math.round(c/b*100)+"%")}this.wa?(this.K.style.width=a,this.K.style.width=a,this.K.style.display="block",this.K.style.margin="auto"):(this.u.style.width=a,this.u.style.height="auto");this.u.style.backgroundColor="black";this.u.Pa();a=!0}this.Ca&&this.Ca.focus()}return a};
function Id(a,b){!b&&a.u&&(a.wa?a.K.style.width=a.K.style.height="":a.u.style.width=a.u.style.height="");eb(a,"notifyFullScreen("+b+")",!0)}
function Hd(a,b,c,d,e){var f=this;this.wa=wa("Gecko/");var h=["","moz","ms","webkit"];v.call(this,"Video",a,Hd,262144);this.ha=a.screenWidth;this.aa=a.screenHeight;this.qa=a.bufferAddr;this.J=a.bufferCols;this.Y=a.bufferRows;this.ia=a.bufferBits||1;this.qb=a.bufferLeft||0;if(this.C=a.bufferRotate)this.C=this.C%360,0<this.C&&(this.C-=360),-90!=this.C&&(this.na("unsupported buffer rotation: "+this.C),this.C=0);this.Zb=a.interruptRate;this.Ea=a.refreshRate||60;this.L=b;this.H=c;this.Ca=d||b||null;b=
a.smoothing;(c=Qa.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<h.length;c++)if(d=(d=h[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.H[d]){this.H[d]=b;break}if(this.G=a.screenRotate)this.G=this.G%360,0<this.G&&(this.G-=360),-90!=this.G?(this.na("unsupported screen rotation: "+this.G),this.G=0):(this.H.translate(0,this.aa),this.H.rotate(this.G*Math.PI/180),this.H.scale(this.aa/this.ha,this.ha/this.aa));this.ba=1<<this.ia;this.W=Array(this.ba+2);this.W[0]=[0,0,0,255];this.W[1]=
[255,255,255,255];this.W[this.ba+0]=[255,255,0,255];this.W[this.ba+1]=[0,255,0,255];a=this.J;b=this.Y;this.C&&(a=this.Y,b=this.J);this.xa=this.H.createImageData(a,b);this.K=document.createElement("canvas");this.K.width=a;this.K.height=b;this.pb=this.K.getContext("2d");if(this.u=e)if(this.u.Pa=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.u.Pa){for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Id(f,
document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);break}for(c=0;c<h.length;c++)if(d=h[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){Id(f,null)},!1);break}}}Va(Hd);
Hd.prototype.Ia=function(a,b,c,d){this.w=a;this.B=b;this.b=c;this.F=d;this.oa=(this.J*this.ia>>3)*this.Y;rb(this.B,this.qa,this.oa,3)&&(this.Fa=this.oa>>1,this.Ga=16/this.ia|0,this.sa=!1,void 0===this.fa||this.fa.length!=this.Fa)&&(this.fa=Array(this.Fa));D(this)};Hd.prototype.pa=function(a,b,c){var d=this;switch(b){case "fullScreen":return this.T[b]=c,this.u&&this.u.Pa?c.onclick=function(){d.Pa()}:c.parentNode.removeChild(c),!0}return!1};
Hd.prototype.Pa=function(){var a=!1;if(this.u){if(this.u.Pa){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.ha/this.aa;b>c&&(a=Math.round(c/b*100)+"%")}this.wa?(this.L.style.width=a,this.L.style.width=a,this.L.style.display="block",this.L.style.margin="auto"):(this.u.style.width=a,this.u.style.height="auto");this.u.style.backgroundColor="black";this.u.Pa();a=!0}this.Ca&&this.Ca.focus()}return a};
function Id(a,b){!b&&a.u&&(a.wa?a.L.style.width=a.L.style.height="":a.u.style.width=a.u.style.height="");eb(a,"notifyFullScreen("+b+")",!0)}
Ia(function(){for(var a=C(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=z(c),e=document.createElement("canvas");if(void 0===e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=qa().indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Qa.aspect);f&&.3<=f&&3.33>=f&&(Ga("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");wa("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var h=e.getContext("2d"),d=new Hd(d,e,h,f,c);bb(d,c)}});
function Jd(a){v.call(this,"Debugger",a,Jd);this.style=Kd;this.fa=this.Ca=this.L=0;this.Y=T();this.Gb=T();this.G=-1;this.C=[];this.ia=!1;this.ha=T();this.J=[];this.oa={};this.u=this.aa=this.H=[];Ld(this);this.wa=0;Md(this);this.Fa=[];Nd(this,a.messages);this.Ga=a.commands;var b=this;window?void 0===window.$&&(window.$=function(a){return qc(b,a)}):void 0===global.$&&(global.$=function(a){return qc(b,a)})}Va(Jd);
@ -192,8 +192,8 @@ function nf(a,b){var c=a.u;c||(c=ua("user"),void 0!==c?!c&&b&&(c=null,window&&(c
function yf(a,b){a.u=null;var c=oa(pa()+"/api/v1/user?req=verify&user="+b),d=c[1];if(!c[0]&&d)try{c=eval("("+d+")"),c.code&&"ok"==c.code&&(va("user",c.data),a.u=c.data)}catch(e){t(e.message+" ("+d+")")}return a.u}function sf(a){var b=null;a.u&&(b=pa()+"/api/v1/user?req=load&user="+a.u+"&state="+df(a,pf));return b}
function xf(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=df(a,pf);d.data=c;b=oa(pa()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.na("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.na(c),va("user",""),a.u=null)}}
function nb(a,b,c){a=Ya(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}m.mb=function(){};m.va=function(a){this.b&&this.b.va(a);this.G&&this.G.va(a)};
function yc(a,b){for(var c=0;c<a.aa.length;c++)a:{var d=a.aa[c];if(0<=b){if(b&1){d=d.b;d.u=d.u&-8|10;break a}var e=d.b;e.u=e.u&-8|9;if(e=d.sa){for(var e=d.B,f=d.oa,h=!0,g=d.qa>>>e.ea;0<f&&g<e.U.length;)e.U[g].ya&&(e.U[g].ya=h=!1,e.U[g].Lb=!0),f-=e.ua,g++;e=h}if(e)break a}var g=d.qa,l=g+d.oa,k=0,n=0,p=0,e=d.H,x=0,f=d.Y,B=h=0,u=d.ia,la=(1<<u)-1;d.qb&&(u=-u,B=16+u);for(;g<l;){var w=vb(d.B,g);if(d.sa&&w===d.fa[k])n+=d.Ga;else{d.fa[k]=w;var da=B;da&&(w=w>>8|(w&255)<<8);n<e&&(e=n);for(var K=d.Ga;K--;){var M=
w>>da&la,P=d.xa,A=n++,X=M,M=void 0,M=d.C?(P.height-A-1)*P.width+p:A+p*P.width;X&&(208<=A&&236>A?X=d.ba+0:28<=A&&72>A&&(X=d.ba+1));A=d.W[X];M*=A.length;P.data[M]=A[0];P.data[M+1]=A[1];P.data[M+2]=A[2];P.data[M+3]=A[3];da+=u}n>x&&(x=n);p<f&&(f=p);p>=h&&(h=p+1)}g+=2;k++;if(n>=d.H&&(n=0,p++,p>d.Y))break}d.sa=!0;e<d.H&&(g=x-e,h-=f,d.C&&(l=e,k=g,e=f,g=h,f=d.H-(l+k),h=k),d.pb.putImageData(d.xa,0,0,e,f,g,h),d.L.drawImage(d.J,0,0,d.J.width,d.J.height,0,0,d.ha,d.aa))}}
function yc(a,b){for(var c=0;c<a.aa.length;c++)a:{var d=a.aa[c];if(0<=b){if(b&1){d=d.b;d.u=d.u&-8|10;break a}var e=d.b;e.u=e.u&-8|9;if(e=d.sa){for(var e=d.B,f=d.oa,h=!0,g=d.qa>>>e.ea;0<f&&g<e.U.length;)e.U[g].ya&&(e.U[g].ya=h=!1,e.U[g].Lb=!0),f-=e.ua,g++;e=h}if(e)break a}var g=d.qa,l=g+d.oa,k=0,n=0,p=0,e=d.J,x=0,f=d.Y,B=h=0,u=d.ia,la=(1<<u)-1;d.qb&&(u=-u,B=16+u);for(;g<l;){var w=vb(d.B,g);if(d.sa&&w===d.fa[k])n+=d.Ga;else{d.fa[k]=w;var da=B;da&&(w=w>>8|(w&255)<<8);n<e&&(e=n);for(var K=d.Ga;K--;){var M=
w>>da&la,P=d.xa,A=n++,X=M,M=void 0,M=d.C?(P.height-A-1)*P.width+p:A+p*P.width;X&&(208<=A&&236>A?X=d.ba+0:28<=A&&72>A&&(X=d.ba+1));A=d.W[X];M*=A.length;P.data[M]=A[0];P.data[M+1]=A[1];P.data[M+2]=A[2];P.data[M+3]=A[3];da+=u}n>x&&(x=n);p<f&&(f=p);p>=h&&(h=p+1)}g+=2;k++;if(n>=d.J&&(n=0,p++,p>d.Y))break}d.sa=!0;e<d.J&&(g=x-e,h-=f,d.C&&(l=e,k=g,e=f,g=h,f=d.J-(l+k),h=k),d.pb.putImageData(d.xa,0,0,e,f,g,h),d.H.drawImage(d.K,0,0,d.K.width,d.K.height,0,0,d.ha,d.aa))}}
Ia(function(){for(var a=C(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=z(c),c=C(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],h=z(f),h=new kf(h,d,!0);bb(h,f);h.ba&&tf(h,h.kb)}});Da.show.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=Za("Computer",c.id))&&c.sa&&!c.A.ka&&c.kb(-1)}});
Da.exit.push(function(){for(var a=C(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=Za("Computer",c.id))&&c.A.ka&&cf(c,!(!c.w||c.L),!0)}});var Mf=0;function Nf(a,b,c,d,e,f){e("Loading "+a+"...");oa(a,null,!0,function(h,g,l){l?(g||(g="unable to load "+a+" ("+l+")"),f(g,null)):Of(g,a,b,c,d,e,f)})}
function Of(a,b,c,d,e,f,h){function g(a,f){if(f)h(f,null);else{if(c){Xa(c,b,a);var g=b;g&&0>g.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(g=window.location.pathname+g);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{";d+='url:"'+g+'"}';"object"==typeof resources&&(g=null);a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(g?' url="'+g+'"':""))}e||(a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));