Support for machines other than PCjs and C1Pjs
This commit is contained in:
parent
a2d183ecfc
commit
79fb14fdbf
7 changed files with 109 additions and 68 deletions
|
|
@ -321,7 +321,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
// src: pkg.pcJSFiles,
|
// src: pkg.pcJSFiles,
|
||||||
src: tmpPCjs,
|
src: tmpPCjs,
|
||||||
dest: "./versions/" + pkg.name + "/" + pkg.version + "/pc.js"
|
dest: "./versions/pcjs/" + pkg.version + "/pc.js"
|
||||||
},
|
},
|
||||||
"pc-dbg.js": {
|
"pc-dbg.js": {
|
||||||
/*
|
/*
|
||||||
|
|
@ -336,7 +336,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
// src: pkg.pcJSFiles,
|
// src: pkg.pcJSFiles,
|
||||||
src: tmpPCjs,
|
src: tmpPCjs,
|
||||||
dest: "./versions/" + pkg.name + "/" + pkg.version + "/pc-dbg.js"
|
dest: "./versions/pcjs/" + pkg.version + "/pc-dbg.js"
|
||||||
},
|
},
|
||||||
"pc8080.js": {
|
"pc8080.js": {
|
||||||
TEMPcompilerOpts: {
|
TEMPcompilerOpts: {
|
||||||
|
|
@ -348,7 +348,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
// src: pkg.pc8080Files,
|
// src: pkg.pc8080Files,
|
||||||
src: tmpPC8080,
|
src: tmpPC8080,
|
||||||
dest: "./versions/" + pkg.name + "/" + pkg.version + "/pc8080.js"
|
dest: "./versions/pc8080/" + pkg.version + "/pc8080.js"
|
||||||
},
|
},
|
||||||
"pc8080-dbg.js": {
|
"pc8080-dbg.js": {
|
||||||
/*
|
/*
|
||||||
|
|
@ -363,7 +363,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
// src: pkg.pc8080Files,
|
// src: pkg.pc8080Files,
|
||||||
src: tmpPC8080,
|
src: tmpPC8080,
|
||||||
dest: "./versions/" + pkg.name + "/" + pkg.version + "/pc8080-dbg.js"
|
dest: "./versions/pc8080/" + pkg.version + "/pc8080-dbg.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
copy: {
|
copy: {
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,9 @@ var sManifestXMLFile = "manifest.xml";
|
||||||
* the closing </head> tag, and JS files are added just before the closing </body> tag.
|
* the closing </head> tag, and JS files are added just before the closing </body> tag.
|
||||||
*/
|
*/
|
||||||
var aMachineFiles = {
|
var aMachineFiles = {
|
||||||
'c1p': pkg.c1pCSSFiles.concat(pkg.c1pJSFiles),
|
'c1p': pkg.c1pCSSFiles.concat(pkg.c1pJSFiles),
|
||||||
'pc': pkg.pcCSSFiles.concat(pkg.pcJSFiles)
|
'pc': pkg.pcCSSFiles.concat(pkg.pcJSFiles),
|
||||||
|
'pc8080': pkg.pcCSSFiles.concat(pkg.pc8080Files)
|
||||||
};
|
};
|
||||||
var aMachineFileTypes = {
|
var aMachineFileTypes = {
|
||||||
'head': [".css"], // put BOTH ".css" and ".js" here if convertMDMachineLinks() embeds its own scripts
|
'head': [".css"], // put BOTH ".css" and ".js" here if convertMDMachineLinks() embeds its own scripts
|
||||||
|
|
@ -1427,10 +1428,11 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
|
||||||
* or "development" stylesheets in ("/modules/pcjs/templates"|"/modules/c1pjs/templates").
|
* or "development" stylesheets in ("/modules/pcjs/templates"|"/modules/c1pjs/templates").
|
||||||
*
|
*
|
||||||
* The common denominator in both sets is either "/pc" or "/c1p", which in turn indicates the class of machine
|
* The common denominator in both sets is either "/pc" or "/c1p", which in turn indicates the class of machine
|
||||||
* (ie, "PC" or "C1P").
|
* (ie, "PCjs" or "C1Pjs").
|
||||||
*/
|
*/
|
||||||
var sMachineClass = (sStyleSheet.indexOf("/pc") >= 0? "PC" : (sStyleSheet.indexOf("/c1p") >= 0? "C1P" : null));
|
aMatch = sStyleSheet.match(/\/(pc|c1p)([^/]*)/);
|
||||||
if (sMachineClass) {
|
if (aMatch) {
|
||||||
|
var sMachineClass = aMatch[1].toUpperCase() + aMatch[2];
|
||||||
/*
|
/*
|
||||||
* Since the MarkOut module already contains the ability to embed a machine definition with
|
* Since the MarkOut module already contains the ability to embed a machine definition with
|
||||||
* one simple line of Markdown-like magic, we'll create such a line and let MarkOut do the rest.
|
* one simple line of Markdown-like magic, we'll create such a line and let MarkOut do the rest.
|
||||||
|
|
@ -1445,7 +1447,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
|
||||||
* options is a comma-delimited series of, well, options; the only option we currently output is "debugger"
|
* options is a comma-delimited series of, well, options; the only option we currently output is "debugger"
|
||||||
* if a <debugger> element is present in the machine XML.
|
* if a <debugger> element is present in the machine XML.
|
||||||
*/
|
*/
|
||||||
var sMachineID = "machine" + sMachineClass; // fallback to either "machinePC" or "machineC1P" if no ID found
|
var sMachineID = "machine" + sMachineClass; // fallback to either "machinePCjs" or "machineC1Pjs" if no ID found
|
||||||
aMatch = sXML.match(/<machine.*?\sid=(['"])(.*?)\1[^>]*>/);
|
aMatch = sXML.match(/<machine.*?\sid=(['"])(.*?)\1[^>]*>/);
|
||||||
if (aMatch) sMachineID = aMatch[2];
|
if (aMatch) sMachineID = aMatch[2];
|
||||||
|
|
||||||
|
|
@ -1455,7 +1457,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
|
||||||
* embedding inside an existing HTML document, so any "machine.xsl" stylesheet must be remapped
|
* embedding inside an existing HTML document, so any "machine.xsl" stylesheet must be remapped
|
||||||
* to a corresponding "components.xsl" stylesheet (which is what the next line does).
|
* to a corresponding "components.xsl" stylesheet (which is what the next line does).
|
||||||
*/
|
*/
|
||||||
var sMachineDef = sMachineClass + "js:" + sMachineID + ":" + sStyleSheet.replace("machine.xsl", "components.xsl");
|
var sMachineDef = sMachineClass + ":" + sMachineID + ":" + sStyleSheet.replace("machine.xsl", "components.xsl");
|
||||||
sMachineDef += (sXML.indexOf("<debugger") > 0? ":*:debugger" : ":*:none");
|
sMachineDef += (sXML.indexOf("<debugger") > 0? ":*:debugger" : ":*:none");
|
||||||
sMachineDef += (sStateFile? ":" + sStateFile : "");
|
sMachineDef += (sStateFile? ":" + sStateFile : "");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1169,7 +1169,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
||||||
* Start looking for Markdown-style machine links now...
|
* Start looking for Markdown-style machine links now...
|
||||||
*/
|
*/
|
||||||
var cMatches = 0;
|
var cMatches = 0;
|
||||||
var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)js([:!|])(.*?)"\)/gi;
|
var reMachines = /\[(.*?)]\((.*?)\s*"(PC|C1P)([a-z0-9-]*)([:!|])(.*?)"\)/gi;
|
||||||
|
|
||||||
while ((aMatch = reMachines.exec(sBlock))) {
|
while ((aMatch = reMachines.exec(sBlock))) {
|
||||||
|
|
||||||
|
|
@ -1177,10 +1177,12 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
||||||
if (sMachineXMLFile.slice(-1) == "/") sMachineXMLFile += "machine.xml";
|
if (sMachineXMLFile.slice(-1) == "/") sMachineXMLFile += "machine.xml";
|
||||||
|
|
||||||
sMachine = aMatch[3].toUpperCase();
|
sMachine = aMatch[3].toUpperCase();
|
||||||
|
if (aMatch[4] != "js") sMachine += aMatch[4];
|
||||||
var sMachineFunc = "embed" + sMachine;
|
var sMachineFunc = "embed" + sMachine;
|
||||||
var sMachineClass = sMachine.toLowerCase();
|
var sMachineClass = sMachine.toLowerCase();
|
||||||
var aMachineParms = aMatch[5].split(aMatch[4]);
|
var aMachineParms = aMatch[6].split(aMatch[5]);
|
||||||
var sMachineMessage = "Waiting for " + sMachine + "js to load";
|
if (aMatch[4] == "js") sMachine += aMatch[4];
|
||||||
|
var sMachineMessage = "Waiting for " + sMachine + " to load";
|
||||||
|
|
||||||
sMachineID = aMachineParms[0];
|
sMachineID = aMachineParms[0];
|
||||||
sMachineXSLFile = aMachineParms[1] || "";
|
sMachineXSLFile = aMachineParms[1] || "";
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,12 @@ Video.init = function()
|
||||||
eVideo.onresize();
|
eVideo.onresize();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* The following is a related hack that allows the user to force the machine to use a particular aspect
|
* The following is a related hack that allows the user to force the screen to use a particular aspect
|
||||||
* ratio if an 'aspect' URL parameter is set. Initially, it's just for testing purposes until we figure
|
* ratio if an 'aspect' attribute or URL parameter is set. Initially, it's just for testing purposes
|
||||||
* out a better UI. And note that we use our web.onPageEvent() helper function to make sure we don't
|
* until we figure out a better UI. And note that we use our web.onPageEvent() helper function to make
|
||||||
* trample any other 'onresize' handler(s) attached to the window object.
|
* sure we don't trample any other 'onresize' handler(s) attached to the window object.
|
||||||
*/
|
*/
|
||||||
var aspect = +Component.parmsURL['aspect'];
|
var aspect = +(parmsVideo['aspect'] || Component.parmsURL['aspect']);
|
||||||
/*
|
/*
|
||||||
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
||||||
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
||||||
|
|
|
||||||
|
|
@ -7275,12 +7275,12 @@ Video.init = function()
|
||||||
eVideo.onresize();
|
eVideo.onresize();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* The following is a related hack that allows the user to force the machine to use a particular aspect
|
* The following is a related hack that allows the user to force the screen to use a particular aspect
|
||||||
* ratio if an 'aspect' URL parameter is set. Initially, it's just for testing purposes until we figure
|
* ratio if an 'aspect' attribute or URL parameter is set. Initially, it's just for testing purposes
|
||||||
* out a better UI. And note that we use our web.onPageEvent() helper function to make sure we don't
|
* until we figure out a better UI. And note that we use our web.onPageEvent() helper function to make
|
||||||
* trample any other 'onresize' handler(s) attached to the window object.
|
* sure we don't trample any other 'onresize' handler(s) attached to the window object.
|
||||||
*/
|
*/
|
||||||
var aspect = +Component.parmsURL['aspect'];
|
var aspect = +(parmsVideo['aspect'] || Component.parmsURL['aspect']);
|
||||||
/*
|
/*
|
||||||
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
* No 'aspect' parameter yields NaN, which is falsey, and anything else must satisfy my arbitrary
|
||||||
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
* constraints of 0.3 <= aspect <= 3.33, to prevent any useless (or worse, browser-blowing) results.
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ var fAsync = true;
|
||||||
var cAsyncMachines = 0;
|
var cAsyncMachines = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loadXML(sFile, idMachine, sParms, fResolve, display, done)
|
* loadXML(sFile, idMachine, sAppClass, sParms, fResolve, display, done)
|
||||||
*
|
*
|
||||||
* This is the preferred way to load all XML and XSL files. It uses getResource()
|
* This is the preferred way to load all XML and XSL files. It uses getResource()
|
||||||
* to load them as strings, which parseXML() can massage before parsing/transforming them.
|
* to load them as strings, which parseXML() can massage before parsing/transforming them.
|
||||||
|
|
@ -81,12 +81,13 @@ var cAsyncMachines = 0;
|
||||||
*
|
*
|
||||||
* @param {string} sXMLFile
|
* @param {string} sXMLFile
|
||||||
* @param {string|null|undefined} idMachine
|
* @param {string|null|undefined} idMachine
|
||||||
|
* @param {string|null|undefined} sAppClass
|
||||||
* @param {string|null|undefined} sParms
|
* @param {string|null|undefined} sParms
|
||||||
* @param {boolean} fResolve is true to resolve any "ref" attributes
|
* @param {boolean} fResolve is true to resolve any "ref" attributes
|
||||||
* @param {function(string)} display
|
* @param {function(string)} display
|
||||||
* @param {function(string,Object)} done (string contains the unparsed XML string data, and Object contains a parsed XML object)
|
* @param {function(string,Object)} done (string contains the unparsed XML string data, and Object contains a parsed XML object)
|
||||||
*/
|
*/
|
||||||
function loadXML(sXMLFile, idMachine, sParms, fResolve, display, done)
|
function loadXML(sXMLFile, idMachine, sAppClass, sParms, fResolve, display, done)
|
||||||
{
|
{
|
||||||
var doneLoadXML = function(sURLName, sXML, nErrorCode) {
|
var doneLoadXML = function(sURLName, sXML, nErrorCode) {
|
||||||
if (nErrorCode) {
|
if (nErrorCode) {
|
||||||
|
|
@ -94,14 +95,14 @@ function loadXML(sXMLFile, idMachine, sParms, fResolve, display, done)
|
||||||
done(sXML, null);
|
done(sXML, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done);
|
parseXML(sXML, sXMLFile, idMachine, sAppClass, sParms, fResolve, display, done);
|
||||||
};
|
};
|
||||||
display("Loading " + sXMLFile + "...");
|
display("Loading " + sXMLFile + "...");
|
||||||
web.getResource(sXMLFile, null, fAsync, doneLoadXML);
|
web.getResource(sXMLFile, null, fAsync, doneLoadXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
|
* parseXML(sXML, sXMLFile, idMachine, sAppClass, sParms, fResolve, display, done)
|
||||||
*
|
*
|
||||||
* Generates an XML document from an XML string. This function also provides a work-around for XSLT's
|
* Generates an XML document from an XML string. This function also provides a work-around for XSLT's
|
||||||
* lack of support for the document() function (at least on some browsers), by replacing every reference
|
* lack of support for the document() function (at least on some browsers), by replacing every reference
|
||||||
|
|
@ -110,12 +111,13 @@ function loadXML(sXMLFile, idMachine, sParms, fResolve, display, done)
|
||||||
* @param {string} sXML
|
* @param {string} sXML
|
||||||
* @param {string|null} sXMLFile
|
* @param {string|null} sXMLFile
|
||||||
* @param {string|null|undefined} idMachine
|
* @param {string|null|undefined} idMachine
|
||||||
|
* @param {string|null|undefined} sAppClass
|
||||||
* @param {string|null|undefined} sParms
|
* @param {string|null|undefined} sParms
|
||||||
* @param {boolean} fResolve is true to resolve any "ref" attributes; default is false
|
* @param {boolean} fResolve is true to resolve any "ref" attributes; default is false
|
||||||
* @param {function(string)} display
|
* @param {function(string)} display
|
||||||
* @param {function(string,Object)} done (string contains the unparsed XML string data, and Object contains a parsed XML object)
|
* @param {function(string,Object)} done (string contains the unparsed XML string data, and Object contains a parsed XML object)
|
||||||
*/
|
*/
|
||||||
function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
|
function parseXML(sXML, sXMLFile, idMachine, sAppClass, sParms, fResolve, display, done)
|
||||||
{
|
{
|
||||||
var buildXML = function(sXML, sError) {
|
var buildXML = function(sXML, sError) {
|
||||||
if (sError) {
|
if (sError) {
|
||||||
|
|
@ -159,13 +161,23 @@ function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
|
||||||
if (typeof resources == 'object') sURL = null; // turn off URL inclusion if we have embedded resources
|
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 + '"' : ''));
|
sXML = sXML.replace(/(<machine[^>]*\sid=)(['"]).*?\2/, "$1$2" + idMachine + "$2" + (sParms? " parms='" + sParms + "'" : "") + (sURL? ' url="' + sURL + '"' : ''));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Non-COMPILED kludge to replace the version number template in the XSL file (which we assume we're reading,
|
if (!fResolve) {
|
||||||
* since fResolve is false) with whatever XMLVERSION we extracted from the XML file (see corresponding kludge below).
|
/*
|
||||||
*/
|
* I'm trying to switch to a shared components.xsl (at least for all PC-class machines),
|
||||||
if (!COMPILED && !fResolve && XMLVERSION) {
|
* but in the interim, that means hacking the XSL file on the fly to reflect the chosen class.
|
||||||
sXML = sXML.replace(/<xsl:variable name="APPVERSION">1.x.x<\/xsl:variable>/, '<xsl:variable name="APPVERSION">' + XMLVERSION + '</xsl:variable>');
|
*/
|
||||||
|
sXML = sXML.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/, "$1" + sAppClass + "$2");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non-COMPILED kludge to replace the version number template in the XSL file (which we assume we're reading,
|
||||||
|
* since fResolve is false) with whatever XMLVERSION we extracted from the XML file (see corresponding kludge below).
|
||||||
|
*/
|
||||||
|
if (!COMPILED && XMLVERSION) {
|
||||||
|
sXML = sXML.replace(/<xsl:variable name="APPVERSION">1.x.x<\/xsl:variable>/, '<xsl:variable name="APPVERSION">' + XMLVERSION + '</xsl:variable>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the resource we requested is not really an XML file (or the file didn't exist and the server simply returned
|
* If the resource we requested is not really an XML file (or the file didn't exist and the server simply returned
|
||||||
* a message like "Cannot GET /devices/pc/machine/5150/cga/64kb/donkey/machine.xml"), we'd like to display a more
|
* a message like "Cannot GET /devices/pc/machine/5150/cga/64kb/donkey/machine.xml"), we'd like to display a more
|
||||||
|
|
@ -200,7 +212,7 @@ function parseXML(sXML, sXMLFile, idMachine, sParms, fResolve, display, done)
|
||||||
* we want to continue supporting older Internet Explorer browsers (ie, back to IE9).
|
* we want to continue supporting older Internet Explorer browsers (ie, back to IE9).
|
||||||
*/
|
*/
|
||||||
/** @namespace window.ActiveXObject */
|
/** @namespace window.ActiveXObject */
|
||||||
if (window.ActiveXObject || 'ActiveXObject' in window) { // second test is required for IE11 on Windows 8.1
|
if (window.ActiveXObject || 'ActiveXObject' in window) { // second test is required for IE11 on Windows 8.1
|
||||||
xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
|
xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
|
||||||
xmlDoc.async = false;
|
xmlDoc.async = false;
|
||||||
xmlDoc['loadXML'](sXML);
|
xmlDoc['loadXML'](sXML);
|
||||||
|
|
@ -404,11 +416,13 @@ function embedMachine(sName, sVersion, idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
sXSLFile = "/versions/" + sAppClass + "/" + sVersion + "/components.xsl";
|
sXSLFile = "/versions/" + sAppClass + "/" + sVersion + "/components.xsl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var loadXSL = function(sXML, xml) {
|
|
||||||
|
var processXML = function(sXML, xml) {
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
displayError(sXML);
|
displayError(sXML);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Non-COMPILED kludge to extract the version number from the stylesheet path in the machine XML file;
|
* Non-COMPILED kludge to extract the version number from the stylesheet path in the machine XML file;
|
||||||
* we don't need this code in COMPILED (non-DEBUG) releases, because APPVERSION is hard-coded into them.
|
* we don't need this code in COMPILED (non-DEBUG) releases, because APPVERSION is hard-coded into them.
|
||||||
|
|
@ -417,15 +431,18 @@ function embedMachine(sName, sVersion, idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
var aMatch = sXML.match(/<\?xml-stylesheet[^>]* href=(['"])[^'"]*?\/([0-9.]*)\/([^'"]*)\1/);
|
var aMatch = sXML.match(/<\?xml-stylesheet[^>]* href=(['"])[^'"]*?\/([0-9.]*)\/([^'"]*)\1/);
|
||||||
if (aMatch) XMLVERSION = aMatch[2];
|
if (aMatch) XMLVERSION = aMatch[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
var transformXML = function(sXSL, xsl) {
|
var transformXML = function(sXSL, xsl) {
|
||||||
if (!xsl) {
|
if (!xsl) {
|
||||||
displayError(sXSL);
|
displayError(sXSL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Record the XSL file, in case someone wants to save the entire machine later.
|
* Record the XSL file, in case someone wants to save the entire machine later.
|
||||||
*/
|
*/
|
||||||
Component.addMachineResource(idMachine, sXSLFile, sXSL);
|
Component.addMachineResource(idMachine, sXSLFile, sXSL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The <machine> template in components.xsl now generates a "machine div" that makes
|
* The <machine> template in components.xsl now generates a "machine div" that makes
|
||||||
* the div we required the caller of embedMachine() to provide redundant, so instead
|
* the div we required the caller of embedMachine() to provide redundant, so instead
|
||||||
|
|
@ -440,6 +457,7 @@ function embedMachine(sName, sVersion, idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
* embeddable HTML (and is the most common cause of failure at this final stage).
|
* embeddable HTML (and is the most common cause of failure at this final stage).
|
||||||
*/
|
*/
|
||||||
displayMessage("Processing " + sXMLFile + "...");
|
displayMessage("Processing " + sXMLFile + "...");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Beginning with Microsoft Edge and the corresponding release of Windows 10, all the
|
* Beginning with Microsoft Edge and the corresponding release of Windows 10, all the
|
||||||
* 'ActiveXObject' crud has gone away; but of course, this code must remain in place if
|
* 'ActiveXObject' crud has gone away; but of course, this code must remain in place if
|
||||||
|
|
@ -485,12 +503,13 @@ function embedMachine(sName, sVersion, idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
displayError("unable to transform XML: unsupported browser");
|
displayError("unable to transform XML: unsupported browser");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
loadXML(sXSLFile, null, null, false, displayMessage, transformXML);
|
loadXML(sXSLFile, null, sAppClass, null, false, displayMessage, transformXML);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sXMLFile.charAt(0) != '<') {
|
if (sXMLFile.charAt(0) != '<') {
|
||||||
loadXML(sXMLFile, idMachine, sParms, true, displayMessage, loadXSL);
|
loadXML(sXMLFile, idMachine, sAppClass, sParms, true, displayMessage, processXML);
|
||||||
} else {
|
} else {
|
||||||
parseXML(sXMLFile, null, idMachine, sParms, false, displayMessage, loadXSL);
|
parseXML(sXMLFile, null, idMachine, sAppClass, sParms, false, displayMessage, processXML);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayError("missing machine element: " + idMachine);
|
displayError("missing machine element: " + idMachine);
|
||||||
|
|
@ -531,16 +550,27 @@ function embedPC(idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent the Closure Compiler from renaming functions we want to export, by adding them
|
* embedPC8080(idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
* as (named) properties of a global object.
|
*
|
||||||
|
* @param {string} idMachine
|
||||||
|
* @param {string} sXMLFile
|
||||||
|
* @param {string} sXSLFile
|
||||||
|
* @param {string} [sParms]
|
||||||
|
* @return {boolean} true if successful, false if error
|
||||||
*/
|
*/
|
||||||
if (APPNAME == "PCjs") {
|
function embedPC8080(idMachine, sXMLFile, sXSLFile, sParms)
|
||||||
window['embedPC'] = embedPC;
|
{
|
||||||
|
if (fAsync) web.enablePageEvents(false);
|
||||||
|
return embedMachine("PC8080", APPVERSION, idMachine, sXMLFile, sXSLFile, sParms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APPNAME == "C1Pjs") {
|
/**
|
||||||
window['embedC1P'] = embedC1P;
|
* Prevent the Closure Compiler from renaming functions we want to export,
|
||||||
}
|
* by adding them as (named) properties of a global object.
|
||||||
|
*/
|
||||||
|
if (APPNAME == "C1Pjs") window['embedC1P'] = embedC1P;
|
||||||
|
if (APPNAME == "PCjs") window['embedPC'] = embedPC;
|
||||||
|
if (APPNAME == "PC8080") window['embedPC8080'] = embedPC8080;
|
||||||
|
|
||||||
window['enableEvents'] = web.enablePageEvents;
|
window['enableEvents'] = web.enablePageEvents;
|
||||||
window['sendEvent'] = web.sendPageEvent;
|
window['sendEvent'] = web.sendPageEvent;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
<xsl:param name="generator" select="'client'"/>
|
<xsl:param name="generator" select="'client'"/>
|
||||||
|
|
||||||
<xsl:variable name="MACHINECLASS">pc</xsl:variable>
|
<xsl:variable name="MACHINECLASS">pc</xsl:variable>
|
||||||
|
<xsl:variable name="CSSCLASS">pcjs</xsl:variable>
|
||||||
<xsl:variable name="APPCLASS">pcjs</xsl:variable>
|
<xsl:variable name="APPCLASS">pcjs</xsl:variable>
|
||||||
<xsl:variable name="APPVERSION">1.x.x</xsl:variable>
|
<xsl:variable name="APPVERSION">1.x.x</xsl:variable>
|
||||||
<xsl:variable name="SITEHOST">www.pcjs.org</xsl:variable>
|
<xsl:variable name="SITEHOST">www.pcjs.org</xsl:variable>
|
||||||
|
|
@ -58,7 +59,13 @@
|
||||||
<xsl:variable name="machineStyle">
|
<xsl:variable name="machineStyle">
|
||||||
<xsl:if test="@float">float:<xsl:value-of select="@float"/></xsl:if>
|
<xsl:if test="@float">float:<xsl:value-of select="@float"/></xsl:if>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<div id="{$machine}" class="machine {@class}js" style="{$machineStyle}">
|
<xsl:variable name="machineClass">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@class = 'pc' or @class = 'c1p'"><xsl:value-of select="@class"/>js</xsl:when>
|
||||||
|
<xsl:otherwise><xsl:value-of select="@class"/></xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
<div id="{$machine}" class="machine {$machineClass}" style="{$machineStyle}">
|
||||||
<xsl:call-template name="component">
|
<xsl:call-template name="component">
|
||||||
<xsl:with-param name="machine" select="$machine"/>
|
<xsl:with-param name="machine" select="$machine"/>
|
||||||
<xsl:with-param name="machineState">
|
<xsl:with-param name="machineState">
|
||||||
|
|
@ -204,7 +211,7 @@
|
||||||
<xsl:if test="$component != 'machine'">
|
<xsl:if test="$component != 'machine'">
|
||||||
<xsl:apply-templates select="name" mode="component"/>
|
<xsl:apply-templates select="name" mode="component"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
<div class="{$APPCLASS}-container" style="{$border}{$style}">
|
<div class="{$CSSCLASS}-container" style="{$border}{$style}">
|
||||||
<xsl:if test="$component = 'machine'">
|
<xsl:if test="$component = 'machine'">
|
||||||
<xsl:apply-templates select="menu" mode="machine"/>
|
<xsl:apply-templates select="menu" mode="machine"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
@ -226,11 +233,11 @@
|
||||||
</div>
|
</div>
|
||||||
<xsl:if test="$component = 'machine'">
|
<xsl:if test="$component = 'machine'">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$url != ''"><div class="{$APPCLASS}-reference">[<a href="{$url}">XML</a>]</div></xsl:when>
|
<xsl:when test="$url != ''"><div class="{$CSSCLASS}-reference">[<a href="{$url}">XML</a>]</div></xsl:when>
|
||||||
<xsl:otherwise/>
|
<xsl:otherwise/>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:if test="$MACHINECLASS = 'pc'"><div class="{$APPCLASS}-reference" style="padding-left:8px">[<a href="#" onclick="savePC('{$machine}'); return false;">Save Machine</a>]</div></xsl:if>
|
<xsl:if test="$MACHINECLASS = 'pc'"><div class="{$CSSCLASS}-reference" style="padding-left:8px">[<a href="#" onclick="savePC('{$machine}'); return false;">Save Machine</a>]</div></xsl:if>
|
||||||
<div class="{$APPCLASS}-copyright">
|
<div class="{$CSSCLASS}-copyright">
|
||||||
<a href="http://{$SITEHOST}" target="_blank">PCjs</a> v<xsl:value-of select="$APPVERSION"/> © 2012-2016 by <a href="http://twitter.com/jeffpar" target="_blank">@jeffpar</a>
|
<a href="http://{$SITEHOST}" target="_blank">PCjs</a> v<xsl:value-of select="$APPVERSION"/> © 2012-2016 by <a href="http://twitter.com/jeffpar" target="_blank">@jeffpar</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear:both"> </div>
|
<div style="clear:both"> </div>
|
||||||
|
|
@ -249,7 +256,7 @@
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="name" mode="component">
|
<xsl:template match="name" mode="component">
|
||||||
<div class="{$APPCLASS}-name"><xsl:apply-templates/></div>
|
<div class="{$CSSCLASS}-name"><xsl:apply-templates/></div>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="menu" mode="component">
|
<xsl:template match="menu" mode="component">
|
||||||
|
|
@ -257,7 +264,7 @@
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="title" mode="component">
|
<xsl:template match="title" mode="component">
|
||||||
<div class="{$APPCLASS}-menu"><xsl:apply-templates/></div>
|
<div class="{$CSSCLASS}-menu"><xsl:apply-templates/></div>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="control" mode="component">
|
<xsl:template match="control" mode="component">
|
||||||
|
|
@ -346,7 +353,7 @@
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:variable name="subClass">
|
<xsl:variable name="subClass">
|
||||||
<xsl:if test="@label"><xsl:text> </xsl:text><xsl:value-of select="$APPCLASS"/><xsl:text>-label</xsl:text></xsl:if>
|
<xsl:if test="@label"><xsl:text> </xsl:text><xsl:value-of select="$CSSCLASS"/><xsl:text>-label</xsl:text></xsl:if>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:variable name="labelWidth">
|
<xsl:variable name="labelWidth">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
|
|
@ -364,43 +371,43 @@
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
<xsl:if test="@label">
|
<xsl:if test="@label">
|
||||||
<xsl:if test="not(@labelpos) or @labelpos = 'left'">
|
<xsl:if test="not(@labelpos) or @labelpos = 'left'">
|
||||||
<div class="{$APPCLASS}-label" style="{$labelWidth}{$labelStyle}"><xsl:value-of select="@label"/></div>
|
<div class="{$CSSCLASS}-label" style="{$labelWidth}{$labelStyle}"><xsl:value-of select="@label"/></div>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@type = 'canvas'">
|
<xsl:when test="@type = 'canvas'">
|
||||||
<canvas class="{$APPCLASS}-binding {$APPCLASS}-canvas" width="{@width}" height="{@height}" style="-webkit-user-select:none;{$border}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></canvas>
|
<canvas class="{$CSSCLASS}-binding {$CSSCLASS}-canvas" width="{@width}" height="{@height}" style="-webkit-user-select:none;{$border}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></canvas>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'button'">
|
<xsl:when test="@type = 'button'">
|
||||||
<button class="{$APPCLASS}-binding" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding},{$value}}}"><xsl:apply-templates/></button>
|
<button class="{$CSSCLASS}-binding" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding},{$value}}}"><xsl:apply-templates/></button>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'list'">
|
<xsl:when test="@type = 'list'">
|
||||||
<select class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}">
|
<select class="{$CSSCLASS}-binding" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}">
|
||||||
<xsl:apply-templates select="disk|app|manifest" mode="component"/>
|
<xsl:apply-templates select="disk|app|manifest" mode="component"/>
|
||||||
</select>
|
</select>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'text'">
|
<xsl:when test="@type = 'text'">
|
||||||
<input class="{$APPCLASS}-binding" type="text" style="{$border}{$width}{$height}{$style}" data-value="{{{$type},{$binding}}}" value="{.}" autocapitalize="off" autocorrect="off"/>
|
<input class="{$CSSCLASS}-binding" type="text" style="{$border}{$width}{$height}{$style}" data-value="{{{$type},{$binding}}}" value="{.}" autocapitalize="off" autocorrect="off"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'submit'">
|
<xsl:when test="@type = 'submit'">
|
||||||
<input class="{$APPCLASS}-binding" type="submit" style="{$border}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}" value="{.}"/>
|
<input class="{$CSSCLASS}-binding" type="submit" style="{$border}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}" value="{.}"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'textarea'">
|
<xsl:when test="@type = 'textarea'">
|
||||||
<textarea class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$style}" data-value="{{{$type},{$binding}}}" readonly="readonly" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"> </textarea>
|
<textarea class="{$CSSCLASS}-binding" style="{$border}{$width}{$height}{$style}" data-value="{{{$type},{$binding}}}" readonly="readonly" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"> </textarea>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'heading'">
|
<xsl:when test="@type = 'heading'">
|
||||||
<div><xsl:value-of select="."/></div>
|
<div><xsl:value-of select="."/></div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'file'">
|
<xsl:when test="@type = 'file'">
|
||||||
<form class="{$APPCLASS}-binding" data-value="{{{$type},{$binding}}}">
|
<form class="{$CSSCLASS}-binding" data-value="{{{$type},{$binding}}}">
|
||||||
<fieldset class="{$APPCLASS}-fieldset">
|
<fieldset class="{$CSSCLASS}-fieldset">
|
||||||
<input type="file"/>
|
<input type="file"/>
|
||||||
<input type="submit" value="Mount" disabled="true"/>
|
<input type="submit" value="Mount" disabled="true"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'led'">
|
<xsl:when test="@type = 'led'">
|
||||||
<div class="{$APPCLASS}-binding {$APPCLASS}-{@type}" data-value="{{{$type},{$binding}}}"><xsl:value-of select="."/></div>
|
<div class="{$CSSCLASS}-binding {$CSSCLASS}-{@type}" data-value="{{{$type},{$binding}}}"><xsl:value-of select="."/></div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'separator'">
|
<xsl:when test="@type = 'separator'">
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
@ -412,12 +419,12 @@
|
||||||
<div style="clear:both"> </div>
|
<div style="clear:both"> </div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<div class="{$APPCLASS}-binding{$subClass} {$APPCLASS}-{@type}" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></div>
|
<div class="{$CSSCLASS}-binding{$subClass} {$CSSCLASS}-{@type}" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding}}}"><xsl:apply-templates/></div>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:if test="@label">
|
<xsl:if test="@label">
|
||||||
<xsl:if test="@labelpos = 'right'">
|
<xsl:if test="@labelpos = 'right'">
|
||||||
<div class="{$APPCLASS}-label" style="{$labelWidth}{$labelStyle}"><xsl:value-of select="@label"/></div>
|
<div class="{$CSSCLASS}-label" style="{$labelWidth}{$labelStyle}"><xsl:value-of select="@label"/></div>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
<div style="clear:both"> </div>
|
<div style="clear:both"> </div>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue