mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-18 19:45:58 +08:00
moved some of the config into a temporary transition module
This commit is contained in:
parent
ce10bca858
commit
4940580aad
14 changed files with 1201 additions and 985 deletions
|
@ -106,6 +106,8 @@ const refactoredSrc = [
|
|||
"./src/js/test/caret.js",
|
||||
"./src/js/custom-text-popup.js",
|
||||
"./src/js/manual-restart-tracker.js",
|
||||
"./src/js/config.js",
|
||||
"./src/js/config-set.js",
|
||||
];
|
||||
|
||||
//legacy files
|
||||
|
|
|
@ -295,14 +295,14 @@ firebase.auth().onAuthStateChanged(function (user) {
|
|||
if (theme !== null) {
|
||||
try {
|
||||
theme = theme.split(",");
|
||||
config.customThemeColors = theme;
|
||||
ConfigSet.customThemeColors(theme);
|
||||
Notifications.add("Custom theme applied.", 1);
|
||||
} catch (e) {
|
||||
Notifications.add(
|
||||
"Something went wrong. Reverting to default custom colors.",
|
||||
0
|
||||
);
|
||||
config.customThemeColors = defaultConfig.customThemeColors;
|
||||
ConfigSet.customThemeColors(Config.defaultConfig.customThemeColors);
|
||||
}
|
||||
setCustomTheme(true);
|
||||
setCustomThemeInputs();
|
||||
|
@ -414,40 +414,40 @@ function getAccountDataAndInit() {
|
|||
} else {
|
||||
accountIconLoading(false);
|
||||
}
|
||||
if (config.paceCaret === "pb" || config.paceCaret === "average") {
|
||||
if (Config.paceCaret === "pb" || Config.paceCaret === "average") {
|
||||
if (!testActive) {
|
||||
initPaceCaret(true);
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// if (
|
||||
// config.resultFilters === undefined ||
|
||||
// config.resultFilters === null ||
|
||||
// config.resultFilters.difficulty === undefined
|
||||
// Config.resultFilters === undefined ||
|
||||
// Config.resultFilters === null ||
|
||||
// Config.resultFilters.difficulty === undefined
|
||||
// ) {
|
||||
// if (
|
||||
// DB.getSnapshot().config.resultFilters == null ||
|
||||
// DB.getSnapshot().config.resultFilters.difficulty === undefined
|
||||
// DB.getSnapshot().Config.resultFilters == null ||
|
||||
// DB.getSnapshot().Config.resultFilters.difficulty === undefined
|
||||
// ) {
|
||||
// config.resultFilters = defaultAccountFilters;
|
||||
// ConfigSet.resultFilters(defaultAccountFilters);
|
||||
// } else {
|
||||
// config.resultFilters = DB.getSnapshot().config.resultFilters;
|
||||
// ConfigSet.resultFilters(DB.getSnapshot().Config.resultFilters);
|
||||
// }
|
||||
// }
|
||||
// } catch (e) {
|
||||
// config.resultFilters = defaultAccountFilters;
|
||||
// ConfigSet.resultFilters(defaultAccountFilters);
|
||||
// }
|
||||
// if (
|
||||
// Object.keys(config.resultFilters.language).length !==
|
||||
// Object.keys(Config.resultFilters.language).length !==
|
||||
// Object.keys(defaultAccountFilters.language).length
|
||||
// ) {
|
||||
// config.resultFilters.language = defaultAccountFilters.language;
|
||||
// ConfigSet.resultFilters.language(defaultAccountFilters.language);
|
||||
// }
|
||||
// if (
|
||||
// Object.keys(config.resultFilters.funbox).length !==
|
||||
// Object.keys(Config.resultFilters.funbox).length !==
|
||||
// Object.keys(defaultAccountFilters.funbox).length
|
||||
// ) {
|
||||
// config.resultFilters.funbox = defaultAccountFilters.funbox;
|
||||
// ConfigSet.resultFilters.funbox(defaultAccountFilters.funbox);
|
||||
// }
|
||||
if (
|
||||
$(".pageLogin").hasClass("active") ||
|
||||
|
@ -497,7 +497,7 @@ function updateMiniResultChart(filteredId) {
|
|||
maxChartVal
|
||||
);
|
||||
|
||||
if (!config.startGraphsAtZero) {
|
||||
if (!Config.startGraphsAtZero) {
|
||||
ChartController.miniResult.options.scales.yAxes[0].ticks.min = Math.round(
|
||||
minChartVal
|
||||
);
|
||||
|
@ -790,33 +790,33 @@ $(".pageAccount .topFilters .button.currentConfigFilter").click((e) => {
|
|||
});
|
||||
});
|
||||
|
||||
ResultFilters.setFilter("difficulty", config.difficulty, true);
|
||||
ResultFilters.setFilter("mode", config.mode, true);
|
||||
if (config.mode === "time") {
|
||||
ResultFilters.setFilter("time", config.time, true);
|
||||
} else if (config.mode === "words") {
|
||||
ResultFilters.setFilter("words", config.words, true);
|
||||
} else if (config.mode === "quote") {
|
||||
ResultFilters.setFilter("difficulty", Config.difficulty, true);
|
||||
ResultFilters.setFilter("mode", Config.mode, true);
|
||||
if (Config.mode === "time") {
|
||||
ResultFilters.setFilter("time", Config.time, true);
|
||||
} else if (Config.mode === "words") {
|
||||
ResultFilters.setFilter("words", Config.words, true);
|
||||
} else if (Config.mode === "quote") {
|
||||
Object.keys(ResultFilters.getGroup("quoteLength")).forEach((ql) => {
|
||||
ResultFilters.setFilter("quoteLength", ql, true);
|
||||
});
|
||||
}
|
||||
if (config.punctuation) {
|
||||
if (Config.punctuation) {
|
||||
ResultFilters.setFilter("punctuation", "on", true);
|
||||
} else {
|
||||
ResultFilters.setFilter("punctuation", "off", true);
|
||||
}
|
||||
if (config.numbers) {
|
||||
if (Config.numbers) {
|
||||
ResultFilters.setFilter("numbers", "on", true);
|
||||
} else {
|
||||
ResultFilters.setFilter("numbers", "off", true);
|
||||
}
|
||||
if (config.mode === "quote" && /english.*/.test(config.language)) {
|
||||
if (Config.mode === "quote" && /english.*/.test(Config.language)) {
|
||||
ResultFilters.setFilter("language", "english", true);
|
||||
} else {
|
||||
ResultFilters.setFilter("language", config.language, true);
|
||||
ResultFilters.setFilter("language", Config.language, true);
|
||||
}
|
||||
ResultFilters.setFilter("funbox", activeFunBox, true);
|
||||
ResultFilters.setFilter("funbox", activeFunbox, true);
|
||||
ResultFilters.setFilter("tags", "none", true);
|
||||
DB.getSnapshot().tags.forEach((tag) => {
|
||||
if (tag.active === true) {
|
||||
|
@ -1656,7 +1656,7 @@ function refreshAccountPage() {
|
|||
ChartController.accountHistory.options.scales.yAxes[0].ticks.max =
|
||||
Math.floor(maxWpmChartVal) + (10 - (Math.floor(maxWpmChartVal) % 10));
|
||||
|
||||
if (!config.startGraphsAtZero) {
|
||||
if (!Config.startGraphsAtZero) {
|
||||
ChartController.accountHistory.options.scales.yAxes[0].ticks.min = Math.floor(
|
||||
minWpmChartVal
|
||||
);
|
||||
|
|
|
@ -502,7 +502,7 @@ let commands = {
|
|||
{
|
||||
id: "randomiseTheme",
|
||||
display: "Next random theme",
|
||||
exec: () => ThemeController.randomiseTheme(config),
|
||||
exec: () => ThemeController.randomiseTheme(),
|
||||
},
|
||||
{
|
||||
id: "viewTypingPage",
|
||||
|
@ -774,7 +774,7 @@ let commandsSoundOnClick = {
|
|||
display: "1",
|
||||
exec: () => {
|
||||
setPlaySoundOnClick("1");
|
||||
Sound.playClick(config.playSoundOnClick);
|
||||
Sound.playClick(Config.playSoundOnClick);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -782,7 +782,7 @@ let commandsSoundOnClick = {
|
|||
display: "2",
|
||||
exec: () => {
|
||||
setPlaySoundOnClick("2");
|
||||
Sound.playClick(config.playSoundOnClick);
|
||||
Sound.playClick(Config.playSoundOnClick);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -790,7 +790,7 @@ let commandsSoundOnClick = {
|
|||
display: "3",
|
||||
exec: () => {
|
||||
setPlaySoundOnClick("3");
|
||||
Sound.playClick(config.playSoundOnClick);
|
||||
Sound.playClick(Config.playSoundOnClick);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -798,7 +798,7 @@ let commandsSoundOnClick = {
|
|||
display: "4",
|
||||
exec: () => {
|
||||
setPlaySoundOnClick("4");
|
||||
Sound.playClick(config.playSoundOnClick);
|
||||
Sound.playClick(Config.playSoundOnClick);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -1537,13 +1537,7 @@ function updateCommandsTagsList() {
|
|||
DB.getSnapshot().tags.forEach((tag) => {
|
||||
tag.active = false;
|
||||
});
|
||||
updateTestModesNotice(
|
||||
sameWordset,
|
||||
textHasTab,
|
||||
paceCaret,
|
||||
activeFunBox,
|
||||
config
|
||||
);
|
||||
updateTestModesNotice(sameWordset, textHasTab, paceCaret, activeFunbox);
|
||||
saveActiveTagsToCookie();
|
||||
},
|
||||
});
|
||||
|
@ -1567,8 +1561,7 @@ function updateCommandsTagsList() {
|
|||
sameWordset,
|
||||
textHasTab,
|
||||
paceCaret,
|
||||
activeFunBox,
|
||||
config
|
||||
activeFunbox
|
||||
);
|
||||
let txt = tag.name;
|
||||
|
||||
|
@ -1610,9 +1603,9 @@ Misc.getThemesList().then((themes) => {
|
|||
});
|
||||
|
||||
function showFavouriteThemesAtTheTop() {
|
||||
if (config.favThemes.length > 0) {
|
||||
if (Config.favThemes.length > 0) {
|
||||
commandsThemes.list = [];
|
||||
config.favThemes.forEach((theme) => {
|
||||
Config.favThemes.forEach((theme) => {
|
||||
commandsThemes.list.push({
|
||||
id: "changeTheme" + Misc.capitalizeFirstLetter(theme),
|
||||
display: theme.replace(/_/g, " "),
|
||||
|
@ -1627,7 +1620,7 @@ function showFavouriteThemesAtTheTop() {
|
|||
});
|
||||
Misc.getThemesList().then((themes) => {
|
||||
themes.forEach((theme) => {
|
||||
if (config.favThemes.includes(theme.name)) return;
|
||||
if (Config.favThemes.includes(theme.name)) return;
|
||||
commandsThemes.list.push({
|
||||
id: "changeTheme" + Misc.capitalizeFirstLetter(theme.name),
|
||||
display: theme.name.replace(/_/g, " "),
|
||||
|
@ -1651,20 +1644,20 @@ let commandsFonts = {
|
|||
|
||||
function canBailOut() {
|
||||
return (
|
||||
(config.mode === "custom" &&
|
||||
(Config.mode === "custom" &&
|
||||
CustomText.isWordRandom &&
|
||||
CustomText.word >= 5000) ||
|
||||
(config.mode === "custom" &&
|
||||
(Config.mode === "custom" &&
|
||||
!CustomText.isWordRandom &&
|
||||
!CustomText.isTimeRandom &&
|
||||
CustomText.text.length >= 5000) ||
|
||||
(config.mode === "custom" &&
|
||||
(Config.mode === "custom" &&
|
||||
CustomText.isTimeRandom &&
|
||||
CustomText.time >= 3600) ||
|
||||
(config.mode === "words" && config.words >= 5000) ||
|
||||
config.words === 0 ||
|
||||
(config.mode === "time" && (config.time >= 3600 || config.time === 0)) ||
|
||||
config.mode == "zen"
|
||||
(Config.mode === "words" && Config.words >= 5000) ||
|
||||
Config.words === 0 ||
|
||||
(Config.mode === "time" && (Config.time >= 3600 || Config.time === 0)) ||
|
||||
Config.mode == "zen"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1711,12 +1704,12 @@ function isSingleListCommandLineActive() {
|
|||
|
||||
function useSingleListCommandLine(show = true) {
|
||||
let allCommands = generateSingleListOfCommands();
|
||||
if (config.singleListCommandLine == "manual")
|
||||
if (Config.singleListCommandLine == "manual")
|
||||
currentCommands.push(allCommands);
|
||||
else if (config.singleListCommandLine == "on")
|
||||
else if (Config.singleListCommandLine == "on")
|
||||
currentCommands = [allCommands];
|
||||
|
||||
if (config.singleListCommandLine != "off")
|
||||
if (Config.singleListCommandLine != "off")
|
||||
$("#commandLine").addClass("allCommands");
|
||||
if (show) showCommandLine();
|
||||
}
|
||||
|
@ -1748,7 +1741,7 @@ Misc.getFontsList().then((fonts) => {
|
|||
display: "custom...",
|
||||
input: true,
|
||||
hover: () => {
|
||||
previewFontFamily(config.fontFamily);
|
||||
previewFontFamily(Config.fontFamily);
|
||||
},
|
||||
exec: (name) => {
|
||||
setFontFamily(name.replace(/\s/g, "_"));
|
||||
|
@ -1895,7 +1888,7 @@ $("#commandLine input").keyup((e) => {
|
|||
$(document).ready((e) => {
|
||||
$(document).keydown((event) => {
|
||||
//escape
|
||||
if (event.keyCode == 27 || (event.keyCode == 9 && config.swapEscAndTab)) {
|
||||
if (event.keyCode == 27 || (event.keyCode == 9 && Config.swapEscAndTab)) {
|
||||
event.preventDefault();
|
||||
if (!$("#leaderboardsWrapper").hasClass("hidden")) {
|
||||
//maybe add more condition for closing other dialogs in the future as well
|
||||
|
@ -1909,9 +1902,9 @@ $(document).ready((e) => {
|
|||
} else {
|
||||
hideCommandLine();
|
||||
}
|
||||
setFontFamily(config.fontFamily, true);
|
||||
} else if (event.keyCode == 9 || !config.swapEscAndTab) {
|
||||
if (config.singleListCommandLine == "on")
|
||||
setFontFamily(Config.fontFamily, true);
|
||||
} else if (event.keyCode == 9 || !Config.swapEscAndTab) {
|
||||
if (Config.singleListCommandLine == "on")
|
||||
useSingleListCommandLine(false);
|
||||
else currentCommands = [commands];
|
||||
showCommandLine();
|
||||
|
@ -1985,7 +1978,7 @@ $("#commandLineWrapper #commandLine .suggestions").on("mouseover", (e) => {
|
|||
if (obj.id == hoverId) {
|
||||
if (!/theme/gi.test(obj.id) || obj.id === "toggleCustomTheme")
|
||||
ThemeController.clearPreview();
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(config.fontFamily);
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(Config.fontFamily);
|
||||
obj.hover();
|
||||
}
|
||||
});
|
||||
|
@ -2000,11 +1993,11 @@ $("#commandLineWrapper #commandLine .suggestions").click((e) => {
|
|||
$("#commandLineWrapper").click((e) => {
|
||||
if ($(e.target).attr("id") === "commandLineWrapper") {
|
||||
hideCommandLine();
|
||||
setFontFamily(config.fontFamily, true);
|
||||
// if (config.customTheme === true) {
|
||||
setFontFamily(Config.fontFamily, true);
|
||||
// if (Config.customTheme === true) {
|
||||
// applyCustomThemeColors();
|
||||
// } else {
|
||||
// setTheme(config.theme, true);
|
||||
// setTheme(Config.theme, true);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
@ -2013,11 +2006,11 @@ $(document).keydown((e) => {
|
|||
// if (isPreviewingTheme) {
|
||||
// console.log("applying theme");
|
||||
// applyCustomThemeColors();
|
||||
// previewTheme(config.theme, false);
|
||||
// previewTheme(Config.theme, false);
|
||||
// }
|
||||
if (!$("#commandLineWrapper").hasClass("hidden")) {
|
||||
$("#commandLine input").focus();
|
||||
if (e.key == ">" && config.singleListCommandLine == "manual") {
|
||||
if (e.key == ">" && Config.singleListCommandLine == "manual") {
|
||||
if (!isSingleListCommandLineActive()) {
|
||||
useSingleListCommandLine();
|
||||
return;
|
||||
|
@ -2030,7 +2023,7 @@ $(document).keydown((e) => {
|
|||
if (
|
||||
e.keyCode == 8 &&
|
||||
$("#commandLine input").val().length == 1 &&
|
||||
config.singleListCommandLine == "manual" &&
|
||||
Config.singleListCommandLine == "manual" &&
|
||||
isSingleListCommandLineActive()
|
||||
)
|
||||
restoreOldCommandLine();
|
||||
|
@ -2105,7 +2098,7 @@ $(document).keydown((e) => {
|
|||
if (obj.id == hoverId) {
|
||||
if (!/theme/gi.test(obj.id) || obj.id === "toggleCustomTheme")
|
||||
ThemeController.clearPreview();
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(config.fontFamily);
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(Config.fontFamily);
|
||||
obj.hover();
|
||||
}
|
||||
});
|
||||
|
@ -2150,7 +2143,7 @@ function triggerCommand(command) {
|
|||
}
|
||||
|
||||
function hideCommandLine() {
|
||||
previewFontFamily(config.fontFamily);
|
||||
previewFontFamily(Config.fontFamily);
|
||||
// applyCustomThemeColors();
|
||||
ThemeController.clearPreview();
|
||||
$("#commandLineWrapper")
|
||||
|
@ -2211,7 +2204,7 @@ function updateSuggestedCommands() {
|
|||
let list = currentCommands[currentCommands.length - 1];
|
||||
if (
|
||||
inputVal[0] === "" &&
|
||||
config.singleListCommandLine === "on" &&
|
||||
Config.singleListCommandLine === "on" &&
|
||||
currentCommands.length === 1
|
||||
) {
|
||||
$.each(list.list, (index, obj) => {
|
||||
|
@ -2285,7 +2278,7 @@ function displayFoundCommands() {
|
|||
if (obj.found) {
|
||||
if (!/theme/gi.test(obj.id) || obj.id === "toggleCustomTheme")
|
||||
ThemeController.clearPreview();
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(config.fontFamily);
|
||||
if (!/font/gi.test(obj.id)) previewFontFamily(Config.fontFamily);
|
||||
obj.hover();
|
||||
return false;
|
||||
}
|
||||
|
|
291
src/js/config-set.js
Normal file
291
src/js/config-set.js
Normal file
|
@ -0,0 +1,291 @@
|
|||
import Config, { reset as resetConfig } from "./config";
|
||||
|
||||
export let defaultConfig = {
|
||||
theme: "serika_dark",
|
||||
customTheme: false,
|
||||
customThemeColors: [
|
||||
"#323437",
|
||||
"#e2b714",
|
||||
"#e2b714",
|
||||
"#646669",
|
||||
"#d1d0c5",
|
||||
"#ca4754",
|
||||
"#7e2a33",
|
||||
"#ca4754",
|
||||
"#7e2a33",
|
||||
],
|
||||
favThemes: [],
|
||||
showKeyTips: true,
|
||||
showLiveWpm: false,
|
||||
showTimerProgress: true,
|
||||
smoothCaret: true,
|
||||
quickTab: false,
|
||||
punctuation: false,
|
||||
numbers: false,
|
||||
words: 50,
|
||||
time: 30,
|
||||
mode: "time",
|
||||
quoteLength: [1],
|
||||
language: "english",
|
||||
fontSize: 15,
|
||||
freedomMode: false,
|
||||
resultFilters: null,
|
||||
difficulty: "normal",
|
||||
blindMode: false,
|
||||
quickEnd: false,
|
||||
caretStyle: "default",
|
||||
paceCaretStyle: "default",
|
||||
flipTestColors: false,
|
||||
capsLockBackspace: false,
|
||||
layout: "default",
|
||||
savedLayout: "default",
|
||||
confidenceMode: "off",
|
||||
indicateTypos: false,
|
||||
timerStyle: "text",
|
||||
colorfulMode: false,
|
||||
randomTheme: "off",
|
||||
timerColor: "black",
|
||||
timerOpacity: "0.25",
|
||||
stopOnError: "off",
|
||||
showAllLines: false,
|
||||
keymapMode: "off",
|
||||
keymapStyle: "staggered",
|
||||
keymapLayout: "qwerty",
|
||||
fontFamily: "Roboto_Mono",
|
||||
smoothLineScroll: false,
|
||||
alwaysShowDecimalPlaces: false,
|
||||
alwaysShowWordsHistory: false,
|
||||
singleListCommandLine: "manual",
|
||||
playSoundOnError: false,
|
||||
playSoundOnClick: "off",
|
||||
startGraphsAtZero: true,
|
||||
swapEscAndTab: false,
|
||||
showOutOfFocusWarning: true,
|
||||
paceCaret: "off",
|
||||
paceCaretCustomSpeed: 100,
|
||||
pageWidth: "100",
|
||||
chartAccuracy: true,
|
||||
chartStyle: "line",
|
||||
minWpm: "off",
|
||||
minWpmCustomSpeed: 100,
|
||||
highlightMode: "letter",
|
||||
alwaysShowCPM: false,
|
||||
enableAds: "off",
|
||||
hideExtraLetters: false,
|
||||
strictSpace: false,
|
||||
minAcc: "off",
|
||||
minAccCustom: 90,
|
||||
showLiveAcc: false,
|
||||
monkey: false,
|
||||
repeatQuotes: "off",
|
||||
oppositeShiftMode: "off",
|
||||
};
|
||||
|
||||
export function reset() {
|
||||
resetConfig();
|
||||
}
|
||||
|
||||
export function theme(val) {
|
||||
Config.theme = val;
|
||||
}
|
||||
export function customTheme(val) {
|
||||
Config.customTheme = val;
|
||||
}
|
||||
export function customThemeColors(val) {
|
||||
Config.customThemeColors = val;
|
||||
}
|
||||
export function favThemes(val) {
|
||||
Config.favThemes = val;
|
||||
}
|
||||
export function showKeyTips(val) {
|
||||
Config.showKeyTips = val;
|
||||
}
|
||||
export function showLiveWpm(val) {
|
||||
Config.showLiveWpm = val;
|
||||
}
|
||||
export function showTimerProgress(val) {
|
||||
Config.showTimerProgress = val;
|
||||
}
|
||||
export function smoothCaret(val) {
|
||||
Config.smoothCaret = val;
|
||||
}
|
||||
export function quickTab(val) {
|
||||
Config.quickTab = val;
|
||||
}
|
||||
export function punctuation(val) {
|
||||
Config.punctuation = val;
|
||||
}
|
||||
export function numbers(val) {
|
||||
Config.numbers = val;
|
||||
}
|
||||
export function words(val) {
|
||||
Config.words = val;
|
||||
}
|
||||
export function time(val) {
|
||||
Config.time = val;
|
||||
}
|
||||
export function mode(val) {
|
||||
Config.mode = val;
|
||||
}
|
||||
export function quoteLength(val) {
|
||||
Config.quoteLength = val;
|
||||
}
|
||||
export function language(val) {
|
||||
Config.language = val;
|
||||
}
|
||||
export function fontSize(val) {
|
||||
Config.fontSize = val;
|
||||
}
|
||||
export function freedomMode(val) {
|
||||
Config.freedomMode = val;
|
||||
}
|
||||
export function resultFilters(val) {
|
||||
Config.resultFilters = val;
|
||||
}
|
||||
export function difficulty(val) {
|
||||
Config.difficulty = val;
|
||||
}
|
||||
export function blindMode(val) {
|
||||
Config.blindMode = val;
|
||||
}
|
||||
export function quickEnd(val) {
|
||||
Config.quickEnd = val;
|
||||
}
|
||||
export function caretStyle(val) {
|
||||
Config.caretStyle = val;
|
||||
}
|
||||
export function paceCaretStyle(val) {
|
||||
Config.paceCaretStyle = val;
|
||||
}
|
||||
export function flipTestColors(val) {
|
||||
Config.flipTestColors = val;
|
||||
}
|
||||
export function capsLockBackspace(val) {
|
||||
Config.capsLockBackspace = val;
|
||||
}
|
||||
export function layout(val) {
|
||||
Config.layout = val;
|
||||
}
|
||||
export function savedLayout(val) {
|
||||
Config.savedLayout = val;
|
||||
}
|
||||
export function confidenceMode(val) {
|
||||
Config.confidenceMode = val;
|
||||
}
|
||||
export function indicateTypos(val) {
|
||||
Config.indicateTypos = val;
|
||||
}
|
||||
export function timerStyle(val) {
|
||||
Config.timerStyle = val;
|
||||
}
|
||||
export function colorfulMode(val) {
|
||||
Config.colorfulMode = val;
|
||||
}
|
||||
export function randomTheme(val) {
|
||||
Config.randomTheme = val;
|
||||
}
|
||||
export function timerColor(val) {
|
||||
Config.timerColor = val;
|
||||
}
|
||||
export function timerOpacity(val) {
|
||||
Config.timerOpacity = val;
|
||||
}
|
||||
export function stopOnError(val) {
|
||||
Config.stopOnError = val;
|
||||
}
|
||||
export function showAllLines(val) {
|
||||
Config.showAllLines = val;
|
||||
}
|
||||
export function keymapMode(val) {
|
||||
Config.keymapMode = val;
|
||||
}
|
||||
export function keymapStyle(val) {
|
||||
Config.keymapStyle = val;
|
||||
}
|
||||
export function keymapLayout(val) {
|
||||
Config.keymapLayout = val;
|
||||
}
|
||||
export function fontFamily(val) {
|
||||
Config.fontFamily = val;
|
||||
}
|
||||
export function smoothLineScroll(val) {
|
||||
Config.smoothLineScroll = val;
|
||||
}
|
||||
export function alwaysShowDecimalPlaces(val) {
|
||||
Config.alwaysShowDecimalPlaces = val;
|
||||
}
|
||||
export function alwaysShowWordsHistory(val) {
|
||||
Config.alwaysShowWordsHistory = val;
|
||||
}
|
||||
export function singleListCommandLine(val) {
|
||||
Config.singleListCommandLine = val;
|
||||
}
|
||||
export function playSoundOnError(val) {
|
||||
Config.playSoundOnError = val;
|
||||
}
|
||||
export function playSoundOnClick(val) {
|
||||
Config.playSoundOnClick = val;
|
||||
}
|
||||
export function startGraphsAtZero(val) {
|
||||
Config.startGraphsAtZero = val;
|
||||
}
|
||||
export function swapEscAndTab(val) {
|
||||
Config.swapEscAndTab = val;
|
||||
}
|
||||
export function showOutOfFocusWarning(val) {
|
||||
Config.showOutOfFocusWarning = val;
|
||||
}
|
||||
export function paceCaret(val) {
|
||||
Config.paceCaret = val;
|
||||
}
|
||||
export function paceCaretCustomSpeed(val) {
|
||||
Config.paceCaretCustomSpeed = val;
|
||||
}
|
||||
export function pageWidth(val) {
|
||||
Config.pageWidth = val;
|
||||
}
|
||||
export function chartAccuracy(val) {
|
||||
Config.chartAccuracy = val;
|
||||
}
|
||||
export function chartStyle(val) {
|
||||
Config.chartStyle = val;
|
||||
}
|
||||
export function minWpm(val) {
|
||||
Config.minWpm = val;
|
||||
}
|
||||
export function minWpmCustomSpeed(val) {
|
||||
Config.minWpmCustomSpeed = val;
|
||||
}
|
||||
export function highlightMode(val) {
|
||||
Config.highlightMode = val;
|
||||
}
|
||||
export function alwaysShowCPM(val) {
|
||||
Config.alwaysShowCPM = val;
|
||||
}
|
||||
export function enableAds(val) {
|
||||
Config.enableAds = val;
|
||||
}
|
||||
export function hideExtraLetters(val) {
|
||||
Config.hideExtraLetters = val;
|
||||
}
|
||||
export function strictSpace(val) {
|
||||
Config.strictSpace = val;
|
||||
}
|
||||
export function minAcc(val) {
|
||||
Config.minAcc = val;
|
||||
}
|
||||
export function minAccCustom(val) {
|
||||
Config.minAccCustom = val;
|
||||
}
|
||||
export function showLiveAcc(val) {
|
||||
Config.showLiveAcc = val;
|
||||
}
|
||||
export function monkey(val) {
|
||||
Config.monkey = val;
|
||||
}
|
||||
export function repeatQuotes(val) {
|
||||
Config.repeatQuotes = val;
|
||||
}
|
||||
export function oppositeShiftMode(val) {
|
||||
Config.oppositeShiftMode = val;
|
||||
}
|
88
src/js/config.js
Normal file
88
src/js/config.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
import * as ConfigSet from "./config-set";
|
||||
|
||||
let config = {
|
||||
theme: "serika_dark",
|
||||
customTheme: false,
|
||||
customThemeColors: [
|
||||
"#323437",
|
||||
"#e2b714",
|
||||
"#e2b714",
|
||||
"#646669",
|
||||
"#d1d0c5",
|
||||
"#ca4754",
|
||||
"#7e2a33",
|
||||
"#ca4754",
|
||||
"#7e2a33",
|
||||
],
|
||||
favThemes: [],
|
||||
showKeyTips: true,
|
||||
showLiveWpm: false,
|
||||
showTimerProgress: true,
|
||||
smoothCaret: true,
|
||||
quickTab: false,
|
||||
punctuation: false,
|
||||
numbers: false,
|
||||
words: 50,
|
||||
time: 30,
|
||||
mode: "time",
|
||||
quoteLength: [1],
|
||||
language: "english",
|
||||
fontSize: 15,
|
||||
freedomMode: false,
|
||||
resultFilters: null,
|
||||
difficulty: "normal",
|
||||
blindMode: false,
|
||||
quickEnd: false,
|
||||
caretStyle: "default",
|
||||
paceCaretStyle: "default",
|
||||
flipTestColors: false,
|
||||
capsLockBackspace: false,
|
||||
layout: "default",
|
||||
savedLayout: "default",
|
||||
confidenceMode: "off",
|
||||
indicateTypos: false,
|
||||
timerStyle: "text",
|
||||
colorfulMode: false,
|
||||
randomTheme: "off",
|
||||
timerColor: "black",
|
||||
timerOpacity: "0.25",
|
||||
stopOnError: "off",
|
||||
showAllLines: false,
|
||||
keymapMode: "off",
|
||||
keymapStyle: "staggered",
|
||||
keymapLayout: "qwerty",
|
||||
fontFamily: "Roboto_Mono",
|
||||
smoothLineScroll: false,
|
||||
alwaysShowDecimalPlaces: false,
|
||||
alwaysShowWordsHistory: false,
|
||||
singleListCommandLine: "manual",
|
||||
playSoundOnError: false,
|
||||
playSoundOnClick: "off",
|
||||
startGraphsAtZero: true,
|
||||
swapEscAndTab: false,
|
||||
showOutOfFocusWarning: true,
|
||||
paceCaret: "off",
|
||||
paceCaretCustomSpeed: 100,
|
||||
pageWidth: "100",
|
||||
chartAccuracy: true,
|
||||
chartStyle: "line",
|
||||
minWpm: "off",
|
||||
minWpmCustomSpeed: 100,
|
||||
highlightMode: "letter",
|
||||
alwaysShowCPM: false,
|
||||
enableAds: "off",
|
||||
hideExtraLetters: false,
|
||||
strictSpace: false,
|
||||
minAcc: "off",
|
||||
minAccCustom: 90,
|
||||
showLiveAcc: false,
|
||||
monkey: false,
|
||||
repeatQuotes: "off",
|
||||
oppositeShiftMode: "off",
|
||||
};
|
||||
|
||||
export function reset() {
|
||||
config = ConfigSet.defaultConfig;
|
||||
}
|
||||
|
||||
export default config;
|
|
@ -1,4 +1,5 @@
|
|||
import * as DB from "./db";
|
||||
import Config from "./config";
|
||||
|
||||
export function showBackgroundLoader() {
|
||||
$("#backgroundLoader").stop(true, true).fadeIn(125);
|
||||
|
@ -84,8 +85,7 @@ export function updateTestModesNotice(
|
|||
sameWordset,
|
||||
textHasTab,
|
||||
paceCaret,
|
||||
activeFunBox,
|
||||
config
|
||||
activeFunbox
|
||||
) {
|
||||
let anim = false;
|
||||
if ($(".pageTest #testModesNotice").text() === "") anim = true;
|
||||
|
@ -104,7 +104,7 @@ export function updateTestModesNotice(
|
|||
);
|
||||
}
|
||||
|
||||
if (config.mode === "zen") {
|
||||
if (Config.mode === "zen") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button"><i class="fas fa-poll"></i>shift + enter to finish zen </div>`
|
||||
);
|
||||
|
@ -112,92 +112,92 @@ export function updateTestModesNotice(
|
|||
|
||||
// /^[0-9a-zA-Z_.-]+$/.test(name);
|
||||
|
||||
if (/_\d+k$/g.test(config.language) && config.mode !== "quote") {
|
||||
if (/_\d+k$/g.test(Config.language) && Config.mode !== "quote") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsLanguages"><i class="fas fa-globe-americas"></i>${config.language.replace(
|
||||
`<div class="text-button" commands="commandsLanguages"><i class="fas fa-globe-americas"></i>${Config.language.replace(
|
||||
/_/g,
|
||||
" "
|
||||
)}</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.difficulty === "expert") {
|
||||
if (Config.difficulty === "expert") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsDifficulty"><i class="fas fa-star-half-alt"></i>expert</div>`
|
||||
);
|
||||
} else if (config.difficulty === "master") {
|
||||
} else if (Config.difficulty === "master") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsDifficulty"><i class="fas fa-star"></i>master</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.blindMode) {
|
||||
if (Config.blindMode) {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" function="toggleBlindMode()"><i class="fas fa-eye-slash"></i>blind</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.paceCaret !== "off") {
|
||||
if (Config.paceCaret !== "off") {
|
||||
let speed = "";
|
||||
try {
|
||||
speed = ` (${Math.round(paceCaret.wpm)} wpm)`;
|
||||
} catch {}
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsPaceCaret"><i class="fas fa-tachometer-alt"></i>${
|
||||
config.paceCaret === "average"
|
||||
Config.paceCaret === "average"
|
||||
? "average"
|
||||
: config.paceCaret === "pb"
|
||||
: Config.paceCaret === "pb"
|
||||
? "pb"
|
||||
: "custom"
|
||||
} pace${speed}</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.minWpm !== "off") {
|
||||
if (Config.minWpm !== "off") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsMinWpm"><i class="fas fa-bomb"></i>min ${config.minWpmCustomSpeed} wpm</div>`
|
||||
`<div class="text-button" commands="commandsMinWpm"><i class="fas fa-bomb"></i>min ${Config.minWpmCustomSpeed} wpm</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.minAcc !== "off") {
|
||||
if (Config.minAcc !== "off") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsMinAcc"><i class="fas fa-bomb"></i>min ${config.minAccCustom}% acc</div>`
|
||||
`<div class="text-button" commands="commandsMinAcc"><i class="fas fa-bomb"></i>min ${Config.minAccCustom}% acc</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (activeFunBox !== "none") {
|
||||
if (activeFunbox !== "none") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsFunbox"><i class="fas fa-gamepad"></i>${activeFunBox.replace(
|
||||
`<div class="text-button" commands="commandsFunbox"><i class="fas fa-gamepad"></i>${activeFunbox.replace(
|
||||
/_/g,
|
||||
" "
|
||||
)}</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.confidenceMode === "on") {
|
||||
if (Config.confidenceMode === "on") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsConfidenceMode"><i class="fas fa-backspace"></i>confidence</div>`
|
||||
);
|
||||
}
|
||||
if (config.confidenceMode === "max") {
|
||||
if (Config.confidenceMode === "max") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsConfidenceMode"><i class="fas fa-backspace"></i>max confidence</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.stopOnError != "off") {
|
||||
if (Config.stopOnError != "off") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsStopOnError"><i class="fas fa-hand-paper"></i>stop on ${config.stopOnError}</div>`
|
||||
`<div class="text-button" commands="commandsStopOnError"><i class="fas fa-hand-paper"></i>stop on ${Config.stopOnError}</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.layout !== "default") {
|
||||
if (Config.layout !== "default") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsLayouts"><i class="fas fa-keyboard"></i>${config.layout}</div>`
|
||||
`<div class="text-button" commands="commandsLayouts"><i class="fas fa-keyboard"></i>${Config.layout}</div>`
|
||||
);
|
||||
}
|
||||
|
||||
if (config.oppositeShiftMode === "on") {
|
||||
if (Config.oppositeShiftMode === "on") {
|
||||
$(".pageTest #testModesNotice").append(
|
||||
`<div class="text-button" commands="commandsOppositeShiftMode"><i class="fas fa-exchange-alt"></i>opposite shift</div>`
|
||||
);
|
||||
|
|
|
@ -7,6 +7,6 @@ global.getuid = getuid;
|
|||
|
||||
//these exports are just for debugging in the browser
|
||||
global.snapshot = DB.getSnapshot;
|
||||
global.config = config;
|
||||
global.config = Config;
|
||||
// global.addnotif = Notifications.add;
|
||||
global.link = linkWithGoogle;
|
||||
|
|
|
@ -34,3 +34,5 @@ import * as ThemeController from "./theme-controller";
|
|||
import * as Caret from "./caret";
|
||||
import * as CustomTextPopup from "./custom-text-popup";
|
||||
import * as ManualRestart from "./manual-restart-tracker";
|
||||
import Config from "./config";
|
||||
import * as ConfigSet from "./config-set";
|
||||
|
|
981
src/js/script.js
981
src/js/script.js
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ class SettingsGroup {
|
|||
updateCallback = null
|
||||
) {
|
||||
this.configName = configName;
|
||||
this.configValue = config[configName];
|
||||
this.configValue = Config[configName];
|
||||
if (this.configValue === true || this.configValue === false) {
|
||||
this.onOff = true;
|
||||
} else {
|
||||
|
@ -53,7 +53,7 @@ class SettingsGroup {
|
|||
}
|
||||
|
||||
updateButton() {
|
||||
this.configValue = config[this.configName];
|
||||
this.configValue = Config[this.configName];
|
||||
$(`.pageSettings .section.${this.configName} .button`).removeClass(
|
||||
"active"
|
||||
);
|
||||
|
@ -100,7 +100,7 @@ settingsGroups.keymapMode = new SettingsGroup(
|
|||
settingsGroups.showLiveWpm.updateButton();
|
||||
},
|
||||
() => {
|
||||
if (config.keymapMode === "off") {
|
||||
if (Config.keymapMode === "off") {
|
||||
$(".pageSettings .section.keymapStyle").addClass("hidden");
|
||||
$(".pageSettings .section.keymapLayout").addClass("hidden");
|
||||
} else {
|
||||
|
@ -119,7 +119,7 @@ settingsGroups.showKeyTips = new SettingsGroup(
|
|||
setKeyTips,
|
||||
null,
|
||||
() => {
|
||||
if (config.showKeyTips) {
|
||||
if (Config.showKeyTips) {
|
||||
$(".pageSettings .tip").removeClass("hidden");
|
||||
} else {
|
||||
$(".pageSettings .tip").addClass("hidden");
|
||||
|
@ -205,8 +205,8 @@ settingsGroups.playSoundOnClick = new SettingsGroup(
|
|||
"playSoundOnClick",
|
||||
setPlaySoundOnClick,
|
||||
() => {
|
||||
if (config.playSoundOnClick !== "off")
|
||||
Sound.playClick(config.playSoundOnClick);
|
||||
if (Config.playSoundOnClick !== "off")
|
||||
Sound.playClick(Config.playSoundOnClick);
|
||||
}
|
||||
);
|
||||
settingsGroups.showAllLines = new SettingsGroup(
|
||||
|
@ -214,7 +214,7 @@ settingsGroups.showAllLines = new SettingsGroup(
|
|||
setShowAllLines
|
||||
);
|
||||
settingsGroups.paceCaret = new SettingsGroup("paceCaret", setPaceCaret, () => {
|
||||
if (config.paceCaret === "custom") {
|
||||
if (Config.paceCaret === "custom") {
|
||||
$(
|
||||
".pageSettings .section.paceCaret input.customPaceCaretSpeed"
|
||||
).removeClass("hidden");
|
||||
|
@ -225,7 +225,7 @@ settingsGroups.paceCaret = new SettingsGroup("paceCaret", setPaceCaret, () => {
|
|||
}
|
||||
});
|
||||
settingsGroups.minWpm = new SettingsGroup("minWpm", setMinWpm, () => {
|
||||
if (config.minWpm === "custom") {
|
||||
if (Config.minWpm === "custom") {
|
||||
$(".pageSettings .section.minWpm input.customMinWpmSpeed").removeClass(
|
||||
"hidden"
|
||||
);
|
||||
|
@ -236,7 +236,7 @@ settingsGroups.minWpm = new SettingsGroup("minWpm", setMinWpm, () => {
|
|||
}
|
||||
});
|
||||
settingsGroups.minAcc = new SettingsGroup("minAcc", setMinAcc, () => {
|
||||
if (config.minAcc === "custom") {
|
||||
if (Config.minAcc === "custom") {
|
||||
$(".pageSettings .section.minAcc input.customMinAcc").removeClass("hidden");
|
||||
} else {
|
||||
$(".pageSettings .section.minAcc input.customMinAcc").addClass("hidden");
|
||||
|
@ -277,7 +277,7 @@ settingsGroups.fontFamily = new SettingsGroup(
|
|||
let customButton = $(".pageSettings .section.fontFamily .buttons .custom");
|
||||
if ($(".pageSettings .section.fontFamily .buttons .active").length === 0) {
|
||||
customButton.addClass("active");
|
||||
customButton.text(`Custom (${config.fontFamily.replace(/_/g, " ")})`);
|
||||
customButton.text(`Custom (${Config.fontFamily.replace(/_/g, " ")})`);
|
||||
} else {
|
||||
customButton.text("Custom");
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ async function fillSettingsPage() {
|
|||
let langGroupsEl = $(
|
||||
".pageSettings .section.languageGroups .buttons"
|
||||
).empty();
|
||||
let currentLanguageGroup = await Misc.findCurrentGroup(config.language);
|
||||
let currentLanguageGroup = await Misc.findCurrentGroup(Config.language);
|
||||
Misc.getLanguageGroups().then((groups) => {
|
||||
groups.forEach((group) => {
|
||||
langGroupsEl.append(
|
||||
|
@ -368,10 +368,10 @@ async function fillSettingsPage() {
|
|||
let fontsEl = $(".pageSettings .section.fontFamily .buttons").empty();
|
||||
Misc.getFontsList().then((fonts) => {
|
||||
fonts.forEach((font) => {
|
||||
if (config.fontFamily === font.name) isCustomFont = false;
|
||||
if (ConfigSet.fontFamily === font.name) isCustomFont(false);
|
||||
fontsEl.append(
|
||||
`<div class="button${
|
||||
config.fontFamily === font.name ? " active" : ""
|
||||
Config.fontFamily === font.name ? " active" : ""
|
||||
}" style="font-family:${
|
||||
font.display !== undefined ? font.display : font.name
|
||||
}" fontFamily="${font.name.replace(/ /g, "_")}" tabindex="0"
|
||||
|
@ -382,7 +382,7 @@ async function fillSettingsPage() {
|
|||
});
|
||||
$(
|
||||
isCustomFont
|
||||
? `<div class="language button no-auto-handle custom active" onclick="this.blur();">Custom (${config.fontFamily.replace(
|
||||
? `<div class="language button no-auto-handle custom active" onclick="this.blur();">Custom (${Config.fontFamily.replace(
|
||||
/_/g,
|
||||
" "
|
||||
)})</div>`
|
||||
|
@ -401,17 +401,17 @@ function refreshThemeButtons() {
|
|||
).empty();
|
||||
let themesEl = $(".pageSettings .section.themes .allThemes.buttons").empty();
|
||||
|
||||
let activeThemeName = config.theme;
|
||||
if (config.randomTheme !== "off" && ThemeController.randomTheme !== null) {
|
||||
let activeThemeName = Config.theme;
|
||||
if (Config.randomTheme !== "off" && ThemeController.randomTheme !== null) {
|
||||
activeThemeName = ThemeController.randomTheme;
|
||||
}
|
||||
|
||||
Misc.getSortedThemesList().then((themes) => {
|
||||
//first show favourites
|
||||
if (config.favThemes.length > 0) {
|
||||
if (Config.favThemes.length > 0) {
|
||||
favThemesEl.css({ paddingBottom: "1rem" });
|
||||
themes.forEach((theme) => {
|
||||
if (config.favThemes.includes(theme.name)) {
|
||||
if (Config.favThemes.includes(theme.name)) {
|
||||
let activeTheme = activeThemeName === theme.name ? "active" : "";
|
||||
favThemesEl.append(
|
||||
`<div class="theme button" theme='${theme.name}' style="color:${
|
||||
|
@ -428,7 +428,7 @@ function refreshThemeButtons() {
|
|||
}
|
||||
//then the rest
|
||||
themes.forEach((theme) => {
|
||||
if (!config.favThemes.includes(theme.name)) {
|
||||
if (!Config.favThemes.includes(theme.name)) {
|
||||
let activeTheme = activeThemeName === theme.name ? "active" : "";
|
||||
themesEl.append(
|
||||
`<div class="theme button" theme='${theme.name}' style="color:${
|
||||
|
@ -458,12 +458,12 @@ function updateSettingsPage() {
|
|||
updateDiscordSettingsSection();
|
||||
refreshThemeButtons();
|
||||
|
||||
if (config.paceCaret === "custom") {
|
||||
if (Config.paceCaret === "custom") {
|
||||
$(
|
||||
".pageSettings .section.paceCaret input.customPaceCaretSpeed"
|
||||
).removeClass("hidden");
|
||||
$(".pageSettings .section.paceCaret input.customPaceCaretSpeed").val(
|
||||
config.paceCaretCustomSpeed
|
||||
Config.paceCaretCustomSpeed
|
||||
);
|
||||
} else {
|
||||
$(".pageSettings .section.paceCaret input.customPaceCaretSpeed").addClass(
|
||||
|
@ -471,12 +471,12 @@ function updateSettingsPage() {
|
|||
);
|
||||
}
|
||||
|
||||
if (config.minWpm === "custom") {
|
||||
if (Config.minWpm === "custom") {
|
||||
$(".pageSettings .section.minWpm input.customMinWpmSpeed").removeClass(
|
||||
"hidden"
|
||||
);
|
||||
$(".pageSettings .section.minWpm input.customMinWpmSpeed").val(
|
||||
config.minWpmCustomSpeed
|
||||
Config.minWpmCustomSpeed
|
||||
);
|
||||
} else {
|
||||
$(".pageSettings .section.minWpm input.customMinWpmSpeed").addClass(
|
||||
|
@ -484,10 +484,10 @@ function updateSettingsPage() {
|
|||
);
|
||||
}
|
||||
|
||||
if (config.minAcc === "custom") {
|
||||
if (Config.minAcc === "custom") {
|
||||
$(".pageSettings .section.minAcc input.customMinAcc").removeClass("hidden");
|
||||
$(".pageSettings .section.minAcc input.customMinAcc").val(
|
||||
config.minAccCustom
|
||||
Config.minAccCustom
|
||||
);
|
||||
} else {
|
||||
$(".pageSettings .section.minAcc input.customMinAcc").addClass("hidden");
|
||||
|
@ -519,8 +519,8 @@ function showCustomThemeShare() {
|
|||
function hideCustomThemeShare() {
|
||||
if (!$("#customThemeShareWrapper").hasClass("hidden")) {
|
||||
try {
|
||||
config.customThemeColors = JSON.parse(
|
||||
$("#customThemeShareWrapper input").val()
|
||||
ConfigSet.customThemeColors(
|
||||
JSON.parse($("#customThemeShareWrapper input").val())
|
||||
);
|
||||
} catch (e) {
|
||||
Notifications.add(
|
||||
|
@ -528,7 +528,7 @@ function hideCustomThemeShare() {
|
|||
0,
|
||||
4
|
||||
);
|
||||
config.customThemeColors = defaultConfig.customThemeColors;
|
||||
ConfigSet.customThemeColors(Config.defaultConfig.customThemeColors);
|
||||
}
|
||||
setCustomThemeInputs();
|
||||
// applyCustomThemeColors();
|
||||
|
@ -588,16 +588,18 @@ $("#shareCustomThemeButton").click((e) => {
|
|||
});
|
||||
|
||||
function toggleFavouriteTheme(themename) {
|
||||
if (config.favThemes.includes(themename)) {
|
||||
if (Config.favThemes.includes(themename)) {
|
||||
//already favourite, remove
|
||||
config.favThemes = config.favThemes.filter((t) => {
|
||||
if (t !== themename) {
|
||||
return t;
|
||||
}
|
||||
});
|
||||
ConfigSet.favThemes(
|
||||
Config.favThemes.filter((t) => {
|
||||
if (t !== themename) {
|
||||
return t;
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
//add to favourites
|
||||
config.favThemes.push(themename);
|
||||
Config.favThemes.push(themename);
|
||||
}
|
||||
saveConfigToCookie();
|
||||
refreshThemeButtons();
|
||||
|
@ -662,7 +664,7 @@ function refreshTagsSettingsSection() {
|
|||
|
||||
function setActiveFunboxButton() {
|
||||
$(`.pageSettings .section.funbox .button`).removeClass("active");
|
||||
$(`.pageSettings .section.funbox .button[funbox='${activeFunBox}']`).addClass(
|
||||
$(`.pageSettings .section.funbox .button[funbox='${activeFunbox}']`).addClass(
|
||||
"active"
|
||||
);
|
||||
}
|
||||
|
@ -670,7 +672,7 @@ function setActiveFunboxButton() {
|
|||
async function setActiveLanguageGroup(groupName, clicked = false) {
|
||||
let currentGroup;
|
||||
if (groupName === undefined) {
|
||||
currentGroup = await Misc.findCurrentGroup(config.language);
|
||||
currentGroup = await Misc.findCurrentGroup(Config.language);
|
||||
} else {
|
||||
let groups = await Misc.getLanguageGroups();
|
||||
groups.forEach((g) => {
|
||||
|
@ -701,20 +703,20 @@ async function setActiveLanguageGroup(groupName, clicked = false) {
|
|||
setLanguage(currentGroup.languages[0]);
|
||||
} else {
|
||||
$(
|
||||
`.pageSettings .section.language .buttons .button[language=${config.language}]`
|
||||
`.pageSettings .section.language .buttons .button[language=${Config.language}]`
|
||||
).addClass("active");
|
||||
}
|
||||
}
|
||||
|
||||
function setActiveThemeButton() {
|
||||
$(`.pageSettings .section.themes .theme`).removeClass("active");
|
||||
$(`.pageSettings .section.themes .theme[theme=${config.theme}]`).addClass(
|
||||
$(`.pageSettings .section.themes .theme[theme=${Config.theme}]`).addClass(
|
||||
"active"
|
||||
);
|
||||
}
|
||||
|
||||
function setActiveThemeTab() {
|
||||
config.customTheme === true
|
||||
Config.customTheme === true
|
||||
? $(".pageSettings .section.themes .tabs .button[tab='custom']").click()
|
||||
: $(".pageSettings .section.themes .tabs .button[tab='preset']").click();
|
||||
}
|
||||
|
@ -724,7 +726,7 @@ function setCustomThemeInputs() {
|
|||
".pageSettings .section.themes .tabContainer .customTheme input[type=color]"
|
||||
).each((n, index) => {
|
||||
let currentColor =
|
||||
config.customThemeColors[colorVars.indexOf($(index).attr("id"))];
|
||||
Config.customThemeColors[colorVars.indexOf($(index).attr("id"))];
|
||||
$(index).val(currentColor);
|
||||
$(index).attr("value", currentColor);
|
||||
$(index).prev().text(currentColor);
|
||||
|
@ -755,13 +757,7 @@ function toggleTag(tagid, nosave = false) {
|
|||
}
|
||||
}
|
||||
});
|
||||
updateTestModesNotice(
|
||||
sameWordset,
|
||||
textHasTab,
|
||||
paceCaret,
|
||||
activeFunBox,
|
||||
config
|
||||
);
|
||||
updateTestModesNotice(sameWordset, textHasTab, paceCaret, activeFunbox);
|
||||
if (!nosave) saveActiveTagsToCookie();
|
||||
}
|
||||
|
||||
|
@ -961,7 +957,7 @@ $(".pageSettings .section.themes .tabs .button").click((e) => {
|
|||
setCustomThemeInputs();
|
||||
if ($target.attr("tab") == "preset") {
|
||||
setCustomTheme(false);
|
||||
ThemeController.set(config.theme);
|
||||
ThemeController.set(Config.theme);
|
||||
// applyCustomThemeColors();
|
||||
swapElements(
|
||||
$('.pageSettings .section.themes .tabContainer [tabContent="custom"]'),
|
||||
|
@ -1006,8 +1002,8 @@ $(".pageSettings .saveCustomThemeButton").click((e) => {
|
|||
});
|
||||
|
||||
$(".pageSettings #loadCustomColorsFromPreset").click((e) => {
|
||||
// previewTheme(config.theme);
|
||||
ThemeController.preview(config.theme);
|
||||
// previewTheme(Config.theme);
|
||||
ThemeController.preview(Config.theme);
|
||||
|
||||
colorVars.forEach((e) => {
|
||||
document.documentElement.style.setProperty(e, "");
|
||||
|
@ -1054,7 +1050,7 @@ $("#resetSettingsButton").click((e) => {
|
|||
});
|
||||
|
||||
$("#exportSettingsButton").click((e) => {
|
||||
let configJSON = JSON.stringify(config);
|
||||
let configJSON = JSON.stringify(Config);
|
||||
navigator.clipboard.writeText(configJSON).then(
|
||||
function () {
|
||||
Notifications.add("JSON Copied to clipboard", 0);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import Config from "./config";
|
||||
|
||||
let errorSound = new Audio("../sound/error.wav");
|
||||
let clickSounds = null;
|
||||
|
||||
|
@ -120,20 +122,22 @@ export function init() {
|
|||
};
|
||||
}
|
||||
|
||||
export function playClick(config) {
|
||||
if (config === "off") return;
|
||||
export function playClick() {
|
||||
if (Config.playSoundOnClick === "off") return;
|
||||
if (clickSounds === null) init();
|
||||
|
||||
let rand = Math.floor(Math.random() * clickSounds[config].length);
|
||||
let randomSound = clickSounds[config][rand];
|
||||
let rand = Math.floor(
|
||||
Math.random() * clickSounds[Config.playSoundOnClick].length
|
||||
);
|
||||
let randomSound = clickSounds[Config.playSoundOnClick][rand];
|
||||
randomSound.counter++;
|
||||
if (randomSound.counter === 2) randomSound.counter = 0;
|
||||
randomSound.sounds[randomSound.counter].currentTime = 0;
|
||||
randomSound.sounds[randomSound.counter].play();
|
||||
}
|
||||
|
||||
export function playError(config) {
|
||||
if (!config) return;
|
||||
export function playError() {
|
||||
if (!Config.playSoundOnError) return;
|
||||
errorSound.currentTime = 0;
|
||||
errorSound.play();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as Misc from "./misc";
|
||||
import Config from "./config";
|
||||
|
||||
export let caretAnimating = true;
|
||||
|
||||
|
@ -11,9 +12,9 @@ export function stopAnimation() {
|
|||
}
|
||||
|
||||
//TODO remove config when module
|
||||
export function startAnimation(config) {
|
||||
export function startAnimation() {
|
||||
if (caretAnimating === false) {
|
||||
if (config.smoothCaret) {
|
||||
if (Config.smoothCaret) {
|
||||
$("#caret").css("animation-name", "caretFlashSmooth");
|
||||
} else {
|
||||
$("#caret").css("animation-name", "caretFlashHard");
|
||||
|
@ -26,17 +27,17 @@ export function hide() {
|
|||
$("#caret").addClass("hidden");
|
||||
}
|
||||
|
||||
export function show(config) {
|
||||
export function show() {
|
||||
if ($("#result").hasClass("hidden")) {
|
||||
updatePosition("", config);
|
||||
updatePosition("");
|
||||
$("#caret").removeClass("hidden");
|
||||
startAnimation(config);
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO remove this after test logic is a module
|
||||
//TODO remove config when module
|
||||
export function updatePosition(currentInput, config) {
|
||||
export function updatePosition(currentInput) {
|
||||
if ($("#wordsWrapper").hasClass("hidden")) return;
|
||||
if ($("#caret").hasClass("off")) {
|
||||
return;
|
||||
|
@ -64,7 +65,7 @@ export function updatePosition(currentInput, config) {
|
|||
currentLetter = currentWordNodeList[currentWordNodeList.length - 1];
|
||||
}
|
||||
|
||||
if (config.mode != "zen" && $(currentLetter).length == 0) return;
|
||||
if (Config.mode != "zen" && $(currentLetter).length == 0) return;
|
||||
const isLanguageLeftToRight = Misc.getCurrentLanguage().leftToRight;
|
||||
let currentLetterPosLeft = isLanguageLeftToRight
|
||||
? currentLetter.offsetLeft
|
||||
|
@ -88,7 +89,7 @@ export function updatePosition(currentInput, config) {
|
|||
let smoothlinescroll = $("#words .smoothScroller").height();
|
||||
if (smoothlinescroll === undefined) smoothlinescroll = 0;
|
||||
|
||||
if (config.smoothCaret) {
|
||||
if (Config.smoothCaret) {
|
||||
caret.stop(true, false).animate(
|
||||
{
|
||||
top: newTop - smoothlinescroll,
|
||||
|
@ -106,7 +107,7 @@ export function updatePosition(currentInput, config) {
|
|||
);
|
||||
}
|
||||
|
||||
if (config.showAllLines) {
|
||||
if (Config.showAllLines) {
|
||||
let browserHeight = window.innerHeight;
|
||||
let middlePos = browserHeight / 2 - $("#caret").outerHeight() / 2;
|
||||
let contentHeight = document.body.scrollHeight;
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as ThemeColors from "./theme-colors";
|
|||
import * as ChartController from "./chart-controller";
|
||||
import * as Misc from "./misc";
|
||||
import * as Notifications from "./notification-center";
|
||||
import Config from "./config";
|
||||
|
||||
let isPreviewingTheme = false;
|
||||
let randomTheme = null;
|
||||
|
@ -85,15 +86,15 @@ export function setCustomColors(colors) {
|
|||
}
|
||||
|
||||
//TODO remove config once config is a module
|
||||
export function randomiseTheme(config) {
|
||||
export function randomiseTheme() {
|
||||
var randomList;
|
||||
Misc.getThemesList().then((themes) => {
|
||||
randomList = themes.map((t) => {
|
||||
return t.name;
|
||||
});
|
||||
|
||||
if (config.randomTheme === "fav" && config.favThemes.length > 0)
|
||||
randomList = config.favThemes;
|
||||
if (Config.randomTheme === "fav" && Config.favThemes.length > 0)
|
||||
randomList = Config.favThemes;
|
||||
randomTheme = randomList[Math.floor(Math.random() * randomList.length)];
|
||||
preview(randomTheme);
|
||||
Notifications.add(randomTheme.replace(/_/g, " "), 0);
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue