Merge pull request #1 from Miodec/master

Updating Fork
This commit is contained in:
Octahedron 2020-08-04 08:11:10 -04:00 committed by GitHub
commit e128c1e93c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 628 additions and 852 deletions

View file

@ -1,5 +0,0 @@
{
"projects": {
"default": "project-id"
}
}

View file

@ -2,6 +2,7 @@
@import url("https://fonts.googleapis.com/css2?family=Montserrat&family=Roboto&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Titillium+Web&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Lexend+Deca&display=swap");
@import url('https://fonts.googleapis.com/css2?family=Oxygen&display=swap');
:root {
--roundness: 0.25rem;
@ -1843,8 +1844,8 @@ key {
}
&.themes,
&.languages,
&.layouts,
&.language,
&.layout,
&.keymapLayout,
&.fontFamily,
&.funbox {

View file

@ -0,0 +1,17 @@
@keyframes shake_dat_ass {
0% { transform: translate(1px, 1px) rotate(0deg); }
10% { transform: translate(-1px, -2px) rotate(-1deg); }
20% { transform: translate(-3px, 0px) rotate(1deg); }
30% { transform: translate(3px, 2px) rotate(0deg); }
40% { transform: translate(1px, -1px) rotate(1deg); }
50% { transform: translate(-1px, 2px) rotate(-1deg); }
60% { transform: translate(-3px, 1px) rotate(0deg); }
70% { transform: translate(3px, 1px) rotate(-1deg); }
80% { transform: translate(-1px, -1px) rotate(1deg); }
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); }
}
letter {
animation: shake_dat_ass .25s infinite linear;
}

View file

@ -25,5 +25,14 @@
{
"name": "rAnDoMcAsE",
"type": "script"
},
{
"name": "layoutfluid",
"type": "script"
},
{
"name": "earthquake",
"type": "style"
}
]
]

View file

@ -7,7 +7,7 @@
<title>Monkey Type</title>
<link rel="stylesheet" href="css/fa.css">
<link rel="stylesheet" href="css/balloon.css">
<link rel="stylesheet" href="css/style.css?v=46">
<link rel="stylesheet" href="css/style.css?v=47">
<link rel="stylesheet" href="themes/serika_dark.css" id="currentTheme">
<link rel="stylesheet" href="" id="funBoxTheme">
<link id="favicon" rel="shortcut icon" href="fav.png">
@ -1123,12 +1123,12 @@
</div>
</div>
</div>
<div class="section layouts">
<div class="section layout">
<h1>layout override</h1>
<div class="buttons">
</div>
</div>
<div class="section languages">
<div class="section language">
<h1>language</h1>
<div class="buttons">
</div>
@ -1158,38 +1158,48 @@
<h1>caret style</h1>
<div class="text">Change the style of the caret during the test.</div>
<div class="buttons">
<div class="button" caret="default" tabindex="0" onclick="this.blur();">|</div>
<div class="button" caret="block" tabindex="0" onclick="this.blur();"></div>
<div class="button" caret="outline" tabindex="0" onclick="this.blur();"></div>
<div class="button" caret="underline" tabindex="0" onclick="this.blur();">_</div>
<div class="button" caretStyle="default" tabindex="0" onclick="this.blur();">|</div>
<div class="button" caretStyle="block" tabindex="0" onclick="this.blur();"></div>
<div class="button" caretStyle="outline" tabindex="0" onclick="this.blur();"></div>
<div class="button" caretStyle="underline" tabindex="0" onclick="this.blur();">_</div>
</div>
</div>
<div class="section timerStyle" section="">
<h1>timer/progress style</h1>
<div class="text">Change the style of the timer/progress during a timed test.</div>
<div class="buttons">
<div class="button" timer="bar" tabindex="0" onclick="this.blur();">bar</div>
<div class="button" timer="text" tabindex="0" onclick="this.blur();">text</div>
<div class="button" timerStyle="bar" tabindex="0" onclick="this.blur();">bar</div>
<div class="button" timerStyle="text" tabindex="0" onclick="this.blur();">text</div>
</div>
</div>
<div class="section timerColor" section="">
<h1>timer/progress color</h1>
<div class="text">Change the color of the timer/progress number/bar and live wpm number.</div>
<div class="buttons">
<div class="button" color="black" tabindex="0" onclick="this.blur();">black</div>
<div class="button" color="sub" tabindex="0" onclick="this.blur();">sub</div>
<div class="button" color="text" tabindex="0" onclick="this.blur();">text</div>
<div class="button" color="main" tabindex="0" onclick="this.blur();">main</div>
<div class="button" timerColor="black" tabindex="0" onclick="this.blur();">black</div>
<div class="button" timerColor="sub" tabindex="0" onclick="this.blur();">sub</div>
<div class="button" timerColor="text" tabindex="0" onclick="this.blur();">text</div>
<div class="button" timerColor="main" tabindex="0" onclick="this.blur();">main</div>
</div>
</div>
<div class="section timerOpacity" section="">
<h1>timer/progress opacity</h1>
<div class="text">Change the opacity of the timer/progress number/bar and live wpm number.</div>
<div class="buttons">
<div class="button" opacity="0.25" tabindex="0" onclick="this.blur();">0.25</div>
<div class="button" opacity="0.5" tabindex="0" onclick="this.blur();">0.5</div>
<div class="button" opacity="0.75" tabindex="0" onclick="this.blur();">0.75</div>
<div class="button" opacity="1" tabindex="0" onclick="this.blur();">1</div>
<div class="button" timerOpacity="0.25" tabindex="0" onclick="this.blur();">0.25</div>
<div class="button" timerOpacity="0.5" tabindex="0" onclick="this.blur();">0.5</div>
<div class="button" timerOpacity="0.75" tabindex="0" onclick="this.blur();">0.75</div>
<div class="button" timerOpacity="1" tabindex="0" onclick="this.blur();">1</div>
</div>
</div>
<div class="section alwaysShowDecimalPlaces">
<h1>always show decimal places</h1>
<div class="text">Always shows decimal places for values on the result page, without the need to hover over
the stats.
</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 smoothLineScroll">
@ -1356,7 +1366,7 @@
hide elements
<i class="fas fa-chevron-down"></i></div>
<div class="settingsGroup hideElements">
<div class="section liveWpm">
<div class="section showLiveWpm">
<h1>live wpm</h1>
<div class="text">Displays a live WPM speed during the test. Updates once every second.</div>
<div class="buttons">
@ -1364,7 +1374,7 @@
<div class="button on" tabindex="0" onclick="this.blur();">show</div>
</div>
</div>
<div class="section timerBar">
<div class="section showTimerProgress">
<h1>timer/progress</h1>
<div class="text">Displays a live timer for timed tests and progress for words/custom tests.</div>
<div class="buttons">
@ -1372,7 +1382,7 @@
<div class="button on" tabindex="0" onclick="this.blur();">show</div>
</div>
</div>
<div class="section keyTips">
<div class="section showKeyTips">
<h1>key tips</h1>
<div class="text">Shows the keybind tips at the bottom of the page.</div>
<div class="buttons">
@ -1380,14 +1390,6 @@
<div class="button on" tabindex="0" onclick="this.blur();">show</div>
</div>
</div>
<div class="section discordDot">
<h1>discord dot</h1>
<div class="text">Shows the notification dot on the Discord icon.</div>
<div class="buttons">
<div class="button off" tabindex="0" onclick="this.blur();">hide</div>
<div class="button on" tabindex="0" onclick="this.blur();">show</div>
</div>
</div>
</div>
</div>
@ -1658,18 +1660,19 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script> -->
<script src="js/chart.js"></script>
<script src="js/chartjs-plugin-trendline.js?v=46"></script>
<script src="js/chart.min.js"></script>
<script src="js/chartjs-plugin-trendline.js?v=47"></script>
<script src="js/chartjs-plugin-annotation.js"></script>
<script src="js/html2canvas.js"></script>
<script src="js/words.js?v=46"></script>
<script src="js/layouts.js?v=46"></script>
<script src="js/db.js?v=46"></script>
<script src="js/userconfig.js?v=46"></script>
<script src="js/commandline.js?v=46"></script>
<script src="js/leaderboards.js?v=46"></script>
<script src="js/settings.js?v=46"></script>
<script src="js/account.js?v=46"></script>
<script src="js/script.js?v=46"></script>
<script src="js/html2canvas.min.js"></script>
<script src="js/misc.js?v=47"></script>
<script src="js/words.js?v=47"></script>
<script src="js/layouts.js?v=47"></script>
<script src="js/db.js?v=47"></script>
<script src="js/userconfig.js?v=47"></script>
<script src="js/commandline.js?v=47"></script>
<script src="js/leaderboards.js?v=47"></script>
<script src="js/settings.js?v=47"></script>
<script src="js/account.js?v=47"></script>
<script src="js/script.js?v=47"></script>
</html>

6
public/js/chart.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -78,7 +78,7 @@ let commands = {
id: "toggleShowLiveWpm",
display: "Toggle live wpm display",
exec: () => {
config.showLiveWpm = !config.showLiveWpm;
toggleShowLiveWpm();
saveConfigToCookie();
},
},
@ -86,7 +86,7 @@ let commands = {
id: "toggleTimerBar",
display: "Toggle timer display",
exec: () => {
config.showTimerBar = !config.showTimerBar;
toggleShowTimerProgress();
saveConfigToCookie();
},
},
@ -139,6 +139,13 @@ let commands = {
toggleSmoothLineScroll();
},
},
{
id: "toggleAlwaysShowDecimalPlaces",
display: "Toggle always show decimal places",
exec: () => {
toggleAlwaysShowDecimalPlaces();
},
},
{
id: "toggleShowAllLines",
display: "Toggle show all lines",
@ -687,17 +694,8 @@ function updateCommandsTagsList() {
}
}
let themesList;
$.getJSON("themes/list.json", function (data) {
commandsThemes.list = [];
themesList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
data.forEach((theme) => {
getThemesList().then((themes) => {
themes.forEach((theme) => {
commandsThemes.list.push({
id: "changeTheme" + capitalizeFirstLetter(theme.name),
display: theme.name.replace(/_/g, " "),
@ -711,32 +709,13 @@ $.getJSON("themes/list.json", function (data) {
});
});
let funboxList;
$.getJSON("funbox/list.json", function (data) {
funboxList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
});
let commandsFonts = {
title: "Change font...",
list: [],
};
let fontsList;
$.getJSON("js/fonts.json", function (data) {
fontsList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
data.forEach((font) => {
getFontsList().then((fonts) => {
fonts.forEach((font) => {
commandsFonts.list.push({
id: "changeFont" + font.name.replace(/ /g, "_"),
display: font.display !== undefined ? font.display : font.name,

View file

@ -28,5 +28,8 @@
{
"name": "Comic Sans MS",
"display": "Helvetica"
},
{
"name": "Oxygen"
}
]

6
public/js/html2canvas.min.js vendored Normal file

File diff suppressed because one or more lines are too long

161
public/js/misc.js Normal file
View file

@ -0,0 +1,161 @@
let themesList = null;
async function getThemesList() {
if (themesList == null) {
return $.getJSON("themes/list.json", function (data) {
themesList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
return themesList;
});
} else {
return themesList;
}
}
let funboxList = null;
async function getFunboxList() {
if (funboxList == null) {
return $.getJSON("funbox/list.json", function (data) {
funboxList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
return funboxList;
});
} else {
return funboxList;
}
}
let fontsList = null;
async function getFontsList() {
if (fontsList == null) {
return $.getJSON("js/fonts.json", function (data) {
fontsList = data.sort(function (a, b) {
(nameA = a.name.toLowerCase()), (nameB = b.name.toLowerCase());
if (nameA < nameB) return -1;
if (nameA > nameB) return 1;
return 0;
});
return fontsList;
});
} else {
return fontsList;
}
}
function smooth(arr, windowSize, getter = (value) => value, setter) {
const get = getter;
const result = [];
for (let i = 0; i < arr.length; i += 1) {
const leftOffeset = i - windowSize;
const from = leftOffeset >= 0 ? leftOffeset : 0;
const to = i + windowSize + 1;
let count = 0;
let sum = 0;
for (let j = from; j < to && j < arr.length; j += 1) {
sum += get(arr[j]);
count += 1;
}
result[i] = setter ? setter(arr[i], sum / count) : sum / count;
}
return result;
}
function stdDev(array) {
try {
const n = array.length;
const mean = array.reduce((a, b) => a + b) / n;
return Math.sqrt(
array.map((x) => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n
);
} catch (e) {
return 0;
}
}
function mean(array) {
try {
return (
array.reduce((previous, current) => (current += previous)) / array.length
);
} catch (e) {
return 0;
}
}
function showNotification(text, time) {
let noti = $(".notification");
noti.text(text);
noti.css("top", `-${noti.outerHeight()}px`);
noti.stop(true, true).animate(
{
top: "1rem",
},
250,
"swing",
() => {
noti.stop(true, true).animate(
{
opacity: 1,
},
time,
() => {
noti.stop(true, true).animate(
{
top: `-${noti.outerHeight()}px`,
},
250,
"swing"
);
}
);
}
);
}
function getReleasesFromGitHub() {
$.getJSON(
"https://api.github.com/repos/Miodec/monkey-type/releases",
(data) => {
$("#bottom .version").text(data[0].name).css("opacity", 1);
$("#versionHistory .releases").empty();
data.forEach((release) => {
if (!release.draft && !release.prerelease) {
$("#versionHistory .releases").append(`
<div class="release">
<div class="title">${release.name}</div>
<div class="date">${moment(release.published_at).format(
"DD MMM YYYY"
)}</div>
<div class="body">${release.body.replace(/\r\n/g, "<br>")}</div>
</div>
`);
}
});
}
);
}
function getLastChar(word) {
return word.charAt(word.length - 1);
}
function capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function kogasa(cov) {
return (
100 * (1 - Math.tanh(cov + Math.pow(cov, 3) / 3 + Math.pow(cov, 5) / 5))
);
}

View file

@ -70,50 +70,6 @@ const generatePairingCode = firebase
.functions()
.httpsCallable("generatePairingCode");
function smooth(arr, windowSize, getter = (value) => value, setter) {
const get = getter;
const result = [];
for (let i = 0; i < arr.length; i += 1) {
const leftOffeset = i - windowSize;
const from = leftOffeset >= 0 ? leftOffeset : 0;
const to = i + windowSize + 1;
let count = 0;
let sum = 0;
for (let j = from; j < to && j < arr.length; j += 1) {
sum += get(arr[j]);
count += 1;
}
result[i] = setter ? setter(arr[i], sum / count) : sum / count;
}
return result;
}
function stdDev(array) {
try {
const n = array.length;
const mean = array.reduce((a, b) => a + b) / n;
return Math.sqrt(
array.map((x) => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n
);
} catch (e) {
return 0;
}
}
function mean(array) {
try {
return (
array.reduce((previous, current) => (current += previous)) / array.length
);
} catch (e) {
return 0;
}
}
function refreshThemeColorObject() {
let st = getComputedStyle(document.body);
@ -134,36 +90,6 @@ function refreshThemeColorObject() {
.replace(" ", "");
}
function showNotification(text, time) {
let noti = $(".notification");
noti.text(text);
noti.css("top", `-${noti.outerHeight()}px`);
noti.stop(true, true).animate(
{
top: "1rem",
},
250,
"swing",
() => {
noti.stop(true, true).animate(
{
opacity: 1,
},
time,
() => {
noti.stop(true, true).animate(
{
top: `-${noti.outerHeight()}px`,
},
250,
"swing"
);
}
);
}
);
}
function copyResultToClipboard() {
if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
showNotification("Sorry, this feature is not supported in Firefox", 4000);
@ -230,14 +156,23 @@ function activateFunbox(funbox, mode) {
}
if (funbox === "simon_says") {
setActiveKeymapModeButton();
settingsGroups.keymapMode.updateButton();
restartTest();
}
} else if (mode === "script") {
if (funbox === "tts") {
$("#funBoxTheme").attr("href", `funbox/simon_says.css`);
config.keymapMode = "off";
setActiveKeymapModeButton();
settingsGroups.keymapMode.updateButton();
restartTest();
} else if (funbox === "layoutfluid") {
config.keymapMode = "on";
changeKeymapMode("next");
settingsGroups.keymapMode.updateButton();
changeLayout("qwerty");
setActiveLayoutButton();
changeKeymapLayout("qwerty");
setActiveKeymapLayoutButton();
restartTest();
}
activeFunBox = funbox;
@ -259,29 +194,6 @@ function toggleScriptFunbox(...params) {
}
}
function getReleasesFromGitHub() {
$.getJSON(
"https://api.github.com/repos/Miodec/monkey-type/releases",
(data) => {
$("#bottom .version").text(data[0].name).css("opacity", 1);
$("#versionHistory .releases").empty();
data.forEach((release) => {
if (!release.draft && !release.prerelease) {
$("#versionHistory .releases").append(`
<div class="release">
<div class="title">${release.name}</div>
<div class="date">${moment(release.published_at).format(
"DD MMM YYYY"
)}</div>
<div class="body">${release.body.replace(/\r\n/g, "<br>")}</div>
</div>
`);
}
});
}
);
}
function verifyUsername() {
// test = firebase.functions().httpsCallable('moveResults')
// test2 = firebase.functions().httpsCallable('getNames')
@ -332,10 +244,6 @@ function getuid() {
console.error("Only share this uid with Miodec and nobody else!");
}
function getLastChar(word) {
return word.charAt(word.length - 1);
}
function setFocus(foc) {
if (foc && !focusState) {
focusState = true;
@ -354,15 +262,6 @@ function setFocus(foc) {
}
}
function capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function roundedToFixed(float, digits) {
let rounded = Math.pow(10, digits);
return (Math.round(float * rounded) / rounded).toFixed(digits);
}
function initWords() {
testActive = false;
wordsList = [];
@ -694,28 +593,17 @@ function showWords() {
.css("overflow", "hidden");
}
// if ($(".active-key") != undefined) {
// $(".active-key").removeClass("active-key");
// }
var currentKey = wordsList[currentWordIndex]
.substring(currentInput.length, currentInput.length + 1)
.toString()
.toUpperCase();
// var highlightKey = `#Key${currentKey}`;
// $(highlightKey).addClass("active-key");
if (config.keymapMode === "next") {
updateHighlightedKeymapKey();
}
updateActiveElement();
updateCaretPosition();
// if (config.keymap !== "off") {
// changeKeymapLayout(config.keymapLayout);
// }
}
function updateActiveElement() {
@ -823,7 +711,7 @@ function highlightBadWord(index, showError) {
}
function showTimer() {
let op = config.showTimerBar ? config.timerOpacity : 0;
let op = config.showTimerProgress ? config.timerOpacity : 0;
if (config.timerStyle === "bar") {
// let op = 0.25;
// if (
@ -924,7 +812,7 @@ function restartTimer() {
}
function updateTimer() {
if (!config.showTimerBar) return;
if (!config.showTimerProgress) return;
if (config.mode === "time") {
if (config.timerStyle === "bar") {
let percent = 100 - ((time + 1) / config.time) * 100;
@ -1406,13 +1294,28 @@ function showResult(difficultyFailed = false) {
};
}
clearIntervals();
let testtime = roundedToFixed(stats.time, 1);
$("#result .stats .wpm .bottom").text(Math.round(stats.wpm));
$("#result .stats .wpm .bottom").attr("aria-label", stats.wpm);
$("#result .stats .raw .bottom").text(Math.round(stats.wpmRaw));
$("#result .stats .raw .bottom").attr("aria-label", stats.wpmRaw);
$("#result .stats .acc .bottom").text(Math.floor(stats.acc) + "%");
$("#result .stats .acc .bottom").attr("aria-label", stats.acc + "%");
let testtime = stats.time;
let afkseconds = keypressPerSecond.filter((x) => x == 0).length;
if (config.alwaysShowDecimalPlaces) {
$("#result .stats .wpm .bottom").text(roundTo2(stats.wpm));
$("#result .stats .raw .bottom").text(roundTo2(stats.wpmRaw));
$("#result .stats .acc .bottom").text(roundTo2(stats.acc) + "%");
$("#result .stats .time .bottom").text(roundTo2(testtime) + "s");
$("#result .stats .time .bottom").attr("aria-label", `${afkseconds}s afk`);
} else {
$("#result .stats .wpm .bottom").text(Math.round(stats.wpm));
$("#result .stats .wpm .bottom").attr("aria-label", stats.wpm);
$("#result .stats .raw .bottom").text(Math.round(stats.wpmRaw));
$("#result .stats .raw .bottom").attr("aria-label", stats.wpmRaw);
$("#result .stats .acc .bottom").text(Math.floor(stats.acc) + "%");
$("#result .stats .acc .bottom").attr("aria-label", stats.acc + "%");
$("#result .stats .time .bottom").text(Math.round(testtime) + "s");
$("#result .stats .time .bottom").attr(
"aria-label",
`${roundTo2(testtime)}s (${afkseconds}s afk)`
);
}
let correctcharpercent = roundTo2(
((stats.correctChars + stats.correctSpaces) /
@ -1426,11 +1329,6 @@ function showResult(difficultyFailed = false) {
stats.correctChars + stats.correctSpaces + "/" + stats.incorrectChars
);
let afkseconds = keypressPerSecond.filter((x) => x == 0).length;
$("#result .stats .time .bottom").text(testtime + "s");
$("#result .stats .time .bottom").attr("aria-label", `${afkseconds}s afk`);
setTimeout(function () {
$("#resultExtraButtons").removeClass("hidden").css("opacity", 0).animate(
{
@ -1448,11 +1346,8 @@ function showResult(difficultyFailed = false) {
let mode2 = "";
if (config.mode === "time") {
mode2 = config.time;
// $("#result .stats .time").addClass('hidden');
} else if (config.mode === "words") {
mode2 = config.words;
// $("#result .stats .time").removeClass('hidden');
// $("#result .stats .time .bottom").text(roundedToFixed(stats.time,1)+'s');
} else if (config.mode === "custom") {
mode2 = "custom";
} else if (config.mode === "quote") {
@ -1492,12 +1387,6 @@ function showResult(difficultyFailed = false) {
let stddev = stdDev(rawWpmPerSecondRaw);
let avg = mean(rawWpmPerSecondRaw);
function kogasa(cov) {
return (
100 * (1 - Math.tanh(cov + Math.pow(cov, 3) / 3 + Math.pow(cov, 5) / 5))
);
}
let consistency = roundTo2(kogasa(stddev / avg));
let keyConsistency = roundTo2(
kogasa(
@ -1509,11 +1398,21 @@ function showResult(difficultyFailed = false) {
consistency = 0;
}
$("#result .stats .consistency .bottom").text(Math.round(consistency) + "%");
$("#result .stats .consistency .bottom").attr(
"aria-label",
`${consistency}% (${keyConsistency}% key)`
);
if (config.alwaysShowDecimalPlaces) {
$("#result .stats .consistency .bottom").text(roundTo2(consistency) + "%");
$("#result .stats .consistency .bottom").attr(
"aria-label",
`${keyConsistency}% key`
);
} else {
$("#result .stats .consistency .bottom").text(
Math.round(consistency) + "%"
);
$("#result .stats .consistency .bottom").attr(
"aria-label",
`${consistency}% (${keyConsistency}% key)`
);
}
wpmOverTimeChart.data.datasets[0].borderColor = themeColors.main;
wpmOverTimeChart.data.datasets[0].data = wpmHistory;
@ -2019,6 +1918,23 @@ function startTest() {
wpmHistory.push(wpmAndRaw.wpm);
rawHistory.push(wpmAndRaw.raw);
if (activeFunBox === "layoutfluid") {
const layouts = ["qwerty", "dvorak", "colemak"];
let index = 0;
if (config.mode === "time") {
index = Math.floor(time / (config.time / 3));
} else if (config.mode === "words") {
index = Math.floor(inputHistory.length / (outof / 3));
}
if (config.layout !== layouts[index] && layouts[index] !== undefined) {
showNotification(`--- !!! ${layouts[index]} !!! ---`, 3000);
}
changeLayout(layouts[index]);
changeKeymapLayout(layouts[index]);
updateHighlightedKeymapKey();
setActiveLayoutButton();
}
// console.timeEnd("livewpm");
keypressPerSecond.push(currentKeypressCount);
currentKeypressCount = 0;
@ -2154,6 +2070,15 @@ function restartTest(withSameWordset = false) {
if (config.keymapMode !== "off") {
showKeymap();
}
if (activeFunBox === "layoutfluid") {
changeLayout("qwerty");
setActiveLayoutButton();
changeKeymapLayout("qwerty");
setActiveKeymapLayoutButton();
updateHighlightedKeymapKey();
}
$("#result").addClass("hidden");
$("#testModesNotice").removeClass("hidden").css({
opacity: 1,

View file

@ -1,14 +1,185 @@
function updateSettingsPage() {
let themesEl = $(".pageSettings .section.themes .buttons").empty();
themesList.forEach((theme) => {
themesEl.append(
`<div class="theme button" theme='${theme.name}' style="color:${
theme.textColor
};background:${theme.bgColor}">${theme.name.replace(/_/g, " ")}</div>`
class SettingsGroup {
constructor(
configName,
toggleFunction,
setCallback = null,
updateCallback = null
) {
this.configName = configName;
this.configValue = config[configName];
if (this.configValue === true || this.configValue === false) {
this.onOff = true;
} else {
this.onOff = false;
}
this.toggleFunction = toggleFunction;
this.setCallback = setCallback;
this.updateCallback = updateCallback;
this.updateButton();
$(document).on(
"click",
`.pageSettings .section.${this.configName} .button`,
(e) => {
if (this.onOff) {
if ($(e.currentTarget).hasClass("on")) {
this.toggleFunction(true);
} else {
this.toggleFunction(false);
}
this.updateButton();
if (this.setCallback !== null) this.setCallback();
} else {
let value = $(e.currentTarget).attr(configName);
let params = $(e.currentTarget).attr("params");
if (params === undefined) {
this.toggleFunction(value);
} else {
this.toggleFunction(value, ...params);
}
this.updateButton();
if (this.setCallback !== null) this.setCallback();
}
}
);
}
updateButton() {
this.configValue = config[this.configName];
$(`.pageSettings .section.${this.configName} .button`).removeClass(
"active"
);
if (this.onOff) {
let onoffstring;
if (this.configValue) {
onoffstring = "on";
} else {
onoffstring = "off";
}
$(
`.pageSettings .section.${this.configName} .buttons .button.${onoffstring}`
).addClass("active");
} else {
$(
`.pageSettings .section.${this.configName} .button[${this.configName}='${this.configValue}']`
).addClass("active");
}
if (this.updateCallback !== null) this.updateCallback();
}
}
let settingsGroups = {};
settingsGroups.smoothCaret = new SettingsGroup("smoothCaret", setSmoothCaret);
settingsGroups.difficulty = new SettingsGroup("difficulty", setDifficulty);
settingsGroups.quickTab = new SettingsGroup("quickTab", setQuickTabMode);
settingsGroups.showLiveWpm = new SettingsGroup(
"showLiveWpm",
setShowLiveWpm,
() => {
settingsGroups.keymapMode.updateButton();
}
);
settingsGroups.showTimerProgress = new SettingsGroup(
"showTimerProgress",
setShowTimerProgress
);
settingsGroups.keymapMode = new SettingsGroup(
"keymapMode",
changeKeymapMode,
() => {
settingsGroups.showLiveWpm.updateButton();
},
() => {
if (config.keymapMode === "off") {
$(".pageSettings .section.keymapLayout").addClass("hidden");
} else {
$(".pageSettings .section.keymapLayout").removeClass("hidden");
}
}
);
settingsGroups.keymapLayout = new SettingsGroup(
"keymapLayout",
changeKeymapLayout
);
settingsGroups.quickTab = new SettingsGroup(
"showKeyTips",
setKeyTips,
null,
() => {
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass("hidden");
} else {
$(".pageSettings .tip").addClass("hidden");
}
}
);
settingsGroups.freedomMode = new SettingsGroup(
"freedomMode",
setFreedomMode,
() => {
settingsGroups.confidenceMode.updateButton();
}
);
settingsGroups.confidenceMode = new SettingsGroup(
"confidenceMode",
setConfidenceMode,
() => {
settingsGroups.freedomMode.updateButton();
}
);
settingsGroups.blindMode = new SettingsGroup("blindMode", setBlindMode);
settingsGroups.quickEnd = new SettingsGroup("quickEnd", setQuickEnd);
settingsGroups.flipTestColors = new SettingsGroup(
"flipTestColors",
setFlipTestColors
);
settingsGroups.colorfulMode = new SettingsGroup(
"colorfulMode",
setColorfulMode
);
settingsGroups.randomTheme = new SettingsGroup("randomTheme", setRandomTheme);
settingsGroups.stopOnError = new SettingsGroup("stopOnError", setStopOnError);
settingsGroups.showAllLines = new SettingsGroup(
"showAllLines",
setShowAllLines
);
settingsGroups.smoothLineScroll = new SettingsGroup(
"smoothLineScroll",
setSmoothLineScroll
);
settingsGroups.layout = new SettingsGroup("layout", changeLayout);
settingsGroups.language = new SettingsGroup("language", changeLanguage);
settingsGroups.fontSize = new SettingsGroup("fontSize", changeFontSize);
settingsGroups.caretStyle = new SettingsGroup("caretStyle", setCaretStyle);
settingsGroups.timerStyle = new SettingsGroup("timerStyle", setTimerStyle);
settingsGroups.timerOpacity = new SettingsGroup(
"timerOpacity",
setTimerOpacity
);
settingsGroups.timerColor = new SettingsGroup("timerColor", setTimerColor);
settingsGroups.fontFamily = new SettingsGroup("fontFamily", setFontFamily);
settingsGroups.alwaysShowDecimalPlaces = new SettingsGroup(
"alwaysShowDecimalPlaces",
setAlwaysShowDecimalPlaces
);
fillSettingsPage();
async function fillSettingsPage() {
let themesEl = $(".pageSettings .section.themes .buttons").empty();
getThemesList().then((themes) => {
themes.forEach((theme) => {
themesEl.append(
`<div class="theme button" theme='${theme.name}' style="color:${
theme.textColor
};background:${theme.bgColor}">${theme.name.replace(/_/g, " ")}</div>`
);
});
});
let langEl = $(".pageSettings .section.languages .buttons").empty();
let langEl = $(".pageSettings .section.language .buttons").empty();
Object.keys(words).forEach((language) => {
if (language === "english_10k") return;
langEl.append(
@ -24,7 +195,7 @@ function updateSettingsPage() {
}
});
let layoutEl = $(".pageSettings .section.layouts .buttons").empty();
let layoutEl = $(".pageSettings .section.layout .buttons").empty();
Object.keys(layouts).forEach((layout) => {
layoutEl.append(
`<div class="layout button" layout='${layout}'>${layout.replace(
@ -38,7 +209,7 @@ function updateSettingsPage() {
Object.keys(layouts).forEach((layout) => {
if (layout.toString() != "default") {
keymapEl.append(
`<div class="layout button" layout='${layout}'>${layout.replace(
`<div class="layout button" keymapLayout='${layout}'>${layout.replace(
"_",
" "
)}</div>`
@ -48,80 +219,53 @@ function updateSettingsPage() {
let funboxEl = $(".pageSettings .section.funbox .buttons").empty();
funboxEl.append(`<div class="funbox button" funbox='none'>none</div>`);
funboxList.forEach((funbox) => {
if (funbox.name === "mirror") {
funboxEl.append(
`<div class="funbox button" funbox='${funbox.name}' type="${
funbox.type
}" style="transform:scaleX(-1);">${funbox.name.replace(
/_/g,
" "
)}</div>`
);
} else {
funboxEl.append(
`<div class="funbox button" funbox='${funbox.name}' type="${
funbox.type
}">${funbox.name.replace(/_/g, " ")}</div>`
);
}
getFunboxList().then((funboxModes) => {
funboxModes.forEach((funbox) => {
if (funbox.name === "mirror") {
funboxEl.append(
`<div class="funbox button" funbox='${funbox.name}' type="${
funbox.type
}" style="transform:scaleX(-1);">${funbox.name.replace(
/_/g,
" "
)}</div>`
);
} else {
funboxEl.append(
`<div class="funbox button" funbox='${funbox.name}' type="${
funbox.type
}">${funbox.name.replace(/_/g, " ")}</div>`
);
}
});
});
let fontsEl = $(".pageSettings .section.fontFamily .buttons").empty();
fontsList.forEach((font) => {
fontsEl.append(
`<div class="button" style="font-family:${
font.display !== undefined ? font.display : font.name
}" fontFamily="${font.name.replace(/ /g, "_")}" tabindex="0"
onclick="this.blur();">${
font.display !== undefined ? font.display : font.name
}</div>`
);
getFontsList().then((fonts) => {
fonts.forEach((font) => {
fontsEl.append(
`<div class="button" style="font-family:${
font.display !== undefined ? font.display : font.name
}" fontFamily="${font.name.replace(/ /g, "_")}" tabindex="0"
onclick="this.blur();">${
font.display !== undefined ? font.display : font.name
}</div>`
);
});
});
}
function updateSettingsPage() {
Object.keys(settingsGroups).forEach((group) => {
settingsGroups[group].updateButton();
});
refreshTagsSettingsSection();
setSettingsButton("smoothCaret", config.smoothCaret);
setSettingsButton("quickTab", config.quickTab);
setSettingsButton("liveWpm", config.showLiveWpm);
setSettingsButton("timerBar", config.showTimerBar);
setSettingsButton("keymap-toggle", config.keymap);
setSettingsButton("keyTips", config.showKeyTips);
setSettingsButton("freedomMode", config.freedomMode);
setSettingsButton("blindMode", config.blindMode);
setSettingsButton("quickEnd", config.quickEnd);
setSettingsButton("flipTestColors", config.flipTestColors);
setSettingsButton("discordDot", config.showDiscordDot);
setSettingsButton("colorfulMode", config.colorfulMode);
setSettingsButton("randomTheme", config.randomTheme);
setSettingsButton("stopOnError", config.stopOnError);
setSettingsButton("showAllLines", config.showAllLines);
setSettingsButton("smoothLineScroll", config.smoothLineScroll);
setActiveFunboxButton();
setActiveLayoutButton();
setActiveThemeButton();
setActiveLanguageButton();
setActiveFontSizeButton();
setActiveDifficultyButton();
setActiveCaretStyleButton();
setActiveTimerStyleButton();
setActiveTimerColorButton();
setActiveTimerOpacityButton();
setActiveThemeTab();
setCustomThemeInputs();
setActiveConfidenceModeButton();
setActiveFontFamilyButton();
setActiveKeymapModeButton();
setActiveKeymapLayoutButton();
updateDiscordSettingsSection();
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass("hidden");
} else {
$(".pageSettings .tip").addClass("hidden");
}
}
function showCustomThemeShare() {
@ -197,29 +341,29 @@ function refreshTagsSettingsSection() {
dbSnapshot.tags.forEach((tag) => {
if (tag.active === true) {
tagsEl.append(`
<div class="tag" id="${tag.id}">
<div class="active" active="true">
<i class="fas fa-check-square"></i>
</div>
<div class="title">${tag.name}</div>
<div class="editButton"><i class="fas fa-pen"></i></div>
<div class="removeButton"><i class="fas fa-trash"></i></div>
</div>
<div class="tag" id="${tag.id}">
<div class="active" active="true">
<i class="fas fa-check-square"></i>
</div>
<div class="title">${tag.name}</div>
<div class="editButton"><i class="fas fa-pen"></i></div>
<div class="removeButton"><i class="fas fa-trash"></i></div>
</div>
`);
} else {
tagsEl.append(`
<div class="tag" id="${tag.id}">
<div class="active" active="false">
<i class="fas fa-square"></i>
</div>
<div class="title">${tag.name}</div>
<div class="editButton"><i class="fas fa-pen"></i></div>
<div class="removeButton"><i class="fas fa-trash"></i></div>
</div>
<div class="tag" id="${tag.id}">
<div class="active" active="false">
<i class="fas fa-square"></i>
</div>
<div class="title">${tag.name}</div>
<div class="editButton"><i class="fas fa-pen"></i></div>
<div class="removeButton"><i class="fas fa-trash"></i></div>
</div>
`);
}
});
@ -259,136 +403,7 @@ function setCustomThemeInputs() {
});
}
function setActiveKeymapModeButton() {
$(`.pageSettings .section.keymapMode .button`).removeClass("active");
$(
`.pageSettings .section.keymapMode .button[keymapMode="${config.keymapMode}"]`
).addClass("active");
if (config.keymapMode === "off") {
$(".pageSettings .section.keymapLayout").addClass("hidden");
} else {
$(".pageSettings .section.keymapLayout").removeClass("hidden");
}
}
function setActiveKeymapLayoutButton() {
$(`.pageSettings .section.keymapLayout .layout`).removeClass("active");
$(
`.pageSettings .section.keymapLayout .layout[layout=${config.keymapLayout}]`
).addClass("active");
}
function setActiveLayoutButton() {
$(`.pageSettings .section.layouts .layout`).removeClass("active");
$(`.pageSettings .section.layouts .layout[layout=${config.layout}]`).addClass(
"active"
);
}
function setActiveFontSizeButton() {
$(`.pageSettings .section.fontSize .buttons .button`).removeClass("active");
$(
`.pageSettings .section.fontSize .buttons .button[fontsize=` +
config.fontSize +
`]`
).addClass("active");
}
function setActiveDifficultyButton() {
$(`.pageSettings .section.difficulty .buttons .button`).removeClass("active");
$(
`.pageSettings .section.difficulty .buttons .button[difficulty=` +
config.difficulty +
`]`
).addClass("active");
}
function setActiveLanguageButton() {
$(`.pageSettings .section.languages .language`).removeClass("active");
$(
`.pageSettings .section.languages .language[language=${config.language}]`
).addClass("active");
}
function setActiveCaretStyleButton() {
$(`.pageSettings .section.caretStyle .buttons .button`).removeClass("active");
$(
`.pageSettings .section.caretStyle .buttons .button[caret=` +
config.caretStyle +
`]`
).addClass("active");
}
function setActiveTimerStyleButton() {
$(`.pageSettings .section.timerStyle .buttons .button`).removeClass("active");
$(
`.pageSettings .section.timerStyle .buttons .button[timer=` +
config.timerStyle +
`]`
).addClass("active");
}
function setActiveTimerColorButton() {
$(`.pageSettings .section.timerColor .buttons .button`).removeClass("active");
$(
`.pageSettings .section.timerColor .buttons .button[color=` +
config.timerColor +
`]`
).addClass("active");
}
function setActiveTimerOpacityButton() {
$(`.pageSettings .section.timerOpacity .buttons .button`).removeClass(
"active"
);
$(
`.pageSettings .section.timerOpacity .buttons .button[opacity="` +
config.timerOpacity +
`"]`
).addClass("active");
}
function setSettingsButton(buttonSection, tf) {
if (tf) {
$(
".pageSettings .section." + buttonSection + " .buttons .button.on"
).addClass("active");
$(
".pageSettings .section." + buttonSection + " .buttons .button.off"
).removeClass("active");
} else {
$(
".pageSettings .section." + buttonSection + " .buttons .button.off"
).addClass("active");
$(
".pageSettings .section." + buttonSection + " .buttons .button.on"
).removeClass("active");
}
}
function showActiveTags() {
// activeTags = [];
// tagsString = "";
// $.each($('.pageSettings .section.tags .tagsList .tag'), (index, tag) => {
// if($(tag).children('.active').attr('active') === 'true'){
// activeTags.push($(tag).attr('id'));
// tagsString += $(tag).children('.title').text() + ', ';
// }
// })
// updateTestModesNotice();
// if($(target).attr('active') === 'true'){
// $(target).attr('active','false');
// $(target).html('<i class="fas fa-square"></i>')
// }else{
// $(target).attr('active','true');
// $(target).html('<i class="fas fa-check-square"></i>')
// }
// $.each($('.pageSettings .section.tags .tagsList .tag'), (index, tag) => {
// let tagid = $(tag).attr('')
// })
dbSnapshot.tags.forEach((tag) => {
if (tag.active === true) {
$(
@ -472,348 +487,12 @@ function updateDiscordSettingsSection() {
}
}
function setActiveConfidenceModeButton() {
let cm = config.confidenceMode;
$(".pageSettings .section.confidenceMode .buttons .button").removeClass(
"active"
);
$(
`.pageSettings .section.confidenceMode .buttons .button[confidenceMode='${cm}']`
).addClass("active");
if (cm !== "off") {
config.freedomMode = false;
setSettingsButton("freedomMode", config.freedomMode);
}
}
function setActiveFontFamilyButton() {
let font = config.fontFamily;
$(".pageSettings .section.fontFamily .buttons .button").removeClass("active");
$(
`.pageSettings .section.fontFamily .buttons .button[fontFamily='${font}']`
).addClass("active");
}
//smooth caret
$(".pageSettings .section.smoothCaret .buttons .button.on").click((e) => {
setSmoothCaret(true);
// showNotification('Smooth caret on', 1000);
setSettingsButton("smoothCaret", config.smoothCaret);
});
$(".pageSettings .section.smoothCaret .buttons .button.off").click((e) => {
setSmoothCaret(false);
// showNotification('Smooth caret off', 1000);
setSettingsButton("smoothCaret", config.smoothCaret);
});
//smooth line
$(".pageSettings .section.smoothLineScroll .buttons .button.on").click((e) => {
setSmoothLineScroll(true);
// showNotification('Smooth caret on', 1000);
setSettingsButton("smoothLineScroll", config.smoothLineScroll);
});
$(".pageSettings .section.smoothLineScroll .buttons .button.off").click((e) => {
setSmoothLineScroll(false);
// showNotification('Smooth caret off', 1000);
setSettingsButton("smoothLineScroll", config.smoothLineScroll);
});
//quick tab
$(".pageSettings .section.quickTab .buttons .button.on").click((e) => {
setQuickTabMode(true);
// showNotification('Quick tab on', 1000);
setSettingsButton("quickTab", config.quickTab);
});
$(".pageSettings .section.quickTab .buttons .button.off").click((e) => {
setQuickTabMode(false);
// showNotification('Quick tab off', 1000);
setSettingsButton("quickTab", config.quickTab);
});
//live wpm
$(".pageSettings .section.liveWpm .buttons .button.on").click((e) => {
config.showLiveWpm = true;
saveConfigToCookie();
// showNotification('Live WPM on', 1000);
setSettingsButton("liveWpm", config.showLiveWpm);
});
$(".pageSettings .section.liveWpm .buttons .button.off").click((e) => {
config.showLiveWpm = false;
saveConfigToCookie();
// showNotification('Live WPM off', 1000);
setSettingsButton("liveWpm", config.showLiveWpm);
});
//timer bar
$(".pageSettings .section.timerBar .buttons .button.on").click((e) => {
config.showTimerBar = true;
saveConfigToCookie();
// showNotification('Timer bar on', 1000);
setSettingsButton("timerBar", config.showTimerBar);
});
$(".pageSettings .section.timerBar .buttons .button.off").click((e) => {
config.showTimerBar = false;
saveConfigToCookie();
// showNotification('Timer bar off', 1000);
setSettingsButton("timerBar", config.showTimerBar);
});
//keymap
$(document).on("click", ".pageSettings .section.keymapMode .button", (e) => {
let mode = $(e.currentTarget).attr("keymapMode");
changeKeymapMode(mode);
restartTest();
setActiveKeymapModeButton();
setSettingsButton("liveWpm", config.showLiveWpm);
});
//keymap layouts
$(document).on("click", ".pageSettings .section.keymapLayout .layout", (e) => {
let layout = $(e.currentTarget).attr("layout");
changeKeymapLayout(layout);
// showNotification('Keymap Layout changed', 1000);
restartTest();
setActiveKeymapLayoutButton();
});
//freedom mode
$(".pageSettings .section.freedomMode .buttons .button.on").click((e) => {
setFreedomMode(true);
saveConfigToCookie();
// showNotification('Freedom mode on', 1000);
setSettingsButton("freedomMode", config.freedomMode);
config.confidenceMode = "off";
setActiveConfidenceModeButton();
});
$(".pageSettings .section.freedomMode .buttons .button.off").click((e) => {
setFreedomMode(false);
saveConfigToCookie();
// showNotification('Freedom mode off', 1000);
setSettingsButton("freedomMode", config.freedomMode);
});
// //max confidence
// $(".pageSettings .section.maxConfidence .buttons .button.on").click((e) => {
// setMaxConfidence(true);
// saveConfigToCookie();
// // showNotification('Max confidence on', 1000);
// setSettingsButton("freedomMode", config.freedomMode);
// setSettingsButton("maxConfidence", config.maxConfidence);
// });
// $(".pageSettings .section.maxConfidence .buttons .button.off").click((e) => {
// setMaxConfidence(false);
// saveConfigToCookie();
// // showNotification('Max confidence off', 1000);
// setSettingsButton("freedomMode", config.freedomMode);
// setSettingsButton("maxConfidence", config.maxConfidence);
// });
//confidence
$(document).on(
"click",
".pageSettings .section.confidenceMode .button",
(e) => {
let confidence = $(e.currentTarget).attr("confidenceMode");
setConfidenceMode(confidence);
setActiveConfidenceModeButton();
}
);
//keytips
$(".pageSettings .section.keyTips .buttons .button.on").click((e) => {
setKeyTips(true);
// showNotification('Key tips on', 1000);
setSettingsButton("keyTips", config.showKeyTips);
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass("hidden");
} else {
$(".pageSettings .tip").addClass("hidden");
}
});
$(".pageSettings .section.keyTips .buttons .button.off").click((e) => {
setKeyTips(false);
// showNotification('Key tips off', 1000);
setSettingsButton("keyTips", config.showKeyTips);
if (config.showKeyTips) {
$(".pageSettings .tip").removeClass("hidden");
} else {
$(".pageSettings .tip").addClass("hidden");
}
});
//keytips
$(".pageSettings .section.discordDot .buttons .button.on").click((e) => {
setDiscordDot(true);
setSettingsButton("discordDot", config.showDiscordDot);
});
$(".pageSettings .section.discordDot .buttons .button.off").click((e) => {
setDiscordDot(false);
setSettingsButton("discordDot", config.showDiscordDot);
});
//themes
// $(document).on("mouseover",".pageSettings .section.themes .theme", (e) => {
// let theme = $(e.currentTarget).attr('theme');
// previewTheme(theme);
// })
$(document).on("click", ".pageSettings .section.themes .theme", (e) => {
let theme = $(e.currentTarget).attr("theme");
setTheme(theme);
setActiveThemeButton();
});
// $(document).on("mouseleave",".pageSettings .section.themes", (e) => {
// setTheme(config.theme);
// })
//languages
$(document).on("click", ".pageSettings .section.languages .language", (e) => {
let language = $(e.currentTarget).attr("language");
changeLanguage(language);
// showNotification('Language changed', 1000);
restartTest();
setActiveLanguageButton();
});
//layouts
$(document).on("click", ".pageSettings .section.layouts .layout", (e) => {
console.log("clicked");
let layout = $(e.currentTarget).attr("layout");
changeLayout(layout);
// showNotification('Layout changed', 1000);
restartTest();
setActiveLayoutButton();
});
//fontsize
$(document).on("click", ".pageSettings .section.fontSize .button", (e) => {
let fontSize = $(e.currentTarget).attr("fontsize");
changeFontSize(fontSize);
// showNotification('Font size changed', 1000);
setActiveFontSizeButton();
});
//difficulty
$(document).on("click", ".pageSettings .section.difficulty .button", (e) => {
let difficulty = $(e.currentTarget).attr("difficulty");
setDifficulty(difficulty);
// showNotification('Difficulty changed', 1000);
setActiveDifficultyButton();
});
//caret style
$(document).on("click", ".pageSettings .section.caretStyle .button", (e) => {
let caretStyle = $(e.currentTarget).attr("caret");
setCaretStyle(caretStyle);
// showNotification('Caret style updated', 1000);
setActiveCaretStyleButton();
});
//timer style
$(document).on("click", ".pageSettings .section.timerStyle .button", (e) => {
let timerStyle = $(e.currentTarget).attr("timer");
setTimerStyle(timerStyle);
// showNotification('Timer style updated', 1000);
setActiveTimerStyleButton();
});
//timer color
$(document).on("click", ".pageSettings .section.timerColor .button", (e) => {
let color = $(e.currentTarget).attr("color");
setTimerColor(color);
// showNotification('Timer style updated', 1000);
setActiveTimerColorButton();
});
//timer opacity
$(document).on("click", ".pageSettings .section.timerOpacity .button", (e) => {
let opacity = $(e.currentTarget).attr("opacity");
setTimerOpacity(opacity);
// showNotification('Timer style updated', 1000);
setActiveTimerOpacityButton();
});
//blind mode
$(".pageSettings .section.blindMode .buttons .button.on").click((e) => {
setBlindMode(true);
// showNotification('Blind mode on', 1000);
setSettingsButton("blindMode", config.blindMode);
});
$(".pageSettings .section.blindMode .buttons .button.off").click((e) => {
setBlindMode(false);
// showNotification('Blind mode off', 1000);
setSettingsButton("blindMode", config.blindMode);
});
//blind mode
$(".pageSettings .section.quickEnd .buttons .button.on").click((e) => {
setQuickEnd(true);
// showNotification('Quick end on', 1000);
setSettingsButton("quickEnd", config.quickEnd);
});
$(".pageSettings .section.quickEnd .buttons .button.off").click((e) => {
setQuickEnd(false);
// showNotification('Quick end off', 1000);
setSettingsButton("quickEnd", config.quickEnd);
});
//flip test
$(".pageSettings .section.flipTestColors .buttons .button.on").click((e) => {
setFlipTestColors(true);
// showNotification('Flip test colors on', 1000);
setSettingsButton("flipTestColors", config.flipTestColors);
});
$(".pageSettings .section.flipTestColors .buttons .button.off").click((e) => {
setFlipTestColors(false);
// showNotification('Flip test colors off', 1000);
setSettingsButton("flipTestColors", config.flipTestColors);
});
//extra color
$(".pageSettings .section.colorfulMode .buttons .button.on").click((e) => {
setColorfulMode(true);
// showNotification('Colorful mode on', 1000);
setSettingsButton("colorfulMode", config.colorfulMode);
});
$(".pageSettings .section.colorfulMode .buttons .button.off").click((e) => {
setColorfulMode(false);
// showNotification('Colorful mode off', 1000);
setSettingsButton("colorfulMode", config.colorfulMode);
});
//extra color
$(".pageSettings .section.randomTheme .buttons .button.on").click((e) => {
setRandomTheme(true);
// showNotification('Colorful mode on', 1000);
setSettingsButton("randomTheme", config.randomTheme);
});
$(".pageSettings .section.randomTheme .buttons .button.off").click((e) => {
setRandomTheme(false);
// showNotification('Colorful mode off', 1000);
setSettingsButton("randomTheme", config.randomTheme);
});
//stop on error
$(".pageSettings .section.stopOnError .buttons .button.on").click((e) => {
setStopOnError(true);
setSettingsButton("stopOnError", config.stopOnError);
});
$(".pageSettings .section.stopOnError .buttons .button.off").click((e) => {
setStopOnError(false);
setSettingsButton("stopOnError", config.stopOnError);
});
//showAllLines
$(".pageSettings .section.showAllLines .buttons .button.on").click((e) => {
setShowAllLines(true);
setSettingsButton("showAllLines", config.showAllLines);
});
$(".pageSettings .section.showAllLines .buttons .button.off").click((e) => {
setShowAllLines(false);
setSettingsButton("showAllLines", config.showAllLines);
});
//discord
$(
".pageSettings .section.discordIntegration .buttons .generateCodeButton"
@ -842,13 +521,6 @@ $(document).on("click", ".pageSettings .section.funbox .button", (e) => {
setActiveFunboxButton();
});
//fontfamily
$(document).on("click", ".pageSettings .section.fontFamily .button", (e) => {
let font = $(e.currentTarget).attr("fontFamily");
setFontFamily(font);
setActiveFontFamilyButton();
});
//tags
$(document).on(
"click",
@ -856,13 +528,6 @@ $(document).on(
(e) => {
let target = e.currentTarget;
let tagid = $(target).parent(".tag").attr("id");
// if($(target).attr('active') === 'true'){
// $(target).attr('active','false');
// $(target).html('<i class="fas fa-square"></i>')
// }else{
// $(target).attr('active','true');
// $(target).html('<i class="fas fa-check-square"></i>')
// }
toggleTag(tagid);
showActiveTags();
}
@ -913,8 +578,6 @@ $(".tab").click((e) => {
if ($target.attr("tab") == "preset") {
setCustomTheme(false);
applyCustomThemeColors();
// $('[tabContent="custom"]').removeClass("reveal");
// $('[tabContent="preset"]').addClass("reveal");
swapElements(
$('.pageSettings [tabContent="custom"]'),
$('.pageSettings [tabContent="preset"]'),
@ -928,9 +591,6 @@ $(".tab").click((e) => {
$('.pageSettings [tabContent="custom"]'),
250
);
// $('[tabContent="preset"]').removeClass("reveal");
// $('[tabContent="custom"]').addClass("reveal");
}
});
@ -942,12 +602,6 @@ $("[type='color']").on("input", (e) => {
document.documentElement.style.setProperty($colorVar, $pickedColor);
$("#" + $colorVar).attr("value", $pickedColor);
$("[for=" + $colorVar + "]").text($pickedColor);
// config.customThemeColors[colorVars.indexOf($colorVar)] = $pickedColor
});
$(".colorPicker").on("change", (e) => {
// Save a color once picked
});
$(".pageSettings .saveCustomThemeButton").click((e) => {
@ -968,9 +622,6 @@ $(".pageSettings .sectionGroupTitle").click((e) => {
.stop(true, true)
.slideToggle(250)
.toggleClass("slideup");
// $(`.pageSettings .sectionGroupTitle[group=${group}] .fas`).toggleClass(
// "rotate"
// );
if ($(`.pageSettings .settingsGroup.${group}`).hasClass("slideup")) {
$(`.pageSettings .sectionGroupTitle[group=${group}] .fas`)
.stop(true, true)

View file

@ -14,7 +14,7 @@ let defaultConfig = {
],
showKeyTips: true,
showLiveWpm: false,
showTimerBar: true,
showTimerProgress: true,
smoothCaret: true,
quickTab: false,
punctuation: false,
@ -31,7 +31,6 @@ let defaultConfig = {
caretStyle: "default",
flipTestColors: false,
layout: "default",
showDiscordDot: true,
confidenceMode: "off",
timerStyle: "bar",
colorfulMode: true,
@ -44,6 +43,7 @@ let defaultConfig = {
keymapLayout: "qwerty",
fontFamily: "Roboto_Mono",
smoothLineScroll: false,
alwaysShowDecimalPlaces: false,
};
let cookieConfig = null;
@ -53,7 +53,7 @@ let config = {
};
//cookies
function saveConfigToCookie() {
async function saveConfigToCookie() {
// showNotification('saving to cookie',1000);
if (config.freedomMode === null) config.freedomMode = false;
let d = new Date();
@ -67,7 +67,7 @@ function saveConfigToCookie() {
saveConfigToDB();
}
function saveConfigToDB() {
async function saveConfigToDB() {
if (firebase.auth().currentUser !== null) {
// showNotification('saving to db',1000);
accountIconLoading(true);
@ -134,7 +134,6 @@ function applyConfig(configObj) {
setBlindMode(configObj.blindMode, true);
setQuickEnd(configObj.quickEnd, true);
setFlipTestColors(configObj.flipTestColors, true);
setDiscordDot(configObj.hideDiscordDot, true);
setColorfulMode(configObj.colorfulMode, true);
setConfidenceMode(configObj.confidenceMode, true);
setTimerStyle(configObj.timerStyle, true);
@ -144,6 +143,9 @@ function applyConfig(configObj) {
changeKeymapLayout(configObj.keymapLayout, true);
setFontFamily(configObj.fontFamily, true);
setSmoothLineScroll(configObj.smoothLineScroll, true);
setShowLiveWpm(configObj.showLiveWpm, true);
setShowTimerProgress(configObj.showTimerProgress, true);
setAlwaysShowDecimalPlaces(config.alwaysShowDecimalPlaces, true);
if (
configObj.resultFilters == null ||
configObj.resultFilters == undefined
@ -192,34 +194,6 @@ function setDifficulty(diff, nosave) {
if (!nosave) saveConfigToCookie();
}
//blind mode
function toggleDiscordDot() {
dot = !config.showDiscordDot;
if (dot == undefined) {
dot = false;
}
config.showDiscordDot = dot;
if (!dot) {
$("#menu .discord").addClass("dotHidden");
} else {
$("#menu .discord").removeClass("dotHidden");
}
saveConfigToCookie();
}
function setDiscordDot(dot, nosave) {
if (dot == undefined) {
dot = false;
}
config.showDiscordDot = dot;
if (!dot) {
$("#menu .discord").addClass("dotHidden");
} else {
$("#menu .discord").removeClass("dotHidden");
}
if (!nosave) saveConfigToCookie();
}
//blind mode
function toggleBlindMode() {
blind = !config.blindMode;
@ -260,6 +234,20 @@ function setStopOnError(soe, nosave) {
if (!nosave) saveConfigToCookie();
}
//alwaysshowdecimal
function toggleAlwaysShowDecimalPlaces() {
config.alwaysShowDecimalPlaces = !config.alwaysShowDecimalPlaces;
saveConfigToCookie();
}
function setAlwaysShowDecimalPlaces(val, nosave) {
if (val == undefined) {
val = false;
}
config.alwaysShowDecimalPlaces = val;
if (!nosave) saveConfigToCookie();
}
//show all lines
function toggleShowAllLines() {
sal = !config.showAllLines;
@ -352,6 +340,38 @@ function setCaretStyle(caretStyle, nosave) {
if (!nosave) saveConfigToCookie();
}
function setShowTimerProgress(timer, nosave) {
if (timer == null || timer == undefined) {
timer = false;
}
config.showTimerProgress = timer;
if (!nosave) saveConfigToCookie();
}
function toggleShowTimerProgress() {
config.showTimerProgress = !config.showTimerProgress;
saveConfigToCookie();
}
function setShowLiveWpm(live, nosave) {
if (live == null || live == undefined) {
live = false;
}
config.showLiveWpm = live;
if (config.keymapMode !== "off") {
config.keymapMode = "off";
}
if (!nosave) saveConfigToCookie();
}
function toggleShowLiveWpm() {
config.showLiveWpm = !config.showLiveWpm;
if (config.keymapMode !== "off") {
config.keymapMode = "off";
}
saveConfigToCookie();
}
function setTimerStyle(style, nosave) {
if (style == null || style == undefined) {
style = "bar";