mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 13:27:49 +08:00
Merge branch 'cpm' into master
This commit is contained in:
commit
63114268c4
5 changed files with 102 additions and 14 deletions
|
@ -2238,6 +2238,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section alwaysShowCPM">
|
||||
<h1>always show cpm</h1>
|
||||
<div class="text">
|
||||
Always shows characters per minute calculation instead of the
|
||||
default words per minute calculation.
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<div class="button off" tabindex="0" onclick="this.blur();">
|
||||
off
|
||||
</div>
|
||||
<div class="button on" tabindex="0" onclick="this.blur();">
|
||||
on
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section startGraphsAtZero">
|
||||
<h1>start graphs at zero</h1>
|
||||
<div class="text">
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -253,6 +253,10 @@ settingsGroups.alwaysShowDecimalPlaces = new SettingsGroup(
|
|||
"alwaysShowDecimalPlaces",
|
||||
setAlwaysShowDecimalPlaces
|
||||
);
|
||||
settingsGroups.alwaysShowCPM = new SettingsGroup(
|
||||
"alwaysShowCPM",
|
||||
setAlwaysShowCPM
|
||||
);
|
||||
|
||||
fillSettingsPage();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue