mirror of https://github.com/nealey/vail.git
Merge pull request #27 from nealey/26-vband-adapter-has-no-notion-of-straight-vs-iambic
leftControl behavior depends on active input tab
This commit is contained in:
commit
7e78a848cd
10
publish.sh
10
publish.sh
|
@ -1,3 +1,11 @@
|
|||
#! /bin/sh
|
||||
|
||||
rsync -va static melville.woozle.org:/srv/vail/
|
||||
case "$1" in
|
||||
-prod|--prod)
|
||||
echo "Push to main branch, then update stack."
|
||||
#rsync -va static melville.woozle.org:/srv/vail/
|
||||
;;
|
||||
"")
|
||||
rsync -va static/ melville.woozle.org:/srv/vail/testing/
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -98,8 +98,8 @@
|
|||
<output id="note"></output>
|
||||
<div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
|
||||
<div class="mdl-tabs__tab-bar">
|
||||
<a href="#straight" class="mdl-tabs__tab is-active">Straight Key</a>
|
||||
<a href="#iambic" class="mdl-tabs__tab">Iambic</a>
|
||||
<a href="#straight" class="mdl-tabs__tab is-active" data-singlekey="straight">Straight Key</a>
|
||||
<a href="#iambic" class="mdl-tabs__tab" data-singlekey="iambic">Iambic</a>
|
||||
<a href="#tools" class="mdl-tabs__tab">Tools</a>
|
||||
</div>
|
||||
<div class="mdl-tabs__panel is-active" id="straight">
|
||||
|
|
|
@ -37,6 +37,9 @@ export class Keyboard {
|
|||
// Listen for keystrokes
|
||||
document.addEventListener("keydown", e => this.keyboard(e))
|
||||
document.addEventListener("keyup", e => this.keyboard(e))
|
||||
|
||||
// VBand: the keyboard input needs to know whether vband's "left" should be dit or straight
|
||||
this.iambic = false
|
||||
}
|
||||
|
||||
keyboard(event) {
|
||||
|
@ -54,7 +57,6 @@ export class Keyboard {
|
|||
if ((event.code == "KeyX") ||
|
||||
(event.code == "Period") ||
|
||||
(event.code == "BracketLeft") ||
|
||||
(event.code == "ControlLeft") ||
|
||||
(event.key == "[")) {
|
||||
event.preventDefault()
|
||||
this.keyer.Dit(down)
|
||||
|
@ -62,7 +64,7 @@ export class Keyboard {
|
|||
if ((event.code == "KeyZ") ||
|
||||
(event.code == "Slash") ||
|
||||
(event.code == "BracketRight") ||
|
||||
(event.code == "ControlRight") ||
|
||||
(event.code == "ControlRight") || // VBand only: don't display this option to the user
|
||||
(event.key == "]")) {
|
||||
event.preventDefault()
|
||||
this.keyer.Dah(down)
|
||||
|
@ -74,6 +76,19 @@ export class Keyboard {
|
|||
event.preventDefault()
|
||||
this.keyer.Straight(down)
|
||||
}
|
||||
|
||||
if ((event.code == "ControlLeft")) {
|
||||
// VBand and the VBand adapter take a different approach to inputs:
|
||||
// There is a "left" key, and a "right" key, and the computer decides what those mean.
|
||||
// Users expect "left" to be a straight key or dit, depending on some screen control.
|
||||
// "right" is always dah.
|
||||
event.preventDefault()
|
||||
if (this.iambic) {
|
||||
this.keyer.Dit(down)
|
||||
} else {
|
||||
this.keyer.Straight(down)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ export class Vail {
|
|||
|
||||
this.wsUrl = new URL("chat", window.location)
|
||||
this.wsUrl.protocol = this.wsUrl.protocol.replace("http", "ws")
|
||||
this.wsUrl.pathname = this.wsUrl.pathname.replace("testing/", "") // Allow staging deploys
|
||||
this.wsUrl.searchParams.set("repeater", name)
|
||||
|
||||
this.reopen()
|
||||
|
|
|
@ -51,6 +51,11 @@ class VailClient {
|
|||
// Set up various input methods
|
||||
this.inputs = Inputs.SetupAll(this.keyer)
|
||||
|
||||
// VBand: Keep track of how the user wants the single key to behave
|
||||
for (let e of document.querySelectorAll("[data-singlekey]")) {
|
||||
e.addEventListener("click", e => this.singlekeyChange(e))
|
||||
}
|
||||
|
||||
// Maximize button
|
||||
for (let e of document.querySelectorAll("button.maximize")) {
|
||||
e.addEventListener("click", e => this.maximize(e))
|
||||
|
@ -84,6 +89,19 @@ class VailClient {
|
|||
this.setRepeater(decodeURIComponent(hashParts[1] || ""))
|
||||
}
|
||||
|
||||
/**
|
||||
* VBand: Called when something happens to change what a single key does
|
||||
*
|
||||
* @param {Event} event What caused this
|
||||
*/
|
||||
singlekeyChange(event) {
|
||||
for (let e of event.path) {
|
||||
if (e.dataset && e.dataset.singlekey) {
|
||||
this.inputs.Keyboard.iambic = (e.dataset.singlekey == "iambic")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a repeater by name.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue