mirror of https://github.com/nealey/vail.git
Minor cleanups, new API adjustments
This commit is contained in:
parent
2f9e651958
commit
8a82a4dc43
|
@ -26,7 +26,7 @@ const Second = 1000 * Millisecond
|
|||
*/
|
||||
const OscillatorRampDuration = 5*Millisecond
|
||||
|
||||
|
||||
console.warn("Chrome will now complain about an AudioContext not being allowed to start. This is normal, and there is no way to make Chrome stop complaining about this.")
|
||||
const BuzzerAudioContext = new AudioContext()
|
||||
/**
|
||||
* Compute the special "Audio Context" time
|
||||
|
|
|
@ -13,19 +13,17 @@ export class HTML extends Input{
|
|||
|
||||
// Listen to HTML buttons
|
||||
for (let e of document.querySelectorAll("button.key")) {
|
||||
e.addEventListener("contextmenu", e => { e.preventDefault(); return false })
|
||||
e.addEventListener("touchstart", e => this.keyButton(e))
|
||||
e.addEventListener("touchend", e => this.keyButton(e))
|
||||
e.addEventListener("mousedown", e => this.keyButton(e))
|
||||
e.addEventListener("mouseup", e => this.keyButton(e))
|
||||
e.addEventListener("contextmenu", e => { return false }, {passive: true})
|
||||
e.addEventListener("touchstart", e => this.keyButton(e), {passive: true})
|
||||
e.addEventListener("touchend", e => this.keyButton(e), {passive: true})
|
||||
e.addEventListener("mousedown", e => this.keyButton(e), {passive: true})
|
||||
e.addEventListener("mouseup", e => this.keyButton(e), {passive: true})
|
||||
}
|
||||
}
|
||||
|
||||
keyButton(event) {
|
||||
let begin = event.type.endsWith("down") || event.type.endsWith("start")
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
if (event.target.id == "dah") {
|
||||
this.keyer.Dah(begin)
|
||||
} else if ((event.target.id == "dit") && (event.button == 2)) {
|
||||
|
@ -69,7 +67,6 @@ export class Keyboard extends Input{
|
|||
if (this.ditDown != down) {
|
||||
this.keyer.Dit(down)
|
||||
this.ditDown = down
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
if (
|
||||
|
@ -82,7 +79,6 @@ export class Keyboard extends Input{
|
|||
if (this.dahDown != down) {
|
||||
this.keyer.Dah(down)
|
||||
this.dahDown = down
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
if (
|
||||
|
@ -95,7 +91,6 @@ export class Keyboard extends Input{
|
|||
if (this.straightDown != down) {
|
||||
this.keyer.Straight(down)
|
||||
this.straightDown = down
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +99,6 @@ export class Keyboard extends Input{
|
|||
// 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 {
|
||||
|
|
|
@ -63,15 +63,11 @@ export class Vail {
|
|||
this.lagDurations.unshift(now - this.clockOffset - beginTxTime - totalDuration)
|
||||
this.lagDurations.splice(20, 2)
|
||||
this.rx(0, 0, this.stats())
|
||||
if (this.name == "debug") {
|
||||
console.debug("Vail.wsMessage() SQUELCH", msg)
|
||||
}
|
||||
console.debug("Vail.wsMessage() SQUELCH", msg)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.name == "debug") {
|
||||
console.debug("Vail.wsMessage()", msg)
|
||||
}
|
||||
console.debug("Vail.wsMessage()", msg)
|
||||
|
||||
// The very first packet is the server telling us the current time
|
||||
if (durations.length == 0) {
|
||||
|
@ -112,6 +108,7 @@ export class Vail {
|
|||
console.error("Not connected, dropping", jmsg)
|
||||
return
|
||||
}
|
||||
console.debug("Transmit", msg)
|
||||
this.socket.send(jmsg)
|
||||
if (squelch) {
|
||||
this.sent.push(jmsg)
|
||||
|
|
|
@ -15,7 +15,7 @@ const Second = 1000 * Millisecond
|
|||
function toast(msg) {
|
||||
let el = document.querySelector("#snackbar")
|
||||
if (!el || !el.MaterialSnackbar) {
|
||||
console.warn(msg)
|
||||
console.info(msg)
|
||||
return
|
||||
}
|
||||
el.MaterialSnackbar.showSnackbar({
|
||||
|
@ -32,7 +32,6 @@ class VailClient {
|
|||
this.clockOffset = null // How badly our clock is off of the server's
|
||||
this.rxDelay = 0 * Millisecond // Time to add to incoming timestamps
|
||||
this.beginTxTime = null // Time when we began transmitting
|
||||
this.debug = localStorage.debug
|
||||
|
||||
// Make helpers
|
||||
this.lamp = new Buzzer.Lamp()
|
||||
|
@ -110,6 +109,7 @@ class VailClient {
|
|||
setTelegraphBuzzer(enable) {
|
||||
if (enable) {
|
||||
this.buzzer = new Buzzer.TelegraphBuzzer()
|
||||
toast("Telegraphs only make sound when receiving!")
|
||||
} else {
|
||||
this.buzzer = new Buzzer.ToneBuzzer()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue