Support for scripts on web pages
This commit is contained in:
parent
7d58e02def
commit
c37cb26800
4 changed files with 28 additions and 17 deletions
|
|
@ -2,15 +2,21 @@
|
|||
|
||||
As discussed in /_posts/2017-01-03-pdp-11-tutorials.md, when a page (usually part of a tutorial)
|
||||
wants to create a control that tests some feature of a machine, the page will define a machine command
|
||||
using a Liquid-style include that looks like:
|
||||
using a Liquid-style include that looks like this:
|
||||
|
||||
{% include machine-command.html type='button' label='Try It!' machine='vt100' component='Keyboard' command='sendString' value='Hello World' %}
|
||||
|
||||
and which should generate something like:
|
||||
and which should generate something like this:
|
||||
|
||||
<button type="button" onclick="commandMachine('vt100','Keyboard','sendString','Hello World')">Try It!</button>
|
||||
|
||||
Well, that's us. So let's do it!
|
||||
Alternatively, if the command parameter is the name of a command string in the page's Front Matter, then this:
|
||||
|
||||
{% include machine-command.html type='button' label='Try It!' machine='vt100' component='Keyboard' command='scriptName' %}
|
||||
|
||||
should generate something like this:
|
||||
|
||||
<button type="button" onclick="commandMachine('vt100','Keyboard','script','...')">Try It!</button>
|
||||
|
||||
{% endcomment %}
|
||||
{% if include.type == "button" %}<button type="button" onclick="commandMachine('{{ include.machine }}','{{ include.component }}','{{ include.command }}','{{ include.value }}')">{{ include.label }}</button>{% else %}<!-- Unrecognized machine control type: {{ include.type }} -->{% endif %}
|
||||
{% if page.commands[include.command] != nil %}{% assign machine_command = "script" %}{% capture command_value %}{{ page.commands[include.command] | replace:'"','"' }}{% endcapture %}{% else %}{% capture machine_command %}{{ include.command }}{% endcapture %}{% capture command_value %}{{ include.value }}{% endcapture %}{% endif %}{% if include.type == "button" %}<button type="button" onclick="commandMachine('{{ include.machine }}','{{ include.component }}','{{ machine_command }}','{{ command_value }}')">{{ include.label }}</button>{% else %}<!-- Unrecognized machine control type: {{ include.type }} -->{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue