MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / layoutfluid

Function layoutfluid

frontend/src/ts/test/test-timer.ts:156–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154}
155
156function layoutfluid(): void {
157 if (timerDebug) console.time("layoutfluid");
158 if (Config.funbox.includes("layoutfluid") && Config.mode === "time") {
159 const layouts = Config.customLayoutfluid;
160 const switchTime = Config.time / layouts.length;
161 const time = Time.get();
162 const index = Math.floor(time / switchTime);
163 const layout = layouts[index];
164 const flooredSwitchTimes = [];
165
166 for (let i = 1; i < layouts.length; i++) {
167 flooredSwitchTimes.push(Math.floor(switchTime * i));
168 }
169
170 if (flooredSwitchTimes.includes(time + 3)) {
171 LayoutfluidFunboxTimer.show();
172 LayoutfluidFunboxTimer.updateTime(3, layouts[index + 1] as string);
173 } else if (flooredSwitchTimes.includes(time + 2)) {
174 LayoutfluidFunboxTimer.updateTime(2, layouts[index + 1] as string);
175 } else if (flooredSwitchTimes.includes(time + 1)) {
176 LayoutfluidFunboxTimer.updateTime(1, layouts[index + 1] as string);
177 }
178
179 if (Config.layout !== layout && layout !== undefined) {
180 LayoutfluidFunboxTimer.hide();
181 setConfig("layout", layout as Layout, {
182 nosave: true,
183 });
184 setConfig("keymapLayout", layout as KeymapLayout, {
185 nosave: true,
186 });
187
188 if (Config.keymapMode === "next") {
189 setTimeout(() => {
190 highlight(
191 TestWords.words.getCurrentText().charAt(getCurrentInput().length),
192 );
193 }, 1);
194 }
195 }
196 }
197 if (timerDebug) console.timeEnd("layoutfluid");
198}
199
200function checkIfFailed(
201 wpmAndRaw: { wpm: number; raw: number },

Callers 1

timerStepFunction · 0.85

Calls 8

setConfigFunction · 0.90
highlightFunction · 0.90
getCurrentInputFunction · 0.90
pushMethod · 0.80
getCurrentTextMethod · 0.80
getMethod · 0.45
showMethod · 0.45
hideMethod · 0.45

Tested by

no test coverage detected