From c69f2ee51fc49ab7e3f8ba6143b902f91e0e0777 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 17 Feb 2016 11:20:09 -0800 Subject: [PATCH] Firefox fix --- modules/pcjs/lib/debugger.js | 1 + modules/shared/lib/save.js | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js index dd112b0bd..8bfc8c92a 100644 --- a/modules/pcjs/lib/debugger.js +++ b/modules/pcjs/lib/debugger.js @@ -8072,6 +8072,7 @@ if (DEBUGGER) { break; } this.println((APPNAME || "PCjs") + " version " + (XMLVERSION || APPVERSION) + " (" + this.cpu.model + (COMPILED? ",RELEASE" : (DEBUG? ",DEBUG" : ",NODEBUG")) + (PREFETCH? ",PREFETCH" : ",NOPREFETCH") + (TYPEDARRAYS? ",TYPEDARRAYS" : (BYTEARRAYS? ",BYTEARRAYS" : ",LONGARRAYS")) + (BACKTRACK? ",BACKTRACK" : ",NOBACKTRACK") + ')'); + this.println(web.getUserAgent()); break; case 'x': this.doExecOptions(asArgs); diff --git a/modules/shared/lib/save.js b/modules/shared/lib/save.js index ded295a31..00ae55024 100644 --- a/modules/shared/lib/save.js +++ b/modules/shared/lib/save.js @@ -157,20 +157,20 @@ function downloadPC(sURL, sPCJS, nErrorCode, aMachineInfo) } if (sXMLFile && sXSLFile) { - var uri; var sResources = JSON.stringify(resNew); var sScriptFile = str.getBaseName(sURL, true); sPCJS = matchScript[1] + "var resources=" + sResources + ";" + matchScript[2] + matchScript[3]; Component.log("saving machine: '" + idMachine + "' (" + sPCJS.length + " bytes)"); + var uri; if (MAXDEBUG) { sPCJS = sPCJS.replace(/[\u00A0-\u2666]/g, function(c) { return '&#' + c.charCodeAt(0) + ';'; }); uri = "data:application/javascript;base64," + btoa(sPCJS); } else { - uri = "data:application/javascript," + encodeURI(sPCJS); + uri = "data:application/javascript," + (web.isUserAgent("Firefox")? encodeURIComponent(sPCJS) : encodeURI(sPCJS)); } var link = document.createElement('a'); @@ -180,17 +180,18 @@ function downloadPC(sURL, sPCJS, nErrorCode, aMachineInfo) document.body.appendChild(link); // Firefox requires the link to be in the body (?) link.click(); document.body.removeChild(link); - var sAlert = 'Check your Downloads folder for "' + sScriptFile + '.json", '; - sAlert += 'copy it to your web server as "' + sScriptFile + '.js", and then add the following to your web page:\n\n'; - sAlert += '
\n'; - sAlert += '...\n'; - sAlert += '\n'; - sAlert += '\n\n'; - sAlert += 'The machine should appear where the
is located.'; - web.alertUser(sAlert); } else { window.open(uri); } + + var sAlert = 'Check your Downloads folder for "' + sScriptFile + '.json", '; + sAlert += 'copy it to your web server as "' + sScriptFile + '.js", and then add the following to your web page:\n\n'; + sAlert += '
\n'; + sAlert += '...\n'; + sAlert += '\n'; + sAlert += '\n\n'; + sAlert += 'The machine should appear where the
is located.'; + web.alertUser(sAlert); } else { web.alertUser("Missing XML/XSL resources"); }