mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-11 01:44:50 +08:00
updated layoutfluid notification element
made it work in mods other than time closes #4484
This commit is contained in:
parent
168055e21e
commit
1d8aee1c68
3 changed files with 36 additions and 13 deletions
|
|
@ -19,6 +19,7 @@ import {
|
|||
checkFunboxForcedConfigs,
|
||||
} from "./funbox-validation";
|
||||
import { Wordset } from "../wordset";
|
||||
import * as LayoutfluidFunboxTimer from "./layoutfluid-funbox-timer";
|
||||
|
||||
const prefixSize = 2;
|
||||
|
||||
|
|
@ -291,17 +292,31 @@ FunboxList.setFunboxFunctions("layoutfluid", {
|
|||
const layouts: string[] = Config.customLayoutfluid
|
||||
? Config.customLayoutfluid.split("#")
|
||||
: ["qwerty", "dvorak", "colemak"];
|
||||
let index = 0;
|
||||
const outOf: number = TestWords.words.length;
|
||||
index = Math.floor(
|
||||
(TestInput.input.history.length + 1) / (outOf / layouts.length)
|
||||
const wordsPerLayout = Math.floor(outOf / layouts.length);
|
||||
const index = Math.floor(
|
||||
(TestInput.input.history.length + 1) / wordsPerLayout
|
||||
);
|
||||
if (Config.layout !== layouts[index] && layouts[index] !== undefined) {
|
||||
Notifications.add(`--- !!! ${layouts[index]} !!! ---`, 0);
|
||||
}
|
||||
if (layouts[index]) {
|
||||
UpdateConfig.setLayout(layouts[index]);
|
||||
UpdateConfig.setKeymapLayout(layouts[index]);
|
||||
const mod =
|
||||
wordsPerLayout - ((TestWords.words.currentIndex + 1) % wordsPerLayout);
|
||||
|
||||
console.log(wordsPerLayout);
|
||||
console.log(mod);
|
||||
|
||||
if (layouts[index + 1]) {
|
||||
if (mod <= 3) {
|
||||
LayoutfluidFunboxTimer.show();
|
||||
LayoutfluidFunboxTimer.updateWords(mod, layouts[index + 1]);
|
||||
}
|
||||
if (mod === wordsPerLayout) {
|
||||
UpdateConfig.setLayout(layouts[index]);
|
||||
UpdateConfig.setKeymapLayout(layouts[index]);
|
||||
if (mod > 3) {
|
||||
LayoutfluidFunboxTimer.hide();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LayoutfluidFunboxTimer.hide();
|
||||
}
|
||||
setTimeout(() => {
|
||||
KeymapEvent.highlight(
|
||||
|
|
|
|||
|
|
@ -18,8 +18,16 @@ export function hide(): void {
|
|||
);
|
||||
}
|
||||
|
||||
export function update(sec: number, layout: string): void {
|
||||
export function updateTime(sec: number, layout: string): void {
|
||||
$("#typingTest #layoutfluidTimer").text(
|
||||
`${capitalizeFirstLetter(layout)} in: ${sec}s`
|
||||
);
|
||||
}
|
||||
|
||||
export function updateWords(words: number, layout: string): void {
|
||||
let str = `${capitalizeFirstLetter(layout)} in: ${words} words`;
|
||||
if (words === 1) {
|
||||
str = `${capitalizeFirstLetter(layout)} starting next word`;
|
||||
}
|
||||
$("#typingTest #layoutfluidTimer").text(str);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,11 +103,11 @@ function layoutfluid(): void {
|
|||
|
||||
if (flooredSwitchTimes.includes(time + 3)) {
|
||||
LayoutfluidFunboxTimer.show();
|
||||
LayoutfluidFunboxTimer.update(3, layouts[index + 1]);
|
||||
LayoutfluidFunboxTimer.updateTime(3, layouts[index + 1]);
|
||||
} else if (flooredSwitchTimes.includes(time + 2)) {
|
||||
LayoutfluidFunboxTimer.update(2, layouts[index + 1]);
|
||||
LayoutfluidFunboxTimer.updateTime(2, layouts[index + 1]);
|
||||
} else if (flooredSwitchTimes.includes(time + 1)) {
|
||||
LayoutfluidFunboxTimer.update(1, layouts[index + 1]);
|
||||
LayoutfluidFunboxTimer.updateTime(1, layouts[index + 1]);
|
||||
}
|
||||
|
||||
if (Config.layout !== layout && layout !== undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue