Fixed recent problems introduced with my switch to addEventListener
This commit is contained in:
parent
2cb0be42f0
commit
743511d5db
14 changed files with 70 additions and 88 deletions
|
|
@ -132,8 +132,8 @@ function Ha(a){var b=0;if(a.C.N)for(;b<a.g;){var c=a.a[a.K+b];if(a.L[b]!=c){var
|
|||
y(function(){for(var a=G(document,"c1pjs","video"),b=0;b<a.length;b++){var c=a[b],d=E(c),e=document.createElement("canvas");if(!e||!e.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}e.setAttribute("class","c1pjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.setAttribute("contenteditable","true");e.setAttribute("autocapitalize","off");e.setAttribute("autocorrect","off");e.style.backgroundColor=d.screenColor;
|
||||
e.style.height="auto";0<=(window?window.navigator.userAgent:"").indexOf("MSIE")&&(e.style.height=(c.clientWidth*d.screenHeight/d.screenWidth|0)+"px",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.appendChild(e);var g=new Image,h=e.getContext("2d"),e=new fb(d,e,h,g);g.onload=function(a){return function(){a.X()}}(e,d.charSet);g.src=d.charSet;F(e,c)}});
|
||||
function ib(a){C.call(this,"C1PSerialPort",a);this.C.N=!1;this.D=a.demo;this.reset(!0)}p(ib,C);f=ib.prototype;f.reset=function(a){if(a||this.o!=jb){this.v=-1;this.A=0;this.g="";if(this.D){a=1;if(this.nb){var b=this.nb.match(/\d+/);null!==b&&(a=parseInt(b[0],10))}this.g='10 PRINT "HELLO OSI #'+a+'"\n'}this.B=!0;this.o=kb}};f.start=function(){this.b&&this.D&&(cb(this.b," C\n\n",3E3),setTimeout(function(a){return function(){a.o=lb;cb(a.b,"LOAD\n")}}(this),12E3));this.D=!1};
|
||||
f.T=function(a,b,c){var d=this;switch(b){case "listSerial":return this.H[b]=c,!0;case "loadSerial":return this.H[b]=c,c.onclick=function(){d.H.listSerial&&w(d.H.listSerial.value,function(a,b,c){mb(d,a,b,c)})},!0;case "mountSerial":return!x("Mobi")&&window&&"FileReader"in window?(this.H[b]=c,c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length}),c.addEventListener("submit",function(a){var b=a.currentTarget[1].files[0],c=new FileReader;c.onload=
|
||||
function(){mb(d,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"))};
|
||||
f.T=function(a,b,c){var d=this;switch(b){case "listSerial":return this.H[b]=c,!0;case "loadSerial":return this.H[b]=c,c.onclick=function(){d.H.listSerial&&w(d.H.listSerial.value,function(a,b,c){mb(d,a,b,c)})},!0;case "mountSerial":return!x("Mobi")&&window&&"FileReader"in window?(this.H[b]=c,c.onchange=function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length},c.onsubmit=function(a){var b=a.currentTarget[1].files[0],c=new FileReader;c.onload=function(){mb(d,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]={Te:0,mb:40,Nb:!0,Ba:20,na:0,Aa:-1,Ra:[]})};
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -9608,7 +9608,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 {HTMLElement} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {Object} 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
|
||||
*/
|
||||
|
|
@ -9625,7 +9625,7 @@ class C1PSerialPort extends Component {
|
|||
case "loadSerial":
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
control.onclick = function(event) {
|
||||
control.onclick = function onClickLoadSerial(event) {
|
||||
if (serial.bindings["listSerial"]) {
|
||||
var sFile = serial.bindings["listSerial"].value;
|
||||
// serial.println("loading " + sFile + "...");
|
||||
|
|
@ -9642,18 +9642,16 @@ class C1PSerialPort extends Component {
|
|||
*/
|
||||
if (!Web.isMobile() && window && 'FileReader' in window) {
|
||||
this.bindings[sBinding] = control;
|
||||
|
||||
/*
|
||||
* Enable "Mount" button only if a file is actually selected
|
||||
*/
|
||||
control.addEventListener('change', function() {
|
||||
control.onchange = function onChangeMountSerial() {
|
||||
var fieldset = control.children[0];
|
||||
var files = fieldset.children[0].files;
|
||||
var submit = fieldset.children[1];
|
||||
submit.disabled = !files.length;
|
||||
});
|
||||
|
||||
control.addEventListener('submit', function(event) {
|
||||
};
|
||||
control.onsubmit = function onSubmitMountSerial(event) {
|
||||
var file = event.currentTarget[1].files[0];
|
||||
|
||||
var reader = new FileReader();
|
||||
|
|
@ -9667,7 +9665,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");
|
||||
|
|
|
|||
|
|
@ -128,8 +128,8 @@ function Ba(a){var b=0;if(a.u.I)for(;b<a.c;){var c=a.a[a.s+b];if(a.v[b]!=c){var
|
|||
x(function(){for(var a=J(document,"c1pjs","video"),b=0;b<a.length;b++){var c=a[b],d=H(c),f=document.createElement("canvas");if(!f||!f.getContext){c.innerHTML="<br/>Missing <canvas> support. Please try a newer web browser.";break}f.setAttribute("class","c1pjs-canvas");f.setAttribute("width",d.screenWidth);f.setAttribute("height",d.screenHeight);f.setAttribute("contenteditable","true");f.setAttribute("autocapitalize","off");f.setAttribute("autocorrect","off");f.style.backgroundColor=d.screenColor;
|
||||
f.style.height="auto";0<=(window?window.navigator.userAgent:"").indexOf("MSIE")&&(f.style.height=(c.clientWidth*d.screenHeight/d.screenWidth|0)+"px",c.onresize=function(a,b,c,d){return function(){b.style.height=(a.clientWidth*d/c|0)+"px"}}(c,f,d.screenWidth,d.screenHeight));c.appendChild(f);var g=new Image,h=f.getContext("2d"),f=new Ua(d,f,h,g);g.onload=function(a){return function(){a.R()}}(f,d.charSet);g.src=d.charSet;I(f,c)}});
|
||||
function Xa(a){E.call(this,"C1PSerialPort",a);this.u.I=!1;this.j=a.demo;this.reset(!0)}q(Xa,E);e=Xa.prototype;e.reset=function(a){if(a||this.f!=Ya){this.g=-1;this.h=0;this.c="";if(this.j){a=1;if(this.Ba){var b=this.Ba.match(/\d+/);null!==b&&(a=parseInt(b[0],10))}this.c='10 PRINT "HELLO OSI #'+a+'"\n'}this.i=!0;this.f=Za}};e.start=function(){this.b&&this.j&&(W(this.b," C\n\n",3E3),setTimeout(function(a){return function(){a.f=$a;W(a.b,"LOAD\n")}}(this),12E3));this.j=!1};
|
||||
e.L=function(a,b,c){var d=this;switch(b){case "listSerial":return this.B[b]=c,!0;case "loadSerial":return this.B[b]=c,c.onclick=function(){d.B.listSerial&&v(d.B.listSerial.value,function(a,b,c){ab(d,a,b,c)})},!0;case "mountSerial":return!w("Mobi")&&window&&"FileReader"in window?(this.B[b]=c,c.addEventListener("change",function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length}),c.addEventListener("submit",function(a){var b=a.currentTarget[1].files[0],c=new FileReader;c.onload=
|
||||
function(){ab(d,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=O(b,"keyboard"))};
|
||||
e.L=function(a,b,c){var d=this;switch(b){case "listSerial":return this.B[b]=c,!0;case "loadSerial":return this.B[b]=c,c.onclick=function(){d.B.listSerial&&v(d.B.listSerial.value,function(a,b,c){ab(d,a,b,c)})},!0;case "mountSerial":return!w("Mobi")&&window&&"FileReader"in window?(this.B[b]=c,c.onchange=function(){var a=c.children[0];a.children[1].disabled=!a.children[0].files.length},c.onsubmit=function(a){var b=a.currentTarget[1].files[0],c=new FileReader;c.onload=function(){ab(d,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=O(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=J(document,"c1pjs","serial"),b=0;b<a.length;b++){var c=a[b],d=H(c),d=new Xa(d);I(d,c)}});
|
||||
function eb(a){E.call(this,"C1PDiskController",a);this.u.I=!1;this.reset(!0)}q(eb,E);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:[]})};
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue