From cd36be4e1984f896d9bc6303c9aa5b230ceb4413 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 9 Dec 2015 13:56:11 -0800 Subject: [PATCH] Fixed support for compiled scripts, and improved error reporting if XML transformation didn't produce a valid machine element --- _config.yml | 2 +- _includes/machine-engines.html | 16 +++++++++--- devices/c1p/machine/8kb/array/README.md | 33 +++++++++++++++++++++++++ modules/shared/lib/embed.js | 10 +++++--- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/_config.yml b/_config.yml index 7d0b7eafe..d6e497543 100644 --- a/_config.yml +++ b/_config.yml @@ -20,7 +20,7 @@ kramdown: # Custom site settings pcjs_domain: pcjs.net pcjs_version: 1.20.1 -pcjs_compiled: false +pcjs_compiled: true c1pjs_scripts: - /modules/shared/lib/defines.js diff --git a/_includes/machine-engines.html b/_includes/machine-engines.html index 7e074d0bf..acbc6f392 100644 --- a/_includes/machine-engines.html +++ b/_includes/machine-engines.html @@ -3,15 +3,22 @@ {% unless machine.config %} {% assign machine_config = "machine.xml" %} {% else %} - {% capture machine_config %}{{ machine.config }}{% endcapture %} + {% assign machine_config = machine.config %} + {% endunless %} + {% unless machine.template %} + {% assign machine_template = '' %} + {% else %} + {% assign machine_template = machine.template %} {% endunless %} - {% capture machine_template %}{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs_version }}/components.xsl{% endcapture %} {% if site.pcjs_compiled %} - {% capture machine_script %}{% endcapture %} + {% capture machine_script %}{% endcapture %} {% unless machine_scripts contains machine_script %} {{ machine_script }} {% endunless %} {% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %} + {% if machine_template == '' %} + {% capture machine_template %}{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs_version }}/components.xsl{% endcapture %} + {% endif %} {% else %} {% if machine.type == "pc" or machine.type == "pc-dbg" %}{% assign array_scripts = site.pcjs_scripts %}{% endif %} {% if machine.type == "c1p" or machine.type == "c1p-dbg" %}{% assign array_scripts = site.c1pjs_scripts %}{% endif %} @@ -22,6 +29,9 @@ {% endunless %} {% capture machine_scripts %}{{ machine_scripts }}{{ machine_script }}{% endcapture %} {% endfor %} + {% if machine_template == '' %} + {% capture machine_template %}{{ site.baseurl }}/modules/{{ machine.type | remove:'-dbg' }}js/templates/components.xsl{% endcapture %} + {% endif %} {% endif %} {% endfor %} diff --git a/devices/c1p/machine/8kb/array/README.md b/devices/c1p/machine/8kb/array/README.md index 035393dda..8120d3f40 100644 --- a/devices/c1p/machine/8kb/array/README.md +++ b/devices/c1p/machine/8kb/array/README.md @@ -5,9 +5,42 @@ permalink: /devices/c1p/machine/8kb/array/ machines: - type: c1p id: osi1 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi2 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi3 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi4 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi5 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi6 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi7 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi8 + config: /devices/c1p/machine/8kb/small/machine.xml + - type: c1p + id: osi9 + config: /devices/c1p/machine/8kb/small/machine.xml --- Challenger 1P (8Kb) "Server Array" --- {% include machine.html id="osi1" %} +{% include machine.html id="osi2" %} +{% include machine.html id="osi3" %} +{% include machine.html id="osi4" %} +{% include machine.html id="osi5" %} +{% include machine.html id="osi6" %} +{% include machine.html id="osi7" %} +{% include machine.html id="osi8" %} +{% include machine.html id="osi9" %} diff --git a/modules/shared/lib/embed.js b/modules/shared/lib/embed.js index 8b1f0bc96..93fcd208f 100644 --- a/modules/shared/lib/embed.js +++ b/modules/shared/lib/embed.js @@ -403,11 +403,15 @@ function embedMachine(sName, sVersion, idElement, sXMLFile, sXSLFile, sStateFile xsltProcessor['importStylesheet'](xsl); var eFragment = xsltProcessor['transformToFragment'](xml, window.document); if (eFragment) { - if (eMachine.parentNode) { + var machine = eFragment.getElementById(idElement); + if (!machine) { + displayError("machine generation failed: " + idElement); + } + else if (!eMachine.parentNode) { + displayError("invalid machine element: " + idElement); + } else { eMachine.parentNode.replaceChild(eFragment, eMachine); doneMachine(); - } else { - displayError("invalid machine element: " + idElement); } } else { displayError("transformToFragment failed");