mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-27 10:31:22 +08:00
parent
86bbc96836
commit
cf5198998f
5 changed files with 34 additions and 19 deletions
|
|
@ -18,7 +18,6 @@ import * as Settings from "../pages/settings";
|
|||
import * as LayoutEmulator from "../test/layout-emulator";
|
||||
import * as PaceCaret from "../test/pace-caret";
|
||||
import * as TimerProgress from "../test/timer-progress";
|
||||
import * as TestTimer from "../test/test-timer";
|
||||
import * as Focus from "../test/focus";
|
||||
import * as ShiftTracker from "../test/shift-tracker";
|
||||
import * as Replay from "../test/replay.js";
|
||||
|
|
@ -267,7 +266,7 @@ function handleSpace() {
|
|||
Config.mode === "quote" ||
|
||||
Config.mode === "zen"
|
||||
) {
|
||||
TimerProgress.update(TestTimer.time);
|
||||
TimerProgress.update();
|
||||
}
|
||||
if (
|
||||
Config.mode == "time" ||
|
||||
|
|
|
|||
13
frontend/src/js/states/time.js
Normal file
13
frontend/src/js/states/time.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let time = 0;
|
||||
|
||||
export function get() {
|
||||
return time;
|
||||
}
|
||||
|
||||
export function set(active) {
|
||||
time = active;
|
||||
}
|
||||
|
||||
export function increment() {
|
||||
time++;
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ export function startTest() {
|
|||
LiveWpm.show();
|
||||
LiveAcc.show();
|
||||
LiveBurst.show();
|
||||
TimerProgress.update(TestTimer.time);
|
||||
TimerProgress.update();
|
||||
TestTimer.clear();
|
||||
|
||||
if (Config.funbox === "memory") {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import * as TestLogic from "./test-logic";
|
|||
import * as Caret from "./caret";
|
||||
import * as SlowTimer from "../states/slow-timer";
|
||||
import * as TestActive from "./../states/test-active";
|
||||
import * as Time from "./../states/time";
|
||||
|
||||
let slowTimerCount = 0;
|
||||
export let time = 0;
|
||||
let timer = null;
|
||||
const interval = 1000;
|
||||
let expected = 0;
|
||||
|
|
@ -29,13 +29,14 @@ export function enableTimerDebug() {
|
|||
}
|
||||
|
||||
export function clear() {
|
||||
time = 0;
|
||||
Time.set(0);
|
||||
clearTimeout(timer);
|
||||
}
|
||||
|
||||
function premid() {
|
||||
if (timerDebug) console.time("premid");
|
||||
document.querySelector("#premidSecondsLeft").innerHTML = Config.time - time;
|
||||
document.querySelector("#premidSecondsLeft").innerHTML =
|
||||
Config.time - Time.get();
|
||||
if (timerDebug) console.timeEnd("premid");
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ function updateTimer() {
|
|||
Config.mode === "time" ||
|
||||
(Config.mode === "custom" && CustomText.isTimeRandom)
|
||||
) {
|
||||
TimerProgress.update(time);
|
||||
TimerProgress.update();
|
||||
}
|
||||
if (timerDebug) console.timeEnd("timer progress update");
|
||||
}
|
||||
|
|
@ -87,23 +88,23 @@ function layoutfluid() {
|
|||
// console.log(layouts);
|
||||
const numLayouts = layouts.length;
|
||||
let index = 0;
|
||||
index = Math.floor(time / (Config.time / numLayouts));
|
||||
index = Math.floor(Time.get() / (Config.time / numLayouts));
|
||||
|
||||
if (
|
||||
time == Math.floor(Config.time / numLayouts) - 3 ||
|
||||
time == (Config.time / numLayouts) * 2 - 3
|
||||
Time.get() == Math.floor(Config.time / numLayouts) - 3 ||
|
||||
Time.get() == (Config.time / numLayouts) * 2 - 3
|
||||
) {
|
||||
Notifications.add("3", 0, 1);
|
||||
}
|
||||
if (
|
||||
time == Math.floor(Config.time / numLayouts) - 2 ||
|
||||
time == Math.floor(Config.time / numLayouts) * 2 - 2
|
||||
Time.get() == Math.floor(Config.time / numLayouts) - 2 ||
|
||||
Time.get() == Math.floor(Config.time / numLayouts) * 2 - 2
|
||||
) {
|
||||
Notifications.add("2", 0, 1);
|
||||
}
|
||||
if (
|
||||
time == Math.floor(Config.time / numLayouts) - 1 ||
|
||||
time == Math.floor(Config.time / numLayouts) * 2 - 1
|
||||
Time.get() == Math.floor(Config.time / numLayouts) - 1 ||
|
||||
Time.get() == Math.floor(Config.time / numLayouts) * 2 - 1
|
||||
) {
|
||||
Notifications.add("1", 0, 1);
|
||||
}
|
||||
|
|
@ -152,8 +153,10 @@ function checkIfTimeIsUp() {
|
|||
(Config.mode === "custom" && CustomText.isTimeRandom)
|
||||
) {
|
||||
if (
|
||||
(time >= Config.time && Config.time !== 0 && Config.mode === "time") ||
|
||||
(time >= CustomText.time &&
|
||||
(Time.get() >= Config.time &&
|
||||
Config.time !== 0 &&
|
||||
Config.mode === "time") ||
|
||||
(Time.get() >= CustomText.time &&
|
||||
CustomText.time !== 0 &&
|
||||
Config.mode === "custom")
|
||||
) {
|
||||
|
|
@ -181,7 +184,7 @@ export function getTimerStats() {
|
|||
|
||||
async function timerStep() {
|
||||
if (timerDebug) console.time("timer step -----------------------------");
|
||||
time++;
|
||||
Time.increment();
|
||||
premid();
|
||||
updateTimer();
|
||||
let wpmAndRaw = calculateWpmRaw();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as CustomText from "./custom-text";
|
|||
import * as Misc from "../misc";
|
||||
import * as TestWords from "./test-words";
|
||||
import * as TestInput from "./test-input";
|
||||
import * as TestTimer from "./test-timer";
|
||||
import * as Time from "./../states/time";
|
||||
import * as SlowTimer from "../states/slow-timer";
|
||||
import * as TestActive from "./../states/test-active";
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ let miniTimerNumberElement = document.querySelector(
|
|||
);
|
||||
|
||||
export function update() {
|
||||
let time = TestTimer.time;
|
||||
let time = Time.get();
|
||||
if (
|
||||
Config.mode === "time" ||
|
||||
(Config.mode === "custom" && CustomText.isTimeRandom)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue