2020-04-20 22:12:30 -06:00
|
|
|
// jshint asi:true
|
2020-04-09 23:09:33 -06:00
|
|
|
|
2020-04-26 15:46:37 -06:00
|
|
|
const lowFreq = 660
|
|
|
|
const highFreq = lowFreq * 6 / 5 // Perfect minor third
|
2020-04-26 21:43:55 -06:00
|
|
|
const errorFreq = 30
|
2020-04-20 22:12:30 -06:00
|
|
|
|
2020-04-26 13:08:43 -06:00
|
|
|
const DIT = 1
|
|
|
|
const DAH = 3
|
2020-04-20 22:12:30 -06:00
|
|
|
|
2020-04-26 13:08:43 -06:00
|
|
|
class Iambic {
|
2020-05-01 15:07:09 -06:00
|
|
|
constructor(beginTxFunc, endTxFunc) {
|
|
|
|
this.beginTxFunc = beginTxFunc
|
|
|
|
this.endTxFunc = endTxFunc
|
2020-05-02 07:43:18 -06:00
|
|
|
this.intervalDuration = null
|
|
|
|
this.state = this.stateBegin
|
2020-05-04 22:20:16 -06:00
|
|
|
this.ditDown = false
|
|
|
|
this.dahDown = false
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new interval (transmission rate)
|
|
|
|
*
|
|
|
|
* @param {number} duration New interval duration, in ms
|
|
|
|
*/
|
2020-05-02 07:43:18 -06:00
|
|
|
SetIntervalDuration(duration) {
|
|
|
|
this.intervalDuration = duration
|
|
|
|
if (this.interval) {
|
|
|
|
clearInterval(this.interval)
|
|
|
|
this.interval = setInterval(e => this.pulse(), duration)
|
|
|
|
}
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// An interval has passed, call whatever the current state function is
|
|
|
|
pulse(event) {
|
|
|
|
this.state()
|
|
|
|
}
|
|
|
|
|
2020-05-02 07:43:18 -06:00
|
|
|
stateBegin() {
|
2020-05-04 22:20:16 -06:00
|
|
|
if (this.ditDown) {
|
|
|
|
this.stateDit()
|
|
|
|
} else if (this.dahDown) {
|
|
|
|
this.stateDah()
|
2020-05-02 07:43:18 -06:00
|
|
|
} else {
|
|
|
|
clearInterval(this.interval)
|
|
|
|
this.interval = null
|
|
|
|
}
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-05-04 22:20:16 -06:00
|
|
|
|
2020-05-01 15:07:09 -06:00
|
|
|
stateDit() {
|
|
|
|
// Send a dit
|
|
|
|
this.beginTxFunc()
|
2020-05-04 22:20:16 -06:00
|
|
|
this.state = this.stateDitEnd
|
|
|
|
}
|
|
|
|
stateDitEnd() {
|
|
|
|
this.endTxFunc()
|
|
|
|
this.state = this.stateDitNext
|
|
|
|
}
|
|
|
|
stateDitNext() {
|
|
|
|
if (this.dahDown) {
|
|
|
|
this.state = this.stateDah
|
|
|
|
} else {
|
|
|
|
this.state = this.stateBegin
|
|
|
|
}
|
|
|
|
this.state()
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-05-04 22:20:16 -06:00
|
|
|
|
2020-05-01 15:07:09 -06:00
|
|
|
stateDah() {
|
|
|
|
// Send a dah
|
|
|
|
this.beginTxFunc()
|
|
|
|
this.state = this.stateDah2
|
|
|
|
}
|
|
|
|
stateDah2() {
|
|
|
|
this.state = this.stateDah3
|
|
|
|
}
|
|
|
|
stateDah3() {
|
2020-05-04 22:20:16 -06:00
|
|
|
this.state = this.stateDahEnd
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-05-04 22:20:16 -06:00
|
|
|
stateDahEnd() {
|
2020-05-01 15:07:09 -06:00
|
|
|
this.endTxFunc()
|
2020-05-04 22:20:16 -06:00
|
|
|
this.state = this.stateDahNext
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-05-04 22:20:16 -06:00
|
|
|
stateDahNext() {
|
|
|
|
if (this.ditDown) {
|
|
|
|
this.state = this.stateDit
|
|
|
|
} else {
|
|
|
|
this.state = this.stateBegin
|
|
|
|
}
|
|
|
|
this.state()
|
|
|
|
}
|
|
|
|
|
2020-05-01 15:07:09 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Edge trigger on key press or release
|
|
|
|
*
|
|
|
|
* @param {boolean} down True if key was pressed, false if released
|
|
|
|
* @param {number} key DIT or DAH
|
|
|
|
*/
|
|
|
|
Key(down, key) {
|
|
|
|
if (key == DIT) {
|
2020-05-04 22:20:16 -06:00
|
|
|
this.ditDown = down
|
2020-05-01 15:07:09 -06:00
|
|
|
} else if (key == DAH) {
|
2020-05-04 22:20:16 -06:00
|
|
|
this.dahDown = down
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-05-04 22:20:16 -06:00
|
|
|
|
2020-05-02 07:43:18 -06:00
|
|
|
// Not pulsing yet? Start right away!
|
|
|
|
if (! this.interval) {
|
|
|
|
this.interval = setInterval(e => this.pulse(), this.intervalDuration)
|
|
|
|
this.pulse()
|
|
|
|
}
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
2020-04-20 22:12:30 -06:00
|
|
|
}
|
|
|
|
|
2020-04-26 13:08:43 -06:00
|
|
|
class Buzzer {
|
2020-05-01 15:07:09 -06:00
|
|
|
// Buzzers keep two oscillators: one high and one low.
|
|
|
|
// They generate a continuous waveform,
|
|
|
|
// and we change the gain to turn the pitches off and on.
|
|
|
|
//
|
|
|
|
// This also implements a very quick ramp-up and ramp-down in gain,
|
|
|
|
// in order to avoid "pops" (square wave overtones)
|
|
|
|
// that happen with instant changes in gain.
|
|
|
|
|
|
|
|
constructor(txGain=0.3) {
|
|
|
|
this.txGain = txGain
|
|
|
|
|
|
|
|
this.ac = new AudioContext()
|
|
|
|
|
|
|
|
this.lowGain = this.create(lowFreq)
|
|
|
|
this.highGain = this.create(highFreq)
|
|
|
|
this.errorGain = this.create(errorFreq, "square")
|
|
|
|
}
|
|
|
|
|
|
|
|
create(frequency, type="sine") {
|
|
|
|
let gain = this.ac.createGain()
|
|
|
|
gain.connect(this.ac.destination)
|
|
|
|
gain.gain.value = 0
|
|
|
|
let osc = this.ac.createOscillator()
|
|
|
|
osc.type = type
|
|
|
|
osc.connect(gain)
|
|
|
|
osc.frequency.value = frequency
|
|
|
|
osc.start()
|
|
|
|
return gain
|
|
|
|
}
|
|
|
|
|
|
|
|
gain(high) {
|
|
|
|
if (high) {
|
|
|
|
return this.highGain.gain
|
|
|
|
} else {
|
|
|
|
return this.lowGain.gain
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert clock time to AudioContext time
|
|
|
|
*
|
|
|
|
* @param {number} when Clock time in ms
|
|
|
|
* @return {number} AudioContext offset time
|
|
|
|
*/
|
|
|
|
acTime(when) {
|
|
|
|
if (! when) {
|
|
|
|
return this.ac.currentTime
|
|
|
|
}
|
|
|
|
|
|
|
|
let acOffset = Date.now() - this.ac.currentTime*1000
|
|
|
|
let acTime = (when - acOffset) / 1000
|
|
|
|
return acTime
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set gain
|
|
|
|
*
|
|
|
|
* @param {number} gain Value (0-1)
|
|
|
|
*/
|
|
|
|
SetGain(gain) {
|
|
|
|
this.txGain = gain
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play an error tone
|
|
|
|
*/
|
|
|
|
ErrorTone() {
|
|
|
|
this.errorGain.gain.setTargetAtTime(this.txGain * 0.5, this.ac.currentTime, 0.001)
|
|
|
|
this.errorGain.gain.setTargetAtTime(0, this.ac.currentTime + 0.2, 0.001)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Begin buzzing at time
|
|
|
|
*
|
|
|
|
* @param {boolean} high High or low pitched tone
|
|
|
|
* @param {number} when Time to begin (null=now)
|
|
|
|
*/
|
|
|
|
Buzz(high, when=null) {
|
|
|
|
let gain = this.gain(high)
|
|
|
|
let acWhen = this.acTime(when)
|
|
|
|
|
|
|
|
this.ac.resume()
|
|
|
|
gain.setTargetAtTime(this.txGain, acWhen, 0.001)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* End buzzing at time
|
|
|
|
*
|
|
|
|
* @param {boolean} high High or low pitched tone
|
|
|
|
* @param {number} when Time to begin (null=now)
|
|
|
|
*/
|
|
|
|
Silence(high, when=null) {
|
|
|
|
let gain = this.gain(high)
|
|
|
|
let acWhen = this.acTime(when)
|
|
|
|
|
|
|
|
gain.setTargetAtTime(0, acWhen, 0.001)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Buzz for a duration at time
|
|
|
|
*
|
|
|
|
* @param {boolean} high High or low pitched tone
|
|
|
|
* @param {number} when Time to begin (ms since 1970-01-01Z, null=now)
|
|
|
|
* @param {number} duration Duration of buzz (ms)
|
|
|
|
*/
|
|
|
|
BuzzDuration(high, when, duration) {
|
|
|
|
this.Buzz(high, when)
|
|
|
|
this.Silence(high, when+duration)
|
|
|
|
}
|
2020-04-09 23:09:33 -06:00
|
|
|
}
|
|
|
|
|
2020-04-26 13:08:43 -06:00
|
|
|
class Vail {
|
2020-05-01 15:07:09 -06:00
|
|
|
constructor() {
|
|
|
|
this.sent = []
|
|
|
|
this.lagTimes = [0]
|
|
|
|
this.rxDurations = [0]
|
|
|
|
this.rxDelay = 0 // Milliseconds to add to incoming timestamps
|
|
|
|
this.beginTxTime = null // Time when we began transmitting
|
|
|
|
|
2020-05-04 22:20:16 -06:00
|
|
|
this.openSocket()
|
2020-05-01 15:07:09 -06:00
|
|
|
|
|
|
|
// Listen to HTML buttons
|
|
|
|
for (let e of document.querySelectorAll("button.key")) {
|
|
|
|
e.addEventListener("contextmenu", e => {e.preventDefault(); return false})
|
2020-05-04 22:20:16 -06:00
|
|
|
e.addEventListener("touchstart", e => this.keyButton(e))
|
|
|
|
e.addEventListener("touchend", e => this.keyButton(e))
|
2020-05-01 15:07:09 -06:00
|
|
|
e.addEventListener("mousedown", e => this.keyButton(e))
|
|
|
|
e.addEventListener("mouseup", e => this.keyButton(e))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Listen for keystrokes
|
|
|
|
document.addEventListener("keydown", e => this.key(e))
|
|
|
|
document.addEventListener("keyup", e => this.key(e))
|
|
|
|
|
|
|
|
// Make helpers
|
|
|
|
this.iambic = new Iambic(() => this.beginTx(), () => this.endTx())
|
|
|
|
this.buzzer = new Buzzer()
|
|
|
|
|
|
|
|
// Listen for slider values
|
2020-05-02 07:43:18 -06:00
|
|
|
this.inputInit("#iambic-duration", e => this.iambic.SetIntervalDuration(e.target.value))
|
2020-05-01 15:07:09 -06:00
|
|
|
this.inputInit("#rx-delay", e => {this.rxDelay = Number(e.target.value)})
|
|
|
|
|
|
|
|
// Show what repeater we're on
|
|
|
|
let repeater = (new URL(location)).searchParams.get("repeater") || "Default"
|
|
|
|
document.querySelector("#repeater").textContent = repeater
|
2020-05-02 07:43:18 -06:00
|
|
|
|
|
|
|
// Request MIDI access
|
2020-05-04 22:20:16 -06:00
|
|
|
if (navigator.requestMIDIAccess) {
|
|
|
|
navigator.requestMIDIAccess()
|
|
|
|
.then(a => this.midiInit(a))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openSocket() {
|
|
|
|
// Set up WebSocket
|
|
|
|
let wsUrl = new URL(window.location)
|
|
|
|
wsUrl.protocol = wsUrl.protocol.replace("http", "ws")
|
|
|
|
wsUrl.pathname += "chat"
|
|
|
|
this.socket = new WebSocket(wsUrl)
|
|
|
|
this.socket.addEventListener("message", e => this.wsMessage(e))
|
|
|
|
this.socket.addEventListener("close", e => this.openSocket())
|
2020-05-01 15:07:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
inputInit(selector, func) {
|
|
|
|
let element = document.querySelector(selector)
|
|
|
|
let storedValue = localStorage[element.id]
|
|
|
|
if (storedValue) {
|
|
|
|
element.value = storedValue
|
|
|
|
}
|
|
|
|
let outputElement = document.querySelector(selector + "-value")
|
|
|
|
element.addEventListener("input", e => {
|
|
|
|
localStorage[element.id] = element.value
|
|
|
|
if (outputElement) {
|
|
|
|
outputElement.value = element.value
|
|
|
|
}
|
|
|
|
func(e)
|
|
|
|
})
|
|
|
|
element.dispatchEvent(new Event("input"))
|
|
|
|
}
|
2020-05-02 07:43:18 -06:00
|
|
|
|
|
|
|
midiInit(access) {
|
|
|
|
this.midiAccess = access
|
|
|
|
for (let input of this.midiAccess.inputs.values()) {
|
|
|
|
input.addEventListener("midimessage", e => this.midiMessage(e))
|
|
|
|
}
|
|
|
|
this.midiAccess.addEventListener("statechange", e => this.midiStateChange(e))
|
|
|
|
}
|
|
|
|
|
|
|
|
midiStateChange(event) {
|
2020-05-04 22:20:16 -06:00
|
|
|
// XXX: it's not entirely clear how to handle new devices showing up.
|
|
|
|
// XXX: possibly we go through this.midiAccess.inputs and somehow only listen on new things
|
2020-05-02 07:43:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
midiMessage(event) {
|
|
|
|
let data = Array.from(event.data)
|
|
|
|
|
|
|
|
let begin
|
2020-05-02 17:55:17 -06:00
|
|
|
let cmd = data[0] >> 4
|
|
|
|
let chan = data[0] & 0xf
|
|
|
|
switch (cmd) {
|
|
|
|
case 9:
|
2020-05-02 07:43:18 -06:00
|
|
|
begin = true
|
|
|
|
break
|
2020-05-02 17:55:17 -06:00
|
|
|
case 8:
|
2020-05-02 07:43:18 -06:00
|
|
|
begin = false
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (data[1] % 12) {
|
|
|
|
case 0: // C
|
|
|
|
this.straightKey(begin)
|
|
|
|
break
|
|
|
|
case 1: // C#
|
|
|
|
this.iambic.Key(begin, DIT)
|
|
|
|
break
|
|
|
|
case 2: // D
|
|
|
|
this.iambic.Key(begin, DAH)
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2020-05-01 15:07:09 -06:00
|
|
|
|
|
|
|
error(msg) {
|
|
|
|
let now = new Date()
|
|
|
|
let e = document.querySelector("#errors")
|
|
|
|
if (e) {
|
|
|
|
let p = e.appendChild(document.createElement("p"))
|
|
|
|
p.innerText = "[" + now.toLocaleTimeString() + "] " + msg
|
|
|
|
e.scrollTop = e.scrollHeight
|
|
|
|
}
|
|
|
|
this.buzzer.ErrorTone()
|
|
|
|
}
|
|
|
|
|
|
|
|
beginTx() {
|
|
|
|
this.beginTxTime = Date.now()
|
|
|
|
this.buzzer.Buzz(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
endTx() {
|
|
|
|
let endTxTime = Date.now()
|
|
|
|
let duration = endTxTime - this.beginTxTime
|
|
|
|
this.buzzer.Silence(true)
|
|
|
|
this.wsSend(this.beginTxTime, duration)
|
|
|
|
this.beginTxTime = null
|
|
|
|
}
|
|
|
|
|
|
|
|
updateReading(selector, value) {
|
|
|
|
let e = document.querySelector(selector)
|
|
|
|
if (e) {
|
|
|
|
e.value = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateReadings() {
|
|
|
|
let avgLag = this.lagTimes.reduce((a,b) => (a+b)) / this.lagTimes.length
|
|
|
|
let longestRx = this.rxDurations.reduce((a,b) => Math.max(a,b))
|
|
|
|
let suggestedDelay = (avgLag + longestRx) * 1.2
|
|
|
|
|
|
|
|
this.updateReading("#lag-value", avgLag.toFixed())
|
|
|
|
this.updateReading("#longest-rx-value", longestRx)
|
|
|
|
this.updateReading("#suggested-delay-value", suggestedDelay.toFixed())
|
|
|
|
}
|
|
|
|
|
|
|
|
addLagReading(duration) {
|
|
|
|
this.lagTimes.push(duration)
|
|
|
|
while (this.lagTimes.length > 20) {
|
|
|
|
this.lagTimes.shift()
|
|
|
|
}
|
|
|
|
this.updateReadings()
|
|
|
|
}
|
|
|
|
|
|
|
|
addRxDuration(duration) {
|
|
|
|
this.rxDurations.push(duration)
|
|
|
|
while (this.rxDurations.length > 20) {
|
|
|
|
this.rxDurations.shift()
|
|
|
|
}
|
|
|
|
this.updateReadings()
|
|
|
|
}
|
|
|
|
|
|
|
|
wsSend(time, duration) {
|
|
|
|
let msg = [time, duration]
|
|
|
|
let jmsg = JSON.stringify(msg)
|
|
|
|
this.socket.send(jmsg)
|
|
|
|
this.sent.push(jmsg)
|
|
|
|
}
|
|
|
|
|
|
|
|
wsMessage(event) {
|
|
|
|
let now = Date.now()
|
|
|
|
let jmsg = event.data
|
2020-05-02 07:43:18 -06:00
|
|
|
let msg
|
|
|
|
try {
|
|
|
|
msg = JSON.parse(jmsg)
|
|
|
|
}
|
|
|
|
catch(err) {
|
|
|
|
console.log(err, msg)
|
|
|
|
return
|
|
|
|
}
|
2020-05-01 15:07:09 -06:00
|
|
|
let beginTxTime = msg[0]
|
|
|
|
let durations = msg.slice(1)
|
|
|
|
|
|
|
|
let sent = this.sent.filter(e => e != jmsg)
|
|
|
|
if (sent.length < this.sent.length) {
|
|
|
|
// We're getting our own message back, which tells us our lag.
|
|
|
|
// We shouldn't emit a tone, though.
|
|
|
|
let totalDuration = durations.reduce((a,b) => a+b)
|
|
|
|
this.sent = sent
|
|
|
|
this.addLagReading(now - beginTxTime - totalDuration)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let adjustedTxTime = beginTxTime+this.rxDelay
|
|
|
|
if (adjustedTxTime < now) {
|
|
|
|
this.error("Packet requested playback " + (now - adjustedTxTime) + "ms in the past. Increase receive delay!")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Every other value is a silence duration
|
|
|
|
let tx = true
|
|
|
|
for (let duration of durations) {
|
|
|
|
duration = Number(duration)
|
|
|
|
if (tx && (duration > 0)) {
|
|
|
|
this.buzzer.BuzzDuration(false, adjustedTxTime, duration)
|
|
|
|
this.addRxDuration(duration)
|
|
|
|
}
|
|
|
|
adjustedTxTime = Number(adjustedTxTime) + duration
|
|
|
|
tx = !tx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-02 07:43:18 -06:00
|
|
|
straightKey(begin) {
|
|
|
|
if (begin) {
|
|
|
|
this.beginTx()
|
|
|
|
} else {
|
|
|
|
this.endTx()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 15:07:09 -06:00
|
|
|
key(event) {
|
|
|
|
if (event.repeat) {
|
|
|
|
// Ignore key repeats generated by the OS, we do this ourselves
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let begin = event.type.endsWith("down")
|
2020-05-04 22:20:16 -06:00
|
|
|
|
2020-05-01 15:07:09 -06:00
|
|
|
if ((event.code == "KeyZ") || (event.code == "Period")) {
|
|
|
|
event.preventDefault()
|
|
|
|
this.iambic.Key(begin, DIT)
|
|
|
|
}
|
|
|
|
if ((event.code == "KeyX") || (event.code == "Slash")) {
|
|
|
|
event.preventDefault()
|
|
|
|
this.iambic.Key(begin, DAH)
|
|
|
|
}
|
|
|
|
if ((event.code == "KeyC") || (event.code == "Comma") || (event.key == "Shift")) {
|
|
|
|
event.preventDefault()
|
|
|
|
if (begin) {
|
|
|
|
this.beginTx()
|
|
|
|
} else {
|
|
|
|
this.endTx()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
keyButton(event) {
|
2020-05-04 22:20:16 -06:00
|
|
|
let begin = event.type.endsWith("down") || event.type.endsWith("start")
|
|
|
|
|
|
|
|
event.preventDefault()
|
2020-05-01 15:07:09 -06:00
|
|
|
|
|
|
|
if (event.target.id == "dah") {
|
|
|
|
this.iambic.Key(begin, DAH)
|
|
|
|
} else if ((event.target.id == "dit") && (event.button == 2)) {
|
|
|
|
this.iambic.Key(begin, DAH)
|
|
|
|
} else if (event.target.id == "dit") {
|
|
|
|
this.iambic.Key(begin, DIT)
|
|
|
|
} else if (event.target.id == "key") {
|
2020-05-02 07:43:18 -06:00
|
|
|
this.straightKey(begin)
|
2020-05-04 22:20:16 -06:00
|
|
|
} else if ((event.target.id == "ck") && begin) {
|
2020-05-01 15:07:09 -06:00
|
|
|
this.Test()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send "CK" to server, and don't squelch the repeat
|
|
|
|
*/
|
|
|
|
Test() {
|
|
|
|
let dit = Number(document.querySelector("#iambic-duration-value").value)
|
|
|
|
let dah = dit * 3
|
|
|
|
let s = dit
|
|
|
|
|
|
|
|
let msg = [
|
|
|
|
Date.now(),
|
|
|
|
dah, s, dit, s, dah, s, dit,
|
|
|
|
s * 3,
|
|
|
|
dah, s, dit, s, dah
|
|
|
|
]
|
|
|
|
this.wsSend(Date.now(), 0) // Get round-trip time
|
|
|
|
this.socket.send(JSON.stringify(msg))
|
|
|
|
}
|
2020-04-10 08:59:15 -06:00
|
|
|
}
|
|
|
|
|
2020-04-26 13:08:43 -06:00
|
|
|
function vailInit() {
|
2020-05-01 15:07:09 -06:00
|
|
|
window.app = new Vail()
|
2020-04-09 23:09:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (document.readyState === "loading") {
|
2020-05-01 15:07:09 -06:00
|
|
|
document.addEventListener("DOMContentLoaded", vailInit)
|
2020-04-09 23:09:33 -06:00
|
|
|
} else {
|
2020-05-01 15:07:09 -06:00
|
|
|
vailInit()
|
2020-04-09 23:09:33 -06:00
|
|
|
}
|