Support for scripts on web pages

This commit is contained in:
Jeff Parsons 2017-01-25 09:44:06 -08:00 committed by Jeff Parsons
commit c37cb26800
4 changed files with 28 additions and 17 deletions

View file

@ -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 */

View file

@ -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;
}
}
}