Fix issue with text display

- Text display was broken due to referring to 'text' instead
  of 'newText'.
This commit is contained in:
Seth Morabito 2020-06-03 20:11:24 -07:00
parent c9fcff128a
commit 5c2a4bf7c0
2 changed files with 18 additions and 4 deletions

View File

@ -323,14 +323,14 @@
$("output").innerHTML = c;
}
if (newText[charNum] === ' ') {
charNum++;
}
newText =
"<span class=\"hilighted\">" + newText.substring(0, charNum) + "</span>" +
newText.substring(charNum, newText.length);
if (text[charNum + 1] === ' ') {
charNum++;
}
sendText.innerHTML = newText;
}

View File

@ -206,13 +206,27 @@ let CwTrainer = (function () {
//
// Set the Words per Minute to be used by this trainer.
//
// wpm: The words per minute to use for each character
// fw: The Farnsworth equivalent words per minute
//
setWpm(wpm, fw) {
// "1.2" is a magic constant here, derived from the fact that
// if you were to send the word "PARIS" one time per minute, each
// dot would be 1.2 seconds long. See also:
//
// http://sv8gxc.blogspot.com/2010/09/morse-code-101-in-wpm-bw-snr.html
//
let fwDotWidth = 1.2 / fw;
dotWidth = 1.2 / wpm;
// A dash is three dots wide
dashWidth = dotWidth * 3.0;
// There are 3 dots of silence between characters
charSpace = fwDotWidth * 3.0;
// There are 7 dots of silence between words
wordSpace = fwDotWidth * 7.0;
}