From c37cb268009214db376a6a3bcd5753b2aaa8c1e9 Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Wed, 25 Jan 2017 09:44:06 -0800 Subject: [PATCH] Support for scripts on web pages --- _includes/machine-command.html | 14 +++++++++---- .../1170/panel/debugger/xxdp/README.md | 8 ++++---- modules/shared/es6/component.js | 3 ++- modules/shared/lib/sticky.js | 20 +++++++++++-------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/_includes/machine-command.html b/_includes/machine-command.html index 7422e04ad..b81ce3811 100644 --- a/_includes/machine-command.html +++ b/_includes/machine-command.html @@ -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: -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: + + {% endcomment %} -{% if include.type == "button" %}{% else %}{% 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" %}{% else %}{% endif %} diff --git a/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md b/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md index 115bd5dc7..dd4bade4a 100644 --- a/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md +++ b/devices/pdp11/machine/1170/panel/debugger/xxdp/README.md @@ -14,10 +14,10 @@ machines: sticky: top commands: bootXXDP: | - select rl11 listDrives RL0 - select rl11 listDisks "XXDP+ Diagnostics" - load rl11 - boot rl11 + select rl11 listDrives RL0; + select rl11 listDisks "XXDP+ Diagnostics"; + click rl11 loadDisk; + click rl11 bootDisk --- This machine is ready to boot [XXDP+ Diagnostics](/disks/dec/rl02k/xxdp/) ("BOOT RL0") and run diff --git a/modules/shared/es6/component.js b/modules/shared/es6/component.js index a16547255..a56acd220 100644 --- a/modules/shared/es6/component.js +++ b/modules/shared/es6/component.js @@ -105,7 +105,9 @@ class Component { this.name = parms['name']; this.comment = parms['comment']; this.parms = parms; + this['exports'] = {}; + this['bindings'] = {}; var i = this.id.indexOf('.'); if (i < 0) { @@ -129,7 +131,6 @@ class Component { this.fnReady = null; this.clearError(); - this.bindings = {}; this.bitsMessage = bitsMessage || 0; /** @type {Object|null} controlPrint is the HTML control, if any, that we can print to */ diff --git a/modules/shared/lib/sticky.js b/modules/shared/lib/sticky.js index 3b8d3b41a..a36a2d90d 100644 --- a/modules/shared/lib/sticky.js +++ b/modules/shared/lib/sticky.js @@ -112,15 +112,19 @@ function commandMachine(idMachine, sComponent, sCommand, sValue) if (window.findMachineComponent) { var component = window.findMachineComponent(idMachine, sComponent); if (component) { - var exports = component['exports']; - if (exports) { - var fnCommand = exports[sCommand]; - if (fnCommand) { - //noinspection JSUnresolvedFunction - if (!fnCommand.call(component, sValue)) { - window.alert("Error calling " + idMachine + "." + sComponent + "." + sCommand + "(" + sValue + ")"); + if (sCommand == "script") { + window.alert("script(" + sValue + ")"); + } else { + var exports = component['exports']; + if (exports) { + var fnCommand = exports[sCommand]; + if (fnCommand) { + //noinspection JSUnresolvedFunction + if (!fnCommand.call(component, sValue)) { + window.alert("Error calling " + idMachine + "." + sComponent + "." + sCommand + "(" + sValue + ")"); + } + return; } - return; } } }