]*path=(['"])(.*?)\1.*?<\/disk>\n?/g;
while (matchDisk = reDisk.exec(resOld[sName])) {
var path = matchDisk[2];
if (path) {
if (resOld[path]) {
Component.log("recording disk: '" + path + "'");
} else {
data = data.replace(matchDisk[0], "");
}
}
}
sXMLFile = sName = str.getBaseName(sName);
}
else if (sExt == "xsl") {
sXSLFile = sName = str.getBaseName(sName);
}
Component.log("saving resource: '" + sName + "' (" + data.length + " bytes)");
resNew[sName] = data;
}
if (sCSS) {
resNew[sName = 'css'] = sCSS;
Component.log("saving resource: '" + sName + "' (" + sCSS.length + " bytes)");
}
if (aMachineInfo[2]) {
var sParms = resNew[sName = 'parms'] = aMachineInfo[2];
Component.log("saving resource: '" + sName + "' (" + sParms.length + " bytes)");
}
if (aMachineInfo[3]) {
var sState = resNew[sName = 'state'] = aMachineInfo[3];
Component.log("saving resource: '" + sName + "' (" + sState.length + " bytes)");
}
if (sXMLFile && sXSLFile) {
var sResources = JSON.stringify(resNew);
sPCJS = matchScript[1] + "var resources=" + sResources + ";" + matchScript[2] + matchScript[3];
Component.log("saving machine: '" + idMachine + "' (" + sPCJS.length + " bytes)");
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) + ';';
});
sURI = "data:application/javascript;base64," + btoa(encodeURI(sPCJS));
} else {
sPCJS = sPCJS.replace(/\u00A9/g, "©");
sURI = "data:application/javascript,";
if (!web.isUserAgent("Firefox")) {
fDownload = false;
sURI += encodeURI(sPCJS);
} else {
sURI += encodeURIComponent(sPCJS);
}
}
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(sURI);
sAlert = 'Check your browser for a new window/tab containing the PCjs script, ';
}
sAlert += 'copy it to your web server as "' + sScript + '.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);
return;
}
web.alertUser("Missing XML/XSL resources");
}
/**
* Prevent the Closure Compiler from renaming functions we want to export, by adding them
* as (named) properties of a global object.
*/
window['savePC'] = savePC;