Restrict the download option to Firefox for now, and disable the external XML link for saved machines
This commit is contained in:
parent
87704cca14
commit
22a4da112d
8 changed files with 397 additions and 383 deletions
|
|
@ -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 + '"' : ''));
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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, "©");
|
||||
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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue