Fixed support for compiled scripts, and improved error reporting if XML transformation didn't produce a valid machine element
This commit is contained in:
parent
629693ed8f
commit
cd36be4e19
4 changed files with 54 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 %}<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs_version }}{{ machine_script }}"></script>{% endcapture %}
|
||||
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs_version }}/{{ machine.type }}.js"></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 %}
|
||||
<script type="text/javascript">{{ machine_embed }}("{{ machine.id }}","{{ machine_config }}","{{ machine_template }}");</script>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -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" %}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue