Removed useless sHTMLClass parameter from all setBinding() methods
HTML controls with bindings are now identified by the single class attribute of "{APPCLASS}-binding" instead of the somewhat arbitrary "{APPCLASS}-input" or "{APPCLASS}-output" classes
This commit is contained in:
parent
f8864beb20
commit
64b2494eef
32 changed files with 221 additions and 246 deletions
|
|
@ -163,13 +163,12 @@ C1PComputer.prototype.stop = function(msStart, nCycles)
|
|||
|
||||
/**
|
||||
* @this {C1PComputer}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PComputer.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PComputer.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
switch(sBinding) {
|
||||
case "reset":
|
||||
|
|
|
|||
|
|
@ -502,13 +502,12 @@ C1PCPU.prototype.reset = function(fPowerOn)
|
|||
|
||||
/**
|
||||
* @this {C1PCPU}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "run")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PCPU.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PCPU.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
var fBound = false;
|
||||
switch(sBinding) {
|
||||
|
|
|
|||
|
|
@ -487,48 +487,47 @@ if (DEBUGGER) {
|
|||
|
||||
/**
|
||||
* @this {C1PDebugger}
|
||||
* @param {string|null} c is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} t is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} s is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "debugInput")
|
||||
* @param {Object} e is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PDebugger.prototype.setBinding = function(c, t, s, e)
|
||||
C1PDebugger.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
var dbg = this;
|
||||
switch(s) {
|
||||
switch(sBinding) {
|
||||
case "debugInput":
|
||||
this.bindings[s] = e;
|
||||
this.eDebug = e;
|
||||
this.bindings[sBinding] = control;
|
||||
this.eDebug = control;
|
||||
this.eDebug.focus();
|
||||
e.onkeypress = function(dbg, e) {
|
||||
control.onkeypress = function(dbg, e) {
|
||||
return function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
s = e.value;
|
||||
sBinding = e.value;
|
||||
e.value = "";
|
||||
C1PDebugger.input(dbg, s);
|
||||
C1PDebugger.input(dbg, sBinding);
|
||||
}
|
||||
};
|
||||
}(this, e);
|
||||
}(this, control);
|
||||
return true;
|
||||
case "debugEnter":
|
||||
this.bindings[s] = e;
|
||||
this.bindings[sBinding] = control;
|
||||
/*
|
||||
* I've replaced the standard "onclick" code with a call to our onClickRepeat() helper in
|
||||
* component.js, so that the "Enter" button can be held to repeat, just like the "Step" button.
|
||||
*/
|
||||
web.onClickRepeat(
|
||||
e, 500, 100,
|
||||
control, 500, 100,
|
||||
function(fRepeat) {
|
||||
if (dbg.eDebug) {
|
||||
s = dbg.eDebug.value;
|
||||
sBinding = dbg.eDebug.value;
|
||||
//
|
||||
// If we want to use the debugEnter button to repeatedly enter the same command,
|
||||
// then don't clear the command string.
|
||||
//
|
||||
// dbg.eDebug.value = "";
|
||||
//
|
||||
C1PDebugger.input(dbg, s);
|
||||
C1PDebugger.input(dbg, sBinding);
|
||||
return true;
|
||||
}
|
||||
if (DEBUG) dbg.log("no debugger input buffer");
|
||||
|
|
@ -537,9 +536,9 @@ if (DEBUGGER) {
|
|||
);
|
||||
return true;
|
||||
case "step":
|
||||
this.bindings[s] = e;
|
||||
this.bindings[sBinding] = control;
|
||||
web.onClickRepeat(
|
||||
e, 500, 100,
|
||||
control, 500, 100,
|
||||
function(fRepeat) {
|
||||
var fCompleted = false;
|
||||
if (!dbg.isBusy(true)) {
|
||||
|
|
|
|||
|
|
@ -657,13 +657,12 @@ C1PDiskController.prototype.resetDrive = function(iDrive, iDriveType, nMaxTracks
|
|||
|
||||
/**
|
||||
* @this {C1PDiskController}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "listDisk")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PDiskController.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PDiskController.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
switch(sBinding) {
|
||||
|
||||
|
|
|
|||
|
|
@ -388,13 +388,12 @@ C1PKeyboard.prototype.reset = function()
|
|||
|
||||
/**
|
||||
* @this {C1PKeyboard}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "esc", "ctrl-c")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PKeyboard.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PKeyboard.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
/*
|
||||
* I want to bind to the first caller (ie, the Screen), not subsequent ones (eg, the Panel)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
<rom id="romSystem" size="0x0800" image="/devices/c1p/rom/system.hex"/>
|
||||
<video id="video" screenwidth="256" screenheight="192" cols="32" rows="32" charset="/devices/c1p/video/chargen1x.png" padding="8px"/>
|
||||
<keyboard id="keyboard">
|
||||
<control type="button" class="input" binding="ctrl-c">CTRL-C</control>
|
||||
<control type="button" class="input" binding="break">BREAK</control>
|
||||
<control type="button" binding="ctrl-c">CTRL-C</control>
|
||||
<control type="button" binding="break">BREAK</control>
|
||||
</keyboard>
|
||||
<serial id="serialPort" demo="true"/>
|
||||
</machine>
|
||||
|
|
@ -80,9 +80,9 @@
|
|||
<lt/>video id="video" screenwidth="256" screenheight="192" cols="32" rows="32"
|
||||
charset="/devices/c1p/video/chargen1x.png" width="256px" padding="8px"/<gt/>
|
||||
<lt/>keyboard id="keyboard"<gt/>
|
||||
<lt/>control type="button" class="input" binding="ctrl-c"<gt/>CTRL-C<lt/>/control<gt/>
|
||||
<lt/>control type="button" class="input" binding="ctrl-o"<gt/>CTRL-O<lt/>/control<gt/>
|
||||
<lt/>control type="button" class="input" binding="break"<gt/>BREAK<lt/>/control<gt/>
|
||||
<lt/>control type="button" binding="ctrl-c"<gt/>CTRL-C<lt/>/control<gt/>
|
||||
<lt/>control type="button" binding="ctrl-o"<gt/>CTRL-O<lt/>/control<gt/>
|
||||
<lt/>control type="button" binding="break"<gt/>BREAK<lt/>/control<gt/>
|
||||
<lt/>/keyboard<gt/>
|
||||
<lt/>/machine<gt/>
|
||||
</pre>
|
||||
|
|
|
|||
|
|
@ -55,19 +55,18 @@ Component.subclass(Component, C1PPanel);
|
|||
* component that doesn't recognize the specified binding should simply ignore it.
|
||||
*
|
||||
* @this {C1PPanel}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea", "canvas")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "reset")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PPanel.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PPanel.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
if (this.cmp && this.cmp.setBinding(sHTMLClass, sHTMLType, sBinding, control)) return true;
|
||||
if (this.cpu && this.cpu.setBinding(sHTMLClass, sHTMLType, sBinding, control)) return true;
|
||||
if (this.kbd && this.kbd.setBinding(sHTMLClass, sHTMLType, sBinding, control)) return true;
|
||||
if (DEBUGGER && this.dbg && this.dbg.setBinding(sHTMLClass, sHTMLType, sBinding, control)) return true;
|
||||
return Component.prototype.setBinding.call(this, sHTMLClass, sHTMLType, sBinding, control);
|
||||
if (this.cmp && this.cmp.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (this.cpu && this.cpu.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (this.kbd && this.kbd.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
if (DEBUGGER && this.dbg && this.dbg.setBinding(sHTMLType, sBinding, control)) return true;
|
||||
return Component.prototype.setBinding.call(this, sHTMLType, sBinding, control);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -100,13 +100,12 @@ C1PSerialPort.prototype.start = function()
|
|||
|
||||
/**
|
||||
* @this {C1PSerialPort}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "listSerial")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PSerialPort.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PSerialPort.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
var serial = this;
|
||||
|
||||
|
|
|
|||
|
|
@ -172,13 +172,12 @@ C1PVideo.prototype.reset = function(fPowerOn)
|
|||
|
||||
/**
|
||||
* @this {C1PVideo}
|
||||
* @param {string|null} sHTMLClass is the class of the HTML control (eg, "input", "output")
|
||||
* @param {string|null} sHTMLType is the type of the HTML control (eg, "button", "list", "text", "submit", "textarea")
|
||||
* @param {string} sBinding is the value of the 'binding' parameter stored in the HTML control's "data-value" attribute (eg, "refresh")
|
||||
* @param {Object} control is the HTML control DOM object (eg, HTMLButtonElement)
|
||||
* @return {boolean} true if binding was successful, false if unrecognized binding request
|
||||
*/
|
||||
C1PVideo.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, control)
|
||||
C1PVideo.prototype.setBinding = function(sHTMLType, sBinding, control)
|
||||
{
|
||||
switch(sBinding) {
|
||||
case "refresh":
|
||||
|
|
@ -322,9 +321,9 @@ C1PVideo.prototype.setPower = function(fOn, cmp)
|
|||
*/
|
||||
this.kbd = cmp.getComponentByType("keyboard");
|
||||
if (this.kbd) {
|
||||
this.kbd.setBinding("input", "canvas", "keyDown", this.eCanvas);
|
||||
this.kbd.setBinding("input", "canvas", "keyPress", this.eCanvas);
|
||||
this.kbd.setBinding("input", "canvas", "keyUp", this.eCanvas);
|
||||
this.kbd.setBinding("canvas", "keyDown", this.eCanvas);
|
||||
this.kbd.setBinding("canvas", "keyPress", this.eCanvas);
|
||||
this.kbd.setBinding("canvas", "keyUp", this.eCanvas);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -266,27 +266,27 @@
|
|||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'button'">
|
||||
<button class="{$APPCLASS}-{@class}" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{$type},{$binding}"><xsl:apply-templates/></button>
|
||||
<button class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{$type},{$binding}"><xsl:apply-templates/></button>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'list'">
|
||||
<select class="{$APPCLASS}-{@class}" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{$type},{$binding}">
|
||||
<select class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$fontsize}{$style}" data-value="{$type},{$binding}">
|
||||
<xsl:apply-templates select="item" mode="component"/>
|
||||
</select>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'text'">
|
||||
<input class="{$APPCLASS}-{@class}" type="text" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}" value="" autocapitalize="off" autocorrect="off"/>
|
||||
<input class="{$APPCLASS}-binding" type="text" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}" value="" autocapitalize="off" autocorrect="off"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'submit'">
|
||||
<input class="{$APPCLASS}-{@class}" type="submit" style="{$border}{$fontsize}{$style}" data-value="{$type},{$binding}" value="{.}"/>
|
||||
<input class="{$APPCLASS}-binding" type="submit" style="{$border}{$fontsize}{$style}" data-value="{$type},{$binding}" value="{.}"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'textarea'">
|
||||
<textarea class="{$APPCLASS}-{@class}" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}" readonly="readonly"></textarea>
|
||||
<textarea class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}" readonly="readonly"></textarea>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'heading'">
|
||||
<div><xsl:value-of select="."/></div>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'file'">
|
||||
<form class="{$APPCLASS}-{@class}" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}">
|
||||
<form class="{$APPCLASS}-binding" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}">
|
||||
<fieldset class="{$APPCLASS}-fieldset">
|
||||
<input type="file"/>
|
||||
<input type="submit" value="Load" disabled="true"/>
|
||||
|
|
@ -300,7 +300,7 @@
|
|||
<div style="clear:both"></div><br/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<div class="{$APPCLASS}-{@class}{$subclass}" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}"><xsl:apply-templates/></div>
|
||||
<div class="{$APPCLASS}-binding{$subclass}" style="{$border}{$width}{$height}{$style}" data-value="{$type},{$binding}"><xsl:apply-templates/></div>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@label">
|
||||
|
|
|
|||
Loading…
Reference in a new issue