changed function names to follow the same convention

This commit is contained in:
Jack 2020-11-06 20:52:50 +00:00
parent aaf6e6b00e
commit 153cdb0898
4 changed files with 95 additions and 98 deletions

View file

@ -648,28 +648,28 @@ let commandsKeymapMode = {
id: "setKeymapModeOff",
display: "off",
exec: () => {
changeKeymapMode("off");
setKeymapMode("off");
},
},
{
id: "setKeymapModeStatic",
display: "static",
exec: () => {
changeKeymapMode("static");
setKeymapMode("static");
},
},
{
id: "setKeymapModeNext",
display: "next",
exec: () => {
changeKeymapMode("next");
setKeymapMode("next");
},
},
{
id: "setKeymapModeReact",
display: "react",
exec: () => {
changeKeymapMode("react");
setKeymapMode("react");
},
},
],
@ -960,28 +960,28 @@ let commandsKeymapStyle = {
id: "setKeymapStyleStaggered",
display: "staggered",
exec: () => {
changeKeymapStyle("staggered");
setKeymapStyle("staggered");
},
},
{
id: "setKeymapStyleMatrix",
display: "matrix",
exec: () => {
changeKeymapStyle("matrix");
setKeymapStyle("matrix");
},
},
{
id: "setKeymapStyleSplit",
display: "split",
exec: () => {
changeKeymapStyle("split");
setKeymapStyle("split");
},
},
{
id: "setKeymapStyleSplitMatrix",
display: "split matrix",
exec: () => {
changeKeymapStyle("split_matrix");
setKeymapStyle("split_matrix");
},
},
],
@ -1149,7 +1149,7 @@ let commandsWordCount = {
id: "changeWordCount10",
display: "10",
exec: () => {
changeWordCount("10");
setWordCount("10");
restartTest();
},
},
@ -1157,7 +1157,7 @@ let commandsWordCount = {
id: "changeWordCount25",
display: "25",
exec: () => {
changeWordCount("25");
setWordCount("25");
restartTest();
},
},
@ -1165,7 +1165,7 @@ let commandsWordCount = {
id: "changeWordCount50",
display: "50",
exec: () => {
changeWordCount("50");
setWordCount("50");
restartTest();
},
},
@ -1173,7 +1173,7 @@ let commandsWordCount = {
id: "changeWordCount100",
display: "100",
exec: () => {
changeWordCount("100");
setWordCount("100");
restartTest();
},
},
@ -1181,7 +1181,7 @@ let commandsWordCount = {
id: "changeWordCount200",
display: "200",
exec: () => {
changeWordCount("200");
setWordCount("200");
restartTest();
},
},
@ -1190,7 +1190,7 @@ let commandsWordCount = {
display: "custom...",
input: true,
exec: (input) => {
changeWordCount(input);
setWordCount(input);
restartTest();
},
},
@ -1204,7 +1204,7 @@ let commandsQuoteLengthConfig = {
id: "changeQuoteLengthAll",
display: "all",
exec: () => {
changeQuoteLength(-1);
setQuoteLength(-1);
restartTest();
},
},
@ -1212,7 +1212,7 @@ let commandsQuoteLengthConfig = {
id: "changeQuoteLengthShort",
display: "short",
exec: () => {
changeQuoteLength(0);
setQuoteLength(0);
restartTest();
},
},
@ -1220,7 +1220,7 @@ let commandsQuoteLengthConfig = {
id: "changeQuoteLengthMedium",
display: "medium",
exec: () => {
changeQuoteLength(1);
setQuoteLength(1);
restartTest();
},
},
@ -1228,7 +1228,7 @@ let commandsQuoteLengthConfig = {
id: "changeQuoteLengthLong",
display: "long",
exec: () => {
changeQuoteLength(2);
setQuoteLength(2);
restartTest();
},
},
@ -1236,7 +1236,7 @@ let commandsQuoteLengthConfig = {
id: "changeQuoteLengthThicc",
display: "thicc",
exec: () => {
changeQuoteLength(3);
setQuoteLength(3);
restartTest();
},
},
@ -1250,7 +1250,7 @@ let commandsMode = {
id: "changeModeTime",
display: "time",
exec: () => {
changeMode("time");
setMode("time");
restartTest();
},
},
@ -1258,7 +1258,7 @@ let commandsMode = {
id: "changeModeWords",
display: "words",
exec: () => {
changeMode("words");
setMode("words");
restartTest();
},
},
@ -1266,7 +1266,7 @@ let commandsMode = {
id: "changeModeQuote",
display: "quote",
exec: () => {
changeMode("quote");
setMode("quote");
restartTest();
},
},
@ -1274,7 +1274,7 @@ let commandsMode = {
id: "changeModeCustom",
display: "custom",
exec: () => {
changeMode("custom");
setMode("custom");
restartTest();
},
},
@ -1287,7 +1287,7 @@ let commandsTimeConfig = {
id: "changeTimeConfig15",
display: "15",
exec: () => {
changeTimeConfig("15");
setTimeConfig("15");
restartTest();
},
},
@ -1295,7 +1295,7 @@ let commandsTimeConfig = {
id: "changeTimeConfig30",
display: "30",
exec: () => {
changeTimeConfig("30");
setTimeConfig("30");
restartTest();
},
},
@ -1303,7 +1303,7 @@ let commandsTimeConfig = {
id: "changeTimeConfig60",
display: "60",
exec: () => {
changeTimeConfig("60");
setTimeConfig("60");
restartTest();
},
},
@ -1311,7 +1311,7 @@ let commandsTimeConfig = {
id: "changeTimeConfig120",
display: "120",
exec: () => {
changeTimeConfig("120");
setTimeConfig("120");
restartTest();
},
},
@ -1320,7 +1320,7 @@ let commandsTimeConfig = {
display: "custom...",
input: true,
exec: (input) => {
changeTimeConfig(input);
setTimeConfig(input);
restartTest();
},
},
@ -1388,7 +1388,7 @@ let commandsFontSize = {
id: "changeFontSize1",
display: "1x",
exec: () => {
changeFontSize(1);
setFontSize(1);
restartTest();
},
},
@ -1396,7 +1396,7 @@ let commandsFontSize = {
id: "changeFontSize125",
display: "1.25x",
exec: () => {
changeFontSize(125);
setFontSize(125);
restartTest();
},
},
@ -1404,7 +1404,7 @@ let commandsFontSize = {
id: "changeFontSize15",
display: "1.5x",
exec: () => {
changeFontSize(15);
setFontSize(15);
restartTest();
},
},
@ -1412,7 +1412,7 @@ let commandsFontSize = {
id: "changeFontSize2",
display: "2x",
exec: () => {
changeFontSize(2);
setFontSize(2);
restartTest();
},
},
@ -1420,7 +1420,7 @@ let commandsFontSize = {
id: "changeFontSize3",
display: "3x",
exec: () => {
changeFontSize(3);
setFontSize(3);
restartTest();
},
},
@ -1608,7 +1608,7 @@ getLanguageList().then((languages) => {
id: "changeLanguage" + capitalizeFirstLetter(language),
display: language.replace(/_/g, " "),
exec: () => {
changeLanguage(language);
setLanguage(language);
restartTest();
saveConfigToCookie();
},
@ -1645,7 +1645,7 @@ if (Object.keys(layouts).length > 0) {
id: "changeLayout" + capitalizeFirstLetter(layout),
display: layout.replace(/_/g, " "),
exec: () => {
changeSavedLayout(layout);
setSavedLayout(layout);
restartTest();
saveConfigToCookie();
},
@ -1669,7 +1669,7 @@ if (Object.keys(layouts).length > 0) {
id: "changeKeymapLayoutOverrideSync",
display: "override sync",
exec: () => {
changeKeymapLayout("overrideSync");
setKeymapLayout("overrideSync");
restartTest();
},
});
@ -1679,7 +1679,7 @@ if (Object.keys(layouts).length > 0) {
id: "changeKeymapLayout" + capitalizeFirstLetter(layout),
display: layout.replace(/_/g, " "),
exec: () => {
changeKeymapLayout(layout);
setKeymapLayout(layout);
restartTest();
},
});

View file

@ -331,7 +331,7 @@ function activateFunbox(funbox, mode) {
}
if (funbox === "simon_says") {
changeKeymapMode("next");
setKeymapMode("next");
settingsGroups.keymapMode.updateButton();
restartTest();
}
@ -343,16 +343,16 @@ function activateFunbox(funbox, mode) {
restartTest();
} else if (funbox === "layoutfluid") {
config.keymapMode = "on";
changeKeymapMode("next");
setKeymapMode("next");
settingsGroups.keymapMode.updateButton();
config.savedLayout = config.layout;
changeLayout("qwerty");
setLayout("qwerty");
settingsGroups.layout.updateButton();
changeKeymapLayout("qwerty");
setKeymapLayout("qwerty");
settingsGroups.keymapLayout.updateButton();
restartTest();
} else if (funbox === "memory") {
changeMode("words");
setMode("words");
setShowAllLines(true, true);
restartTest(false, true);
}
@ -361,7 +361,7 @@ function activateFunbox(funbox, mode) {
if (funbox !== "layoutfluid" || mode !== "script") {
if (config.layout !== config.savedLayout) {
changeLayout(config.savedLayout);
setLayout(config.savedLayout);
settingsGroups.layout.updateButton();
}
}
@ -1115,7 +1115,7 @@ function hideTimer() {
);
}
function changeTimerColor(color) {
function setTimerColor(color) {
$("#timer").removeClass("timerSub");
$("#timer").removeClass("timerText");
$("#timer").removeClass("timerMain");
@ -2673,8 +2673,8 @@ function startTest() {
if (config.layout !== layouts[index] && layouts[index] !== undefined) {
showNotification(`--- !!! ${layouts[index]} !!! ---`, 3000);
}
changeLayout(layouts[index]);
changeKeymapLayout(layouts[index]);
setLayout(layouts[index]);
setKeymapLayout(layouts[index]);
updateHighlightedKeymapKey();
settingsGroups.layout.updateButton();
}
@ -2759,7 +2759,7 @@ function restartTest(withSameWordset = false, nosave = false) {
if (modeBeforePractise !== null && !withSameWordset) {
showNotification("Reverting to previous settings.", 1500);
changeMode(modeBeforePractise);
setMode(modeBeforePractise);
modeBeforePractise = null;
}
@ -2862,9 +2862,9 @@ function restartTest(withSameWordset = false, nosave = false) {
document.querySelector("#liveWpm").innerHTML = "0";
if (activeFunBox === "layoutfluid") {
changeLayout("qwerty");
setLayout("qwerty");
settingsGroups.layout.updateButton();
changeKeymapLayout("qwerty");
setKeymapLayout("qwerty");
settingsGroups.keymapLayout.updateButton();
updateHighlightedKeymapKey();
}
@ -2932,14 +2932,14 @@ function focusWords() {
}
}
function changeCustomText() {
function setCustomText() {
customText = prompt("Custom text").trim();
customText = customText.replace(/[\n\r\t ]/gm, " ");
customText = customText.replace(/ +/gm, " ");
customText = customText.split(" ");
if (customText.length >= 10000) {
showNotification("Custom text cannot be longer than 10000 words.", 4000);
changeMode("time");
setMode("time");
customText = "The quick brown fox jumped over the lazy dog".split(" ");
}
// initWords();
@ -3035,7 +3035,7 @@ function changePage(page) {
}
}
function changeMode(mode, nosave) {
function setMode(mode, nosave) {
if (mode !== "words" && activeFunBox === "memory") {
showNotification("Memory funbox can only be used with words mode.");
return;
@ -4237,7 +4237,7 @@ function applyMode2Popup() {
if (mode == "time") {
if (val !== null && !isNaN(val) && val >= 0) {
changeTimeConfig(val);
setTimeConfig(val);
manualRestart = true;
restartTest();
if (val >= 1800) {
@ -4253,7 +4253,7 @@ function applyMode2Popup() {
}
} else if (mode == "words") {
if (val !== null && !isNaN(val) && val >= 0) {
changeWordCount(val);
setWordCount(val);
manualRestart = true;
restartTest();
if (val > 2000) {
@ -4281,7 +4281,7 @@ $(document).on("click", "#top .config .wordCount .text-button", (e) => {
if (wrd == "custom") {
// let newWrd = prompt("Custom word amount");
// if (newWrd !== null && !isNaN(newWrd) && newWrd > 0 && newWrd <= 10000) {
// changeWordCount(newWrd);
// setWordCount(newWrd);
// if (newWrd > 2000) {
// showNotification(
// "Very long tests can cause performance issues or crash the website on some machines!",
@ -4296,7 +4296,7 @@ $(document).on("click", "#top .config .wordCount .text-button", (e) => {
// }
showCustomMode2Popup("words");
} else {
changeWordCount(wrd);
setWordCount(wrd);
manualRestart = true;
restartTest();
}
@ -4307,7 +4307,7 @@ $(document).on("click", "#top .config .time .text-button", (e) => {
if (mode == "custom") {
// let newTime = prompt("Custom time in seconds");
// if (newTime !== null && !isNaN(newTime) && newTime > 0 && newTime <= 3600) {
// changeTimeConfig(newTime);
// setTimeConfig(newTime);
// if (newTime >= 1800) {
// showNotification(
// "Very long tests can cause performance issues or crash the website on some machines!",
@ -4319,7 +4319,7 @@ $(document).on("click", "#top .config .time .text-button", (e) => {
// }
showCustomMode2Popup("time");
} else {
changeTimeConfig(mode);
setTimeConfig(mode);
manualRestart = true;
restartTest();
@ -4328,7 +4328,7 @@ $(document).on("click", "#top .config .time .text-button", (e) => {
$(document).on("click", "#top .config .quoteLength .text-button", (e) => {
let len = $(e.currentTarget).attr("quoteLength");
changeQuoteLength(len);
setQuoteLength(len);
manualRestart = true;
restartTest();
});
@ -4360,7 +4360,7 @@ $("#wordsWrapper").on("click", (e) => {
$(document).on("click", "#top .config .mode .text-button", (e) => {
if ($(e.currentTarget).hasClass("active")) return;
mode = $(e.currentTarget).attr("mode");
changeMode(mode);
setMode(mode);
manualRestart = true;
restartTest();
});
@ -4426,7 +4426,7 @@ $(document.body).on("click", "#restartTestButton", (event) => {
function initPractiseMissedWords() {
let currentMode = config.mode;
changeMode("custom");
setMode("custom");
let newCustomText = [];
Object.keys(missedWords).forEach((missedWord) => {
for (let i = 0; i < missedWords[missedWord]; i++) {
@ -5039,8 +5039,8 @@ $(document).keydown((event) => {
if (config.layout !== layouts[index] && layouts[index] !== undefined) {
showNotification(`--- !!! ${layouts[index]} !!! ---`, 3000);
}
changeLayout(layouts[index]);
changeKeymapLayout(layouts[index]);
setLayout(layouts[index]);
setKeymapLayout(layouts[index]);
updateHighlightedKeymapKey();
settingsGroups.layout.updateButton();
}

View file

@ -87,7 +87,7 @@ settingsGroups.showTimerProgress = new SettingsGroup(
);
settingsGroups.keymapMode = new SettingsGroup(
"keymapMode",
changeKeymapMode,
setKeymapMode,
() => {
settingsGroups.showLiveWpm.updateButton();
},
@ -101,13 +101,10 @@ settingsGroups.keymapMode = new SettingsGroup(
}
}
);
settingsGroups.keymapMatrix = new SettingsGroup(
"keymapStyle",
changeKeymapStyle
);
settingsGroups.keymapMatrix = new SettingsGroup("keymapStyle", setKeymapStyle);
settingsGroups.keymapLayout = new SettingsGroup(
"keymapLayout",
changeKeymapLayout
setKeymapLayout
);
settingsGroups.showKeyTips = new SettingsGroup(
"showKeyTips",
@ -230,9 +227,9 @@ settingsGroups.capsLockBackspace = new SettingsGroup(
"capsLockBackspace",
setCapsLockBackspace
);
settingsGroups.layout = new SettingsGroup("layout", changeSavedLayout);
settingsGroups.language = new SettingsGroup("language", changeLanguage);
settingsGroups.fontSize = new SettingsGroup("fontSize", changeFontSize);
settingsGroups.layout = new SettingsGroup("layout", setSavedLayout);
settingsGroups.language = new SettingsGroup("language", setLanguage);
settingsGroups.fontSize = new SettingsGroup("fontSize", setFontSize);
settingsGroups.pageWidth = new SettingsGroup("pageWidth", setPageWidth);
settingsGroups.caretStyle = new SettingsGroup("caretStyle", setCaretStyle);
settingsGroups.paceCaretStyle = new SettingsGroup(

View file

@ -174,13 +174,13 @@ function applyConfig(configObj) {
setCustomThemeColors(configObj.customThemeColors, true);
setQuickTabMode(configObj.quickTab, true);
setKeyTips(configObj.showKeyTips, true);
changeTimeConfig(configObj.time, true);
changeQuoteLength(configObj.quoteLength, true);
changeWordCount(configObj.words, true);
changeLanguage(configObj.language, true);
setTimeConfig(configObj.time, true);
setQuoteLength(configObj.quoteLength, true);
setWordCount(configObj.words, true);
setLanguage(configObj.language, true);
setCapsLockBackspace(configObj.capsLockBackspace, true);
changeSavedLayout(configObj.savedLayout, true);
changeFontSize(configObj.fontSize, true);
setSavedLayout(configObj.savedLayout, true);
setFontSize(configObj.fontSize, true);
setFreedomMode(configObj.freedomMode, true);
setCaretStyle(configObj.caretStyle, true);
setPaceCaretStyle(configObj.paceCaretStyle, true);
@ -195,9 +195,9 @@ function applyConfig(configObj) {
setTimerStyle(configObj.timerStyle, true);
setTimerColor(configObj.timerColor, true);
setTimerOpacity(configObj.timerOpacity, true);
changeKeymapMode(configObj.keymapMode, true);
changeKeymapStyle(configObj.keymapStyle, true);
changeKeymapLayout(configObj.keymapLayout, true);
setKeymapMode(configObj.keymapMode, true);
setKeymapStyle(configObj.keymapStyle, true);
setKeymapLayout(configObj.keymapLayout, true);
setFontFamily(configObj.fontFamily, true);
setSmoothCaret(configObj.smoothCaret, true);
setSmoothLineScroll(configObj.smoothLineScroll, true);
@ -225,7 +225,7 @@ function applyConfig(configObj) {
setPunctuation(configObj.punctuation, true);
setHighlightMode(configObj.highlightMode, true);
setAlwaysShowCPM(configObj.alwaysShowCPM, true);
changeMode(configObj.mode, true);
setMode(configObj.mode, true);
config.startGraphsAtZero = configObj.startGraphsAtZero;
// if (
// configObj.resultFilters !== null &&
@ -796,7 +796,7 @@ function setTimerColor(color, nosave) {
color = "black";
}
config.timerColor = color;
changeTimerColor(color);
setTimerColor(color);
if (!nosave) saveConfigToCookie();
}
function setTimerOpacity(opacity, nosave) {
@ -829,13 +829,13 @@ function toggleKeyTips() {
}
//mode
function changeTimeConfig(time, nosave) {
function setTimeConfig(time, nosave) {
if (time !== null && !isNaN(time) && time >= 0) {
} else {
time = 15;
}
time = parseInt(time);
if (!nosave) changeMode("time", nosave);
if (!nosave) setMode("time", nosave);
config.time = time;
$("#top .config .time .text-button").removeClass("active");
if (![15, 30, 60, 120].includes(time)) {
@ -848,13 +848,13 @@ function changeTimeConfig(time, nosave) {
}
//quote length
function changeQuoteLength(len, nosave) {
function setQuoteLength(len, nosave) {
if (len !== null && !isNaN(len) && len >= -1 && len <= 3) {
} else {
len = 1;
}
len = parseInt(len);
if (!nosave) changeMode("quote", nosave);
if (!nosave) setMode("quote", nosave);
config.quoteLength = len;
$("#top .config .quoteLength .text-button").removeClass("active");
$(
@ -863,13 +863,13 @@ function changeQuoteLength(len, nosave) {
if (!nosave) saveConfigToCookie();
}
function changeWordCount(wordCount, nosave) {
function setWordCount(wordCount, nosave) {
if (wordCount !== null && !isNaN(wordCount) && wordCount >= 0) {
} else {
wordCount = 10;
}
wordCount = parseInt(wordCount);
if (!nosave) changeMode("words", nosave);
if (!nosave) setMode("words", nosave);
config.words = wordCount;
$("#top .config .wordCount .text-button").removeClass("active");
if (![10, 25, 50, 100, 200].includes(wordCount)) {
@ -1239,7 +1239,7 @@ function updateFavicon(size, curveSize) {
$("#favicon").attr("href", canvas.toDataURL("image/png"));
}
function changeLanguage(language, nosave) {
function setLanguage(language, nosave) {
if (language == null || language == undefined) {
language = "english";
}
@ -1266,7 +1266,7 @@ function toggleCapsLockBackspace() {
setCapsLockBackspace(!config.capsLockBackspace, false);
}
function changeLayout(layout, nosave) {
function setLayout(layout, nosave) {
if (layout == null || layout == undefined) {
layout = "qwerty";
}
@ -1278,15 +1278,15 @@ function changeLayout(layout, nosave) {
if (!nosave) saveConfigToCookie();
}
function changeSavedLayout(layout, nosave) {
function setSavedLayout(layout, nosave) {
if (layout == null || layout == undefined) {
layout = "qwerty";
}
config.savedLayout = layout;
changeLayout(layout, nosave);
setLayout(layout, nosave);
}
function changeKeymapMode(mode, nosave) {
function setKeymapMode(mode, nosave) {
if (mode == null || mode == undefined) {
mode = "off";
}
@ -1301,7 +1301,7 @@ function changeKeymapMode(mode, nosave) {
if (!nosave) saveConfigToCookie();
}
function changeKeymapStyle(style, nosave) {
function setKeymapStyle(style, nosave) {
$(".keymap").removeClass("matrix");
$(".keymap").removeClass("split");
$(".keymap").removeClass("split_matrix");
@ -1374,7 +1374,7 @@ function keymapShowIsoKey(tf) {
}
}
function changeKeymapLayout(layout, nosave) {
function setKeymapLayout(layout, nosave) {
if (layout == null || layout == undefined) {
layout = "qwerty";
}
@ -1475,11 +1475,11 @@ function refreshKeymapKeys(layout) {
console.log(
"something went wrong when changing layout, resettings: " + e.message
);
changeKeymapLayout("qwerty", true);
setKeymapLayout("qwerty", true);
}
}
function changeFontSize(fontSize, nosave) {
function setFontSize(fontSize, nosave) {
if (fontSize == null || fontSize == undefined) {
fontSize = 1;
}