handle all other helper switchers

This commit is contained in:
wixette 2020-03-08 20:39:13 +08:00
parent 880dff13ac
commit 6b4a4d39f1
2 changed files with 29 additions and 9 deletions

View File

@ -590,14 +590,14 @@
</div>
<div class="h-box justify-space-start">
<div id="S-OFF-ON" class="button m-8 flex-grow-1">OFF/ON</div>
<div id="S-STOP" class="button m-8 flex-grow-1">STOP</div>
<div id="S-RUN" class="button m-8 flex-grow-1">RUN</div>
<div id="S-SINGLE" class="button m-8 flex-grow-1">SINGLE STEP</div>
<div id="S-EXAMINE" class="button m-8 flex-grow-1">EXAMINE</div>
<div id="S-EXAMINE-NEXT" class="button m-8 flex-grow-1">EXAMINE-NEXT</div>
<div id="S-DEPOSIT" class="button m-8 flex-grow-1">DEPOSIT</div>
<div id="S-DEPOSIT-NEXT" class="button m-8 flex-grow-1">DEPOSIT-NEXT</div>
<div id="S-RESET" class="button m-8 flex-grow-1">RESET</div>
<div id="SSW-STOP" class="button m-8 flex-grow-1">STOP</div>
<div id="SSW-RUN" class="button m-8 flex-grow-1">RUN</div>
<div id="SSW-SINGLE" class="button m-8 flex-grow-1">SINGLE STEP</div>
<div id="SSW-EXAMINE" class="button m-8 flex-grow-1">EXAMINE</div>
<div id="SSW-EXAMINE-NEXT" class="button m-8 flex-grow-1">EXAMINE-NEXT</div>
<div id="SSW-DEPOSIT" class="button m-8 flex-grow-1">DEPOSIT</div>
<div id="SSW-DEPOSIT-NEXT" class="button m-8 flex-grow-1">DEPOSIT-NEXT</div>
<div id="SSW-RESET" class="button m-8 flex-grow-1">RESET</div>
</div>
</div>

View File

@ -716,7 +716,7 @@ panel.createSwitch = function(id, type, x, y, upperCmd, lowerCmd) {
panel.onToggle(sourceId);
},
false);
// Also installs soft switch handlers.
// Also installs helper switch handlers.
let softSwitchId = 'S-' + id;
let elem = document.getElementById(softSwitchId);
elem.addEventListener(
@ -738,6 +738,16 @@ panel.createSwitch = function(id, type, x, y, upperCmd, lowerCmd) {
upperCmd.callback();
},
false);
// Also installs helper switch handlers.
cmdElem = document.getElementById('S' + upperCmd.textId);
cmdElem.addEventListener(
'click',
function() {
panel.switchUpThenBack(id);
panel.playSwitch();
upperCmd.callback();
},
false);
}
if (lowerCmd) {
let cmdElem = document.getElementById(lowerCmd.textId);
@ -750,6 +760,16 @@ panel.createSwitch = function(id, type, x, y, upperCmd, lowerCmd) {
lowerCmd.callback();
},
false);
// Also installs helper switch handlers.
cmdElem = document.getElementById('S' + lowerCmd.textId);
cmdElem.addEventListener(
'click',
function() {
panel.switchDownThenBack(id);
panel.playSwitch();
lowerCmd.callback();
},
false);
}
}