mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-26 08:47:36 +08:00
parent
9ec4c72a34
commit
dcb04f19e7
2 changed files with 7 additions and 27 deletions
|
|
@ -3,7 +3,6 @@ import * as Sound from "./controllers/sound-controller";
|
|||
import * as OutOfFocus from "./test/out-of-focus";
|
||||
import * as Notifications from "./elements/notifications";
|
||||
import * as LanguagePicker from "./settings/language-picker";
|
||||
import * as TestLogic from "./test/test-logic";
|
||||
import * as PaceCaret from "./test/pace-caret";
|
||||
import * as UI from "./ui";
|
||||
import * as CommandlineLists from "./elements/commandline-lists";
|
||||
|
|
@ -25,8 +24,8 @@ export function subscribeToEvent(fn) {
|
|||
eventSubscribers.push(fn);
|
||||
}
|
||||
|
||||
function dispatchEvent(key, value) {
|
||||
eventSubscribers.forEach((fn) => fn(key, value));
|
||||
function dispatchEvent(key, value, value2) {
|
||||
eventSubscribers.forEach((fn) => fn(key, value, value2));
|
||||
}
|
||||
|
||||
export function setLocalStorageConfig(val) {
|
||||
|
|
@ -265,9 +264,8 @@ export function setDifficulty(diff, nosave) {
|
|||
diff = "normal";
|
||||
}
|
||||
config.difficulty = diff;
|
||||
if (!nosave) TestLogic.restart(false, nosave);
|
||||
if (!nosave) saveToLocalStorage();
|
||||
dispatchEvent("difficulty", config.difficulty);
|
||||
dispatchEvent("difficulty", config.difficulty, nosave);
|
||||
}
|
||||
|
||||
//set fav themes
|
||||
|
|
@ -505,7 +503,6 @@ export function setShowAllLines(sal, nosave) {
|
|||
ChallengeContoller.clearActive();
|
||||
if (!nosave) {
|
||||
saveToLocalStorage();
|
||||
TestLogic.restart();
|
||||
}
|
||||
dispatchEvent("showAllLines", config.showAllLines);
|
||||
}
|
||||
|
|
@ -1096,7 +1093,6 @@ export function setKeymapMode(mode, nosave) {
|
|||
$(".keymap-key").attr("style", "");
|
||||
config.keymapMode = mode;
|
||||
ChallengeContoller.clearActive();
|
||||
if (!nosave) TestLogic.restart(false, nosave);
|
||||
if (!nosave) saveToLocalStorage();
|
||||
dispatchEvent("keymapMode", config.keymapMode);
|
||||
}
|
||||
|
|
@ -1566,21 +1562,4 @@ export let loadPromise = new Promise((v) => {
|
|||
loadDone = v;
|
||||
});
|
||||
|
||||
export function getMode2(mode) {
|
||||
if (!mode) mode = config.mode;
|
||||
let mode2 = "";
|
||||
if (mode === "time") {
|
||||
mode2 = config.time;
|
||||
} else if (mode === "words") {
|
||||
mode2 = config.words;
|
||||
} else if (mode === "custom") {
|
||||
mode2 = "custom";
|
||||
} else if (mode === "zen") {
|
||||
mode2 = "zen";
|
||||
} else if (mode === "quote") {
|
||||
mode2 = TestLogic.randomQuote.id;
|
||||
}
|
||||
return mode2;
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import * as TestLogic from "./test-logic";
|
||||
import * as TestUI from "./test-ui";
|
||||
import Config, * as UpdateConfig from "../config";
|
||||
import Config from "../config";
|
||||
import * as DB from "../db";
|
||||
import * as SlowTimer from "../states/slow-timer";
|
||||
import * as Misc from "./../misc";
|
||||
|
||||
export let settings = null;
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ function resetCaretPosition() {
|
|||
|
||||
export async function init() {
|
||||
$("#paceCaret").addClass("hidden");
|
||||
let mode2 = UpdateConfig.getMode2();
|
||||
let mode2 = Misc.getMode2(Config, TestLogic.randomQuote);
|
||||
let wpm;
|
||||
if (Config.paceCaret === "pb") {
|
||||
wpm = await DB.getLocalPB(
|
||||
|
|
@ -45,7 +46,7 @@ export async function init() {
|
|||
Config.funbox
|
||||
);
|
||||
} else if (Config.paceCaret === "average") {
|
||||
let mode2 = UpdateConfig.getMode2();
|
||||
let mode2 = Misc.getMode2(Config, TestLogic.randomQuote);
|
||||
wpm = await DB.getUserAverageWpm10(
|
||||
Config.mode,
|
||||
mode2,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue