; it's purely a mechanism for telling the script where to embed the machine, so we could
* auto-generate an ID for you, but on the other hand, there might actually be situations where you want to style
@@ -989,7 +1032,7 @@ MarkOut.prototype.convertMDImageLinks = function(sBlock, sIndent)
MarkOut.prototype.convertMDMachineLinks = function(sBlock)
{
var aMatch, sReplacement;
- var sMachine, sMachineID, sMachineXMLFile, sMachineXSLFile, sMachineVersion, sMachineOptions, sMachineState;
+ var sMachine, sMachineID, sMachineXMLFile, sMachineXSLFile, sMachineVersion, sMachineOptions, sMachineParms;
/*
* Before we start looking for Markdown-style machine links, see if there are any Liquid-style machines,
@@ -1008,8 +1051,8 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
sMachineXMLFile = machine['config'] || "machine.xml";
sMachineXSLFile = machine['template'] || "";
sMachineVersion = (machine['uncompiled'] && machine['uncompiled'] == "true"? "uncompiled" : "");
- sMachineState = machine['state'] || "";
- sReplacement = "[Embedded PC](" + sMachineXMLFile + ' "' + sMachine + 'js:' + sMachineID + ':' + sMachineXSLFile + '::' + sMachineOptions + ':' + sMachineState + '")';
+ sMachineParms = machine['parms'] || "";
+ sReplacement = "[Embedded PC](" + sMachineXMLFile + ' "' + sMachine + 'js|' + sMachineID + '|' + sMachineXSLFile + '||' + sMachineOptions + '|' + sMachineParms + '")';
}
sBlock = sBlock.replace(aMatch[0], sReplacement);
reIncludes.lastIndex = 0; // reset lastIndex, since we just modified the string that reIncludes is iterating over
@@ -1019,7 +1062,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
* Start looking for Markdown-style machine links now...
*/
var cMatches = 0;
- var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)js:(.*?)"\)/gi;
+ var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)js[:|](.*?)"\)/gi;
while ((aMatch = reMachines.exec(sBlock))) {
@@ -1029,14 +1072,14 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
sMachine = aMatch[3].toUpperCase();
var sMachineFunc = "embed" + sMachine;
var sMachineClass = sMachine.toLowerCase();
- var aMachineParms = aMatch[4].split(':');
+ var aMachineParms = aMatch[4].split(aMatch[4].indexOf('|') > 0? '|' : ':');
var sMachineMessage = "Waiting for " + sMachine + "js to load";
sMachineID = aMachineParms[0];
sMachineXSLFile = aMachineParms[1] || "";
sMachineVersion = aMachineParms[2] || this.sMachineVersion;
sMachineOptions = aMachineParms[3] || "";
- sMachineState = aMachineParms[4] || "";
+ sMachineParms = aMachineParms[4] || "";
var aMachineOptions = sMachineOptions.split(',');
var fDebugger = (aMachineOptions.indexOf("debugger") >= 0);
@@ -1071,14 +1114,14 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
cMatches++;
this.addMachine({
- 'class': sMachineClass, // eg, a machine class, such as "pc" or "c1p"
- 'func': sMachineFunc,
- 'id': sMachineID,
- 'xml': sMachineXMLFile,
- 'xsl': sMachineXSLFile,
- 'version': sMachineVersion, // eg, "1.10", "*" to select the current version, or "uncompiled"; "*" is the default
+ 'class': sMachineClass, // eg, a machine class, such as "pc" or "c1p"
+ 'func': sMachineFunc,
+ 'id': sMachineID,
+ 'xml': sMachineXMLFile,
+ 'xsl': sMachineXSLFile,
+ 'version': sMachineVersion,// eg, "1.10", "*" to select the current version, or "uncompiled"; "*" is the default
'debugger': fDebugger, // eg, true or false; false is the default
- 'state': sMachineState}
+ 'parms': sMachineParms}
);
}
diff --git a/modules/shared/lib/embed.js b/modules/shared/lib/embed.js
index df2694487..0a4b6c866 100644
--- a/modules/shared/lib/embed.js
+++ b/modules/shared/lib/embed.js
@@ -131,13 +131,22 @@ function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
*/
if (!sParms) {
sParms = '{';
- } else if (sParms.substr(0, 1) == '{') {
+ } else if (sParms.slice(-1) == '}') {
sParms = sParms.slice(0, -1);
if (sParms.length > 1) sParms += ',';
- } else { // backward compatibility: sParms is actually sStateFile
+ } else { // sParms must just be a "state" file, so encode it as a "state" property
sParms = '{state:"' + sParms + '",';
}
sParms += 'url:"' + sURL + '"}';
+ /*
+ * Note that while we no longer generate a machine XML file with a "state" attribute (because it's
+ * encoded inside the "parms" attribute), the XSL file must still cope with "state" attributes inside
+ * other XML files; for example, manifest XML files like /apps/pc/1981/visicalc/manifest.xml contain
+ * machine elements with "state" attributes that must still be passed down to the computer element
+ * "the old fashioned way".
+ *
+ * Until/unless that changes, components.xsl cannot be simplified as much as I might have hoped.
+ */
sXML = sXML.replace(/(
]*\sid=)(['"]).*?\2/, "$1$2" + idMachine + "$2" + (sParms? " parms='" + sParms + "'" : "") + (sURL? ' url="' + sURL + '"' : ''));
}
/*
diff --git a/versions/pcjs/1.20.4/pc-dbg.js b/versions/pcjs/1.20.4/pc-dbg.js
index 7282a30f3..a5bc3284b 100644
--- a/versions/pcjs/1.20.4/pc-dbg.js
+++ b/versions/pcjs/1.20.4/pc-dbg.js
@@ -1210,7 +1210,7 @@ function kr(a,b){a.A=null;var c=za(Aa()+"/api/v1/user?req=verify&user="+b),d=c[1
function jr(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=Xq(a,er);d.data=c;b=za(Aa()+"/api/v1/user",!1,d);d=b[1];if(b[0]){if(d){var e=d.indexOf("\n");0k.indexOf("/")&&(k=window.location.pathname+k);d?"{"==d.substr(0,1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(k?' url="'+k+'"':""))}k=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(k=new window.ActiveXObject("Microsoft.XMLDOM"),
+function nr(a,b,c,d,e,f,g){function k(a,f){if(f)g(f,null);else{if(c){var k=b;k&&0>k.indexOf("/")&&(k=window.location.pathname+k);d?"}"==d.slice(-1)?(d=d.slice(0,-1),1]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(k?' url="'+k+'"':""))}k=null;if("<"==a.charAt(0))try{e||(a=a.replace(/\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(k=new window.ActiveXObject("Microsoft.XMLDOM"),
k.async=!1,k.loadXML(a)):k=(new window.DOMParser).parseFromString(a,"text/xml")}catch(B){k=null,a=B.message}else a="unrecognized XML: "+(255/g.exec(a)){var e=d[2];b("Loading "+e+"...");za(e,!0,null,null,function(f,g,k){if(k||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+k+")");else{if(f=d[3])if(k=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var q=k[0],r,x=/( [a-z]+=)(['"])(.*?)\2/g;r=x.exec(f);)q=0>q.indexOf(r[1])?q.replace(">",r[0]+">"):q.replace(new RegExp(r[1]+"(['\"])(.*?)\\1"),r[0]);k[0]!=q&&(g=g.replace(k[0],q))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/,
"");a=a.replace(d[0],g);yr(a,b,c)}})}else c(a,null)}