Added code to extract the machine XML version number when running DEBUG-only
This commit is contained in:
parent
a061c16392
commit
2e89c38e4a
7 changed files with 2096 additions and 2080 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1241,6 +1241,11 @@ Computer.prototype.getComponentByType = function(sType, componentPrev)
|
||||||
*/
|
*/
|
||||||
Computer.init = function()
|
Computer.init = function()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* In DEBUG builds, embedMachine() may have set DEBUG_APPVERSION.
|
||||||
|
*/
|
||||||
|
if (DEBUG && DEBUG_APPVERSION) Computer.sAppVer = DEBUG_APPVERSION;
|
||||||
|
|
||||||
var aeMachines = Component.getElementsByClass(window.document, PCJSCLASS + "-machine");
|
var aeMachines = Component.getElementsByClass(window.document, PCJSCLASS + "-machine");
|
||||||
|
|
||||||
for (var iMachine = 0; iMachine < aeMachines.length; iMachine++) {
|
for (var iMachine = 0; iMachine < aeMachines.length; iMachine++) {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ var APPNAME = ""; // this @define is overridden by the Closure Com
|
||||||
*/
|
*/
|
||||||
var APPVERSION = "1.x.x"; // this @define is overridden by the Closure Compiler with the version in package.json
|
var APPVERSION = "1.x.x"; // this @define is overridden by the Closure Compiler with the version in package.json
|
||||||
|
|
||||||
|
var DEBUG_APPVERSION = null; // this is set in DEBUG builds by embedMachine() if a version number was found in the machine XML
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @define {string}
|
* @define {string}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,13 @@ function parseXML(sXML, sXMLFile, idMachine, sStateFile, fResolve, display, done
|
||||||
if (sURL && sURL.indexOf('/') < 0) sURL = window.location.pathname + sURL;
|
if (sURL && sURL.indexOf('/') < 0) sURL = window.location.pathname + sURL;
|
||||||
sXML = sXML.replace(/(<machine[^>]*\sid=)(['"]).*?\2/, "$1$2" + idMachine + "$2" + (sStateFile? " state=$2" + sStateFile + "$2" : "") + (sURL? " url=$2" + sURL + "$2" : ""));
|
sXML = sXML.replace(/(<machine[^>]*\sid=)(['"]).*?\2/, "$1$2" + idMachine + "$2" + (sStateFile? " state=$2" + sStateFile + "$2" : "") + (sURL? " url=$2" + sURL + "$2" : ""));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* DEBUG-only kludge to replace the version number template in the XSL file (which we assume we're reading,
|
||||||
|
* since fResolve is false) with any APPVERSION we extracted from the XML file (see corresponding kludge below).
|
||||||
|
*/
|
||||||
|
if (DEBUG && !fResolve && DEBUG_APPVERSION) {
|
||||||
|
sXML = sXML.replace(/<xsl:variable name="APPVERSION">1.x.x<\/xsl:variable>/, '<xsl:variable name="APPVERSION">' + DEBUG_APPVERSION + '</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
|
||||||
|
|
@ -339,6 +346,14 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sStateFile
|
||||||
displayError(sXML);
|
displayError(sXML);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* DEBUG-only 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.
|
||||||
|
*/
|
||||||
|
if (DEBUG) {
|
||||||
|
var aMatch = sXML.match(/<\?xml-stylesheet[^>]* href=(['"])[^'"]*?\/([0-9.]*)\/([^'"]*)\1/);
|
||||||
|
if (aMatch && APPVERSION == "1.x.x") DEBUG_APPVERSION = aMatch[2];
|
||||||
|
}
|
||||||
var transformXML = function(sXSL, xsl) {
|
var transformXML = function(sXSL, xsl) {
|
||||||
if (!xsl) {
|
if (!xsl) {
|
||||||
displayError(sXSL);
|
displayError(sXSL);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue