Skip to content

Commit 923aa0e

Browse files
committed
added raw wpm, fixed capital I appearing again
1 parent 505abc1 commit 923aa0e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

public/js/script.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function addWord() {
192192
while (randomWord.indexOf(' ') > -1) {
193193
randomWord = language[Math.floor(Math.random() * language.length)];
194194
}
195-
if (config.punctuation && config.mode != "custom"){
195+
if (config.punctuation && config.mode != "custom" || (!config.punctuation && randomWord == "I") || randomWord.indexOf(' ') > -1){
196196
randomWord = punctuateWord(previousWord, randomWord, wordsList.length, 0)
197197
}
198198
wordsList.push(randomWord);
@@ -428,16 +428,17 @@ function calculateStats() {
428428
if (inputHistory.length != wordsList.length) return;
429429
}
430430
let chars = countChars();
431-
let totalChars = chars.allCorrectChars + chars.incorrectChars + chars.extraChars + chars.missedChars;
432431

433432
let testNow = Date.now();
434433
let testSeconds = (testNow - testStart) / 1000;
435434
let wpm = Math.round((chars.correctWordChars * (60 / testSeconds)) / 5);
435+
let wpmraw = Math.round(((chars.correctWordChars + chars.incorrectChars) * (60/testSeconds))/5)
436436
let acc = Math.floor((accuracyStats.correct / (accuracyStats.correct + accuracyStats.incorrect)) * 100);
437437
return {
438438
wpm: wpm,
439+
wpmRaw: wpmraw,
439440
acc: acc,
440-
correctChars: chars.allCorrectChars,
441+
correctChars: chars.correctWordChars,
441442
incorrectChars: chars.incorrectChars + chars.extraChars + chars.missedChars,
442443
time: testSeconds
443444
};
@@ -463,6 +464,7 @@ function showResult() {
463464
if(stats === undefined){
464465
stats = {
465466
wpm: 0,
467+
wpmRaw: 0,
466468
acc: 0,
467469
correctChars: 0,
468470
incorrectChars: 0,
@@ -471,16 +473,19 @@ function showResult() {
471473
}
472474
clearIntervals();
473475
$("#result .stats .wpm .bottom").text(stats.wpm);
476+
$("#result .stats .raw .bottom").text(stats.wpmRaw);
474477
$("#result .stats .acc .bottom").text(stats.acc + "%");
475478
$("#result .stats .key .bottom").text(stats.correctChars + "/" + stats.incorrectChars);
479+
$("#result .stats .time .bottom").text(roundedToFixed(stats.time,1)+'s');
480+
476481
let mode2 = "";
477482
if (config.mode == "time") {
478483
mode2 = config.time;
479-
$("#result .stats .time").addClass('hidden');
484+
// $("#result .stats .time").addClass('hidden');
480485
} else if (config.mode == "words") {
481486
mode2 = config.words;
482-
$("#result .stats .time").removeClass('hidden');
483-
$("#result .stats .time .bottom").text(roundedToFixed(stats.time,1)+'s');
487+
// $("#result .stats .time").removeClass('hidden');
488+
// $("#result .stats .time .bottom").text(roundedToFixed(stats.time,1)+'s');
484489
}
485490

486491
if(afkDetected){

0 commit comments

Comments
 (0)