diff --git a/public/index.html b/public/index.html
index b2e28dbd5..6235b8ac9 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2238,6 +2238,21 @@
+
start graphs at zero
diff --git a/public/js/commandline.js b/public/js/commandline.js
index 99ad85cd7..8d7ea78ff 100644
--- a/public/js/commandline.js
+++ b/public/js/commandline.js
@@ -274,6 +274,13 @@ let commands = {
toggleAlwaysShowDecimalPlaces();
},
},
+ {
+ id: "toggleAlwaysShowCPM",
+ display: "Toggle always show CPM",
+ exec: () => {
+ toggleAlwaysShowCPM();
+ },
+ },
{
id: "toggleSwapEscAndTab",
display: "Toggle swap esc and tab",
@@ -954,6 +961,26 @@ let commandsHighlightMode = {
],
};
+let commandsAlwaysShowCPM = {
+ title: "Toggle always show cpm...",
+ list: [
+ {
+ id: "setAlwaysShowCPMTrue",
+ display: true,
+ exec: () => {
+ setAlwaysShowCPM(true);
+ },
+ },
+ {
+ id: "setAlwaysShowCPMFalse",
+ display: false,
+ exec: () => {
+ setHighlightMode(false);
+ },
+ },
+ ],
+};
+
let commandsTimerStyle = {
title: "Change timer/progress style...",
list: [
diff --git a/public/js/script.js b/public/js/script.js
index b7d16f39d..93f40f5af 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -1647,6 +1647,7 @@ function calculateStats() {
// }
let chars = countChars();
// let testNow = Date.now();
+
let wpm = roundTo2(
((chars.correctWordChars + chars.correctSpaces) * (60 / testSeconds)) / 5
);
@@ -1738,8 +1739,22 @@ function showResult(difficultyFailed = false) {
$("#result #resultWordsHistory").addClass("hidden");
if (config.alwaysShowDecimalPlaces) {
- $("#result .stats .wpm .bottom").text(roundTo2(stats.wpm));
- $("#result .stats .raw .bottom").text(roundTo2(stats.wpmRaw));
+ if (config.alwaysShowCPM == false) {
+ $("#result .stats .wpm .bottom").text(roundTo2(stats.wpm));
+ $("#result .stats .raw .bottom").text(roundTo2(stats.wpmRaw));
+ $("#result .stats .wpm .bottom").attr(
+ "aria-label",
+ roundTo2(stats.wpm * 5) + " cpm"
+ );
+ } else {
+ $("#result .stats .wpm .bottom").text(roundTo2(stats.wpm * 5));
+ $("#result .stats .raw .bottom").text(roundTo2(stats.wpmRaw * 5));
+ $("#result .stats .wpm .bottom").attr(
+ "aria-label",
+ roundTo2(stats.wpm) + " wpm"
+ );
+ }
+
$("#result .stats .acc .bottom").text(roundTo2(stats.acc) + "%");
// $("#result .stats .time .bottom").text(roundTo2(testtime) + "s");
let time = roundTo2(testtime) + "s";
@@ -1747,10 +1762,7 @@ function showResult(difficultyFailed = false) {
time = secondsToString(roundTo2(testtime));
}
$("#result .stats .time .bottom .text").text(time);
- $("#result .stats .wpm .bottom").attr(
- "aria-label",
- roundTo2(stats.wpm * 5) + " cpm"
- );
+
$("#result .stats .raw .bottom").removeAttr("aria-label");
$("#result .stats .acc .bottom").removeAttr("aria-label");
$("#result .stats .time .bottom").attr(
@@ -1758,13 +1770,25 @@ function showResult(difficultyFailed = false) {
`${afkseconds}s afk ${afkSecondsPercent}%`
);
} else {
- $("#result .stats .wpm .bottom").text(Math.round(stats.wpm));
- $("#result .stats .wpm .bottom").attr(
- "aria-label",
- stats.wpm + ` (${roundTo2(stats.wpm * 5)} cpm)`
- );
- $("#result .stats .raw .bottom").text(Math.round(stats.wpmRaw));
- $("#result .stats .raw .bottom").attr("aria-label", stats.wpmRaw);
+ //not showing decimal places
+ if (config.alwaysShowCPM == false) {
+ $("#result .stats .wpm .bottom").attr(
+ "aria-label",
+ stats.wpm + ` (${roundTo2(stats.wpm * 5)} cpm)`
+ );
+ $("#result .stats .wpm .bottom").text(Math.round(stats.wpm));
+ $("#result .stats .raw .bottom").text(Math.round(stats.wpmRaw));
+ $("#result .stats .raw .bottom").attr("aria-label", stats.wpmRaw);
+ } else {
+ $("#result .stats .wpm .bottom").attr(
+ "aria-label",
+ stats.wpm + ` (${roundTo2(stats.wpm)} wpm)`
+ );
+ $("#result .stats .wpm .bottom").text(Math.round(stats.wpm * 5));
+ $("#result .stats .raw .bottom").text(Math.round(stats.wpmRaw * 5));
+ $("#result .stats .raw .bottom").attr("aria-label", stats.wpmRaw * 5);
+ }
+
$("#result .stats .acc .bottom").text(Math.floor(stats.acc) + "%");
$("#result .stats .acc .bottom").attr("aria-label", stats.acc + "%");
let time = Math.round(testtime) + "s";
@@ -3115,6 +3139,9 @@ function updateLiveWpm(wpm, raw) {
if (config.blindMode) {
number = raw;
}
+ if (config.alwaysShowCPM) {
+ number = Math.round(number * 5);
+ }
document.querySelector("#miniTimerAndLiveWpm .wpm").innerHTML = number;
document.querySelector("#liveWpm").innerHTML = number;
// $("#liveWpm").html(wpm);
diff --git a/public/js/settings.js b/public/js/settings.js
index 8da6a25df..eba9b2036 100644
--- a/public/js/settings.js
+++ b/public/js/settings.js
@@ -253,6 +253,10 @@ settingsGroups.alwaysShowDecimalPlaces = new SettingsGroup(
"alwaysShowDecimalPlaces",
setAlwaysShowDecimalPlaces
);
+settingsGroups.alwaysShowCPM = new SettingsGroup(
+ "alwaysShowCPM",
+ setAlwaysShowCPM
+);
fillSettingsPage();
diff --git a/public/js/userconfig.js b/public/js/userconfig.js
index 27ef06a6e..9e7ab8833 100644
--- a/public/js/userconfig.js
+++ b/public/js/userconfig.js
@@ -68,6 +68,7 @@ let defaultConfig = {
minWpm: "off",
minWpmCustomSpeed: 100,
highlightMode: "letter",
+ alwaysShowCPM: false,
};
let cookieConfig = null;
@@ -212,8 +213,9 @@ function applyConfig(configObj) {
setMinWpmCustomSpeed(configObj.minWpmCustomSpeed, true);
setNumbers(configObj.numbers, true);
setPunctuation(configObj.punctuation, true);
- changeMode(configObj.mode, true);
setHighlightMode(configObj.highlightMode, true);
+ setAlwaysShowCPM(config.alwaysShowCPM, true);
+ changeMode(configObj.mode, true);
config.startGraphsAtZero = configObj.startGraphsAtZero;
// if (
// configObj.resultFilters !== null &&
@@ -428,6 +430,19 @@ function setAlwaysShowDecimalPlaces(val, nosave) {
if (!nosave) saveConfigToCookie();
}
+function toggleAlwaysShowCPM() {
+ config.alwaysShowCPM = !config.alwaysShowCPM;
+ saveConfigToCookie();
+}
+
+function setAlwaysShowCPM(val, nosave) {
+ if (val == undefined) {
+ val = false;
+ }
+ config.alwaysShowCPM = val;
+ if (!nosave) saveConfigToCookie();
+}
+
//show out of focus warning
function toggleShowOutOfFocusWarning() {
config.showOutOfFocusWarning = !config.showOutOfFocusWarning;