mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-09 12:56:07 +08:00
changed the way config is stored a bit
made sure all missing configs are reset to default added discord dot functions
This commit is contained in:
parent
56629d26cc
commit
4e40e02ee2
1 changed files with 40 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
let config = {
|
||||
let defaultConfig = {
|
||||
theme: 'serika_dark',
|
||||
showKeyTips: true,
|
||||
showLiveWpm: false,
|
||||
|
|
@ -18,9 +18,12 @@ let config = {
|
|||
quickEnd: false,
|
||||
caretStyle: "default",
|
||||
flipTestColors: false,
|
||||
layout:"default"
|
||||
layout:"default",
|
||||
showDiscordDot: true
|
||||
}
|
||||
|
||||
let config = defaultConfig;
|
||||
|
||||
//cookies
|
||||
function saveConfigToCookie() {
|
||||
let d = new Date();
|
||||
|
|
@ -53,23 +56,18 @@ function loadConfigFromCookie() {
|
|||
setBlindMode(newConfig.blindMode,true);
|
||||
setQuickEnd(newConfig.quickEnd,true);
|
||||
setFlipTestColors(newConfig.flipTestColors,true);
|
||||
setDiscordDot(newConfig.hideDiscordDot,true);
|
||||
if(newConfig.resultFilters == null || newConfig.resultFilters == undefined){
|
||||
newConfig.resultFilters = ["all"];
|
||||
}
|
||||
config = newConfig;
|
||||
}
|
||||
if(config.difficulty == undefined){
|
||||
config.difficulty = "normal";
|
||||
saveConfigToCookie();
|
||||
}
|
||||
if(config.blindMode == undefined){
|
||||
config.blindMode = false;
|
||||
saveConfigToCookie();
|
||||
}
|
||||
if(config.layout == undefined){
|
||||
config.layout = "default";
|
||||
saveConfigToCookie();
|
||||
}
|
||||
Object.keys(defaultConfig).forEach(configKey => {
|
||||
if(config[configKey] == undefined){
|
||||
config[configKey] = defaultConfig[configKey];
|
||||
}
|
||||
})
|
||||
saveConfigToCookie();
|
||||
}
|
||||
|
||||
function showTestConfig() {
|
||||
|
|
@ -90,6 +88,34 @@ 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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue