Restrict the download option to Firefox for now, and disable the external XML link for saved machines

This commit is contained in:
Jeff Parsons 2016-02-17 23:03:29 -08:00
commit 22a4da112d
8 changed files with 397 additions and 383 deletions

View file

@ -43,9 +43,9 @@ in your Downloads folder, so the OS X Terminal command `chmod -w PCDOS200-DISK2.
Saving Machines
---
Saving the entire state of any existing IBM PC machine is also possible with a single click. You can choose to save
a machine in its initial state, or make changes to any of the machine's disks and then save it. All your changes should
be preserved.
Saving the entire state of any existing IBM PC machine is also easy now, thanks to the new **Save Machine** link.
You can choose to save a machine in its initial state, or make changes to any of the machine's disks and then save it.
All your changes should be preserved.
Under the bottom-left corner of any IBM PC on the PCjs [website](/), you should now see a
[**Save Machine**] link. When you click that link, PCjs will generate a large "blob" of JavaScript containing

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -156,6 +156,7 @@ function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
*
* Until/unless that changes, components.xsl cannot be simplified as much as I might have hoped.
*/
if (typeof resources == 'object') sURL = null; // turn off URL inclusion if we have embedded resources
sXML = sXML.replace(/(<machine[^>]*\sid=)(['"]).*?\2/, "$1$2" + idMachine + "$2" + (sParms? " parms='" + sParms + "'" : "") + (sURL? ' url="' + sURL + '"' : ''));
}
/*

View file

@ -197,29 +197,38 @@ function downloadPC(sURL, sCSS, nErrorCode, aMachineInfo)
sPCJS = matchScript[1] + "var resources=" + sResources + ";" + matchScript[2] + matchScript[3];
Component.log("saving machine: '" + idMachine + "' (" + sPCJS.length + " bytes)");
var uri;
var sURI, sAlert;
var link = document.createElement('a');
var fDownload = (!DEBUG && typeof link.download == 'string');
if (MAXDEBUG) {
sPCJS = sPCJS.replace(/[\u00A0-\u2666]/g, function(c) {
return '&#' + c.charCodeAt(0) + ';';
});
uri = "data:application/javascript;base64," + btoa(sPCJS);
sURI = "data:application/javascript;base64," + btoa(encodeURI(sPCJS));
} else {
sPCJS = sPCJS.replace(/\u00A9/g, "&#xA9;");
uri = "data:application/javascript," + (web.isUserAgent("Firefox")? encodeURIComponent(sPCJS) : encodeURI(sPCJS));
sURI = "data:application/javascript,";
if (!web.isUserAgent("Firefox")) {
fDownload = false;
sURI += encodeURI(sPCJS);
} else {
sURI += encodeURIComponent(sPCJS);
}
}
var link = document.createElement('a');
if (!DEBUG && typeof link.download == 'string') {
link.href = uri;
link.download = sScript + ".json";
document.body.appendChild(link); // Firefox requires the link to be in the body (?)
if (fDownload) {
link.href = sURI;
link.download = sScript + ".js";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
sAlert = 'Check your Downloads folder for "' + link.download + '", ';
} else {
window.open(uri);
window.open(sURI);
sAlert = 'Check your browser for a new window/tab containing the PCjs script, ';
}
var sAlert = 'Check your Downloads folder for "' + sScript + '.json", ';
sAlert += 'copy it to your web server as "' + sScript + '.js", and then add the following to your web page:\n\n';
sAlert += '<div id="' + idMachine + '"></div>\n';
sAlert += '...\n';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long