]*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 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," + (web.isUserAgent("Firefox")? encodeURIComponent(sPCJS) : encodeURI(sPCJS));
}
var link = document.createElement('a');
if (typeof link.download == 'string' && sPCJS.length < 2000000) {
link.href = uri;
link.download = sScript + ".json";
document.body.appendChild(link); // Firefox requires the link to be in the body (?)
link.click();
document.body.removeChild(link);
} else {
window.open(uri);
}
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 += '\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;