Cleaned up PC8080 cross-browser full-screen support (matches PCx86 now)

This commit is contained in:
Jeff Parsons 2017-08-03 08:42:29 -07:00 committed by Jeff Parsons
commit 13b0c23b0a
19 changed files with 500 additions and 524 deletions

View file

@ -61,7 +61,7 @@ var ra="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),sa=
function xa(a,b,c,d,e){c=void 0===c?!1:c;var f=0,g=null,h=null;if("object"==typeof resources&&(g=resources[a]))return d&&d(a,g,f),[g,f];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),h;var k=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(k.onreadystatechange=function(){4!==k.readyState?e&&e(1):(g=k.responseText,200==k.status||!k.status&&g.length&&"file:"==(window?window.location.protocol:"file:")||(f=k.status||-1),
e&&e(2),d&&d(a,g,f))});e&&e(0);if(b&&"object"==typeof b){var m="",r;for(r in b)b.hasOwnProperty(r)&&(m&&(m+="&"),m+=r+"="+encodeURIComponent(b[r]));m=m.replace(/%20/g,"+");k.open("POST",a,c);k.setRequestHeader("Content-type","application/x-www-form-urlencoded");k.send(m)}else k.open("GET",a,c),"bytes"==b&&k.overrideMimeType("text/plain; charset=x-user-defined"),k.send();c||(g=k.responseText,200!=k.status&&(f=k.status||-1),d&&d(a,g,f),h=[g,f]);return h}
function za(){return"http://"+(window?window.location.host:"www.pcjs.org")}function Aa(){return window?window.navigator.userAgent:""}function Ba(){if(null==Ca){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}Ca=a}return Ca}function Da(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function Ea(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Fa(a){if(window){var b=Aa();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Ga(a,b,c){if(a)for(var d=0;d<Ia.length;d++){var e=Ia[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0].toLowerCase(),e+=b.substr(1),e in a)return e}return null}
function Ea(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function Fa(a){if(window){var b=Aa();return"iOS"==a&&!!b.match(/(iPod|iPhone|iPad)/)&&!!b.match(/AppleWebKit/)||"MSIE"==a&&!!b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)}return!1}function Ga(a,b,c){if(a)for(var d=0;d<Ia.length;d++){var e=Ia[d];if(c){if(e+=c,b+e in a)return e}else if(e=e?e+b[0].toUpperCase():b[0],e+=b.substr(1),e in a)return e}return null}
function Ja(a){if(!Ka){var b,c={};if(window){b||(b=window.location.search.substr(1));for(var d,e=/\+/g,f=/([^&=]+)=?([^&]*)/g;d=f.exec(b);)c[decodeURIComponent(d[1].replace(e," "))]=decodeURIComponent(d[2].replace(e," "))}Ka=c}return Ka[a]||Ka[a.toLowerCase()]}
function La(a,b,c,d){var e=null;b="data:application/"+b+(c?";base64":"")+",";b=Fa("Firefox")?b+(c?a:encodeURIComponent(a)):b+(c?a:encodeURI(a));d&&(e=document.createElement("a"),"string"!=typeof e.download&&(e=null));e?(e.href=b,e.download=d,document.body.appendChild(e),e.click(),document.body.removeChild(e),a="Check your Downloads folder for "+d+"."):(window.open(b),a="Check your browser for a new window/tab containing the requested data"+(d?" ("+d+")":"")+".");return a}
function Ma(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function Na(a){Oa.init.push(a)}function Pa(a){if(Qa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){q(""+("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks."))}}function Ra(a){!Qa&&a?(Qa=!0,Sa&&Ta("init"),Ua&&Ta("show")):Qa=a}function Ta(a){Oa[a]&&Pa(Oa[a])}
@ -516,8 +516,8 @@ Cp[98]=function(a,b){a+=this.G;b=$p[b&15];b&=this.controller.pb;b=b&this.control
Cp[226]=function(a,b){a+=this.G;b=$p[b&15];b^=this.controller.pb;b=b&this.controller.sb|this.controller.pb&~this.controller.sb;b=b&this.controller.Wa|this.T[a]&~this.controller.Wa;this.T[a]!=b&&(this.T[a]=b,this.Ea=!0)};Cp[3]=function(a,b){a+=this.G;b=b>>this.controller.Bc|b<<8-this.controller.Bc&255;b=(b|b<<8|b<<16|b<<24)&this.controller.sb;b=this.controller.af&b|this.controller.pb&~b;b=b&this.controller.Wa|this.T[a]&~this.controller.Wa;this.T[a]!=b&&(this.T[a]=b,this.Ea=!0)};
function W(a,b,c,d,e){u.call(this,"Video",a);var f=this,g;this.Oc=Fa("Gecko/");this.ca=a.model;var h=aq[this.ca]||aq.mda;this.Na=h[0];this.Yc=a.memory||0;this.Uc=a.switches;this.ba=a.mode;if(null==this.ba||null==bq[this.ba])this.ba=h[1];this.Gb=a.charCols;this.lc=a.charRows;if(void 0===this.Gb||void 0===this.lc)this.Gb=bq[this.ba][0],this.lc=bq[this.ba][1];this.X=a.screenWidth;this.ja=a.screenHeight;this.Pc=a.scale;this.pd=12<=Math.round(this.X/this.Gb);this.M=b;this.J=c;this.F=(this.Lf=d)||b||null;
this.Xb=a.screenColor||"black";this.Tc=(1-(Ja("flicker")||a.flicker||0)).toString();this.Db=!1;b&&(b.style.backgroundColor=this.Xb);e&&(e.style.backgroundColor=this.Xb);b=a.smoothing;(c=Ja("smoothing"))&&(b="true"==c);null!=b&&(g=Ga(this.J,"imageSmoothingEnabled"))&&(this.J[g]=b);this.Vc=a.touchScreen;this.mc=cq;this.K=null;this.od=a.autoLock;this.bb=this.Hb=0;this.qa=[];this.fa=Array(this.Na==Zn?256:16);this.Ga=!1;if(this.N=e)if(g=Ga(e,"requestFullscreen")||Ga(e,"requestFullScreen")){this.N.A=e[g];
if(e=Ga(document,"on","fullscreenchange")){var k=Ga(document,"fullscreenElement")||Ga(document,"fullScreenElement");document.addEventListener(e,function(){dq(f,!!k)},!1)}(e=Ga(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){dq(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Xf(!0)},this.F.onblur=function(){return f.Xf(!1)},this.F.Nd=(g=Ga(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Ga(this.F,"exitPointerLock"))&&this.F[g],this.F.Nd)){var m=Ga(document,
"pointerLockElement");(e=Ga(document,"on","pointerlockchange"))&&document.addEventListener(e,function(){f.cf(!(!m||document[m]!==f.F))},!1)}(this.xa=a.fontROM)&&"json"!=ka(this.xa)&&(this.xa=za()+"/api/v1/dump?file="+this.xa+"&format=bytes")}ba(W,u);l=W.prototype;
if(e=Ga(document,"on","fullscreenchange")){var k=Ga(document,"fullscreenElement")||Ga(document,"fullScreenElement");document.addEventListener(e,function(){dq(f,!!k)},!1)}(e=Ga(document,"on","fullscreenerror"))&&document.addEventListener(e,function(){dq(f,null)},!1)}if(this.F&&(this.F.onfocus=function(){return f.Xf(!0)},this.F.onblur=function(){return f.Xf(!1)},this.F.Nd=(g=Ga(this.F,"requestPointerLock"))&&this.F[g],this.F.B=(g=Ga(this.F,"exitPointerLock"))&&this.F[g],this.F.Nd&&(e=Ga(document,"on",
"pointerlockchange")))){var m=Ga(document,"pointerLockElement");document.addEventListener(e,function(){f.cf(!(!m||document[m]!==f.F))},!1)}(this.xa=a.fontROM)&&"json"!=ka(this.xa)&&(this.xa=za()+"/api/v1/dump?file="+this.xa+"&format=bytes")}ba(W,u);l=W.prototype;
l.kc=function(a,b,c,d){var e=this;this.ma=b;this.S=c;this.Da=d;c=(c=aq[this.ca])&&c[0];c!==eq&&(mc(b,this,fq),oc(b,this,gq));c!==hq&&(mc(b,this,iq),oc(b,this,jq));this.Na>=Xn&&(mc(b,this,kq),oc(b,this,lq));this.Na==Zn&&(mc(b,this,mq),oc(b,this,nq));if((this.C=yb(a,"Keyboard"))&&this.M){for(var f in this.ia)0<f.indexOf("lock")&&this.C.Ab("led",f,this.ia[f]);this.C.Ab(this.Lf?"textarea":"canvas","screen",this.F)}this.vb=9;(this.V=yb(a,"ChipSet"))&&this.Uc&&this.Na==Xn&&(this.vb=Aj(this.Uc,this.vb));
"mouse"==this.Vc?(this.K=yb(a,"Mouse"))&&oq(this,pq):"keygrid"==this.Vc&&this.C&&oq(this,qq);if(this.xa){var g="Loading "+this.xa+"...";xa(this.xa,null,!0,function(a,b,c){rq(e,a,b,c)},function(){e.tb(g,nb.ce)})}};
l.Ab=function(a,b,c){var d=this;if(!this.ia[b])switch(this.ia[b]=c,b){case "fullScreen":return this.N&&this.N.A?c.onclick=function(){if(d.N){if(d.N.A){var a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=d.X/d.ja;b>c&&(a=Math.round(c/b*100)+"%")}d.Oc?(d.M.style.width=a,d.M.style.width=a,d.M.style.display="block",d.M.style.margin="auto"):(d.N.style.width=a,d.N.style.height="auto");d.N.style.backgroundColor=d.Xb;d.N.A()}d.F&&d.F.focus()}}:c.parentNode.removeChild(c),