Added layoutfluid challenge to the funbox

This commit is contained in:
Octahedron 2020-08-03 08:28:47 -04:00
parent 2239dbd04a
commit ffd32603e9
4 changed files with 46 additions and 7 deletions

View file

@ -1,5 +0,0 @@
{
"projects": {
"default": "project-id"
}
}

View file

@ -2369,4 +2369,4 @@ key {
.r5 {
display: grid;
grid-template-columns: 4fr 7.5fr 4fr;
}
}

View file

@ -25,5 +25,9 @@
{
"name": "rAnDoMcAsE",
"type": "script"
},
{
"name": "layoutfluid",
"type": "script"
}
]
]

View file

@ -239,6 +239,15 @@ function activateFunbox(funbox, mode) {
config.keymapMode = "off";
setActiveKeymapModeButton();
restartTest();
} else if (funbox === "layoutfluid") {
config.keymapMode = "on";
changeKeymapMode("next");
setActiveKeymapModeButton();
changeLayout("qwerty");
setActiveLayoutButton();
changeKeymapLayout("qwerty");
setActiveKeymapLayoutButton();
restartTest();
}
activeFunBox = funbox;
}
@ -954,6 +963,16 @@ function updateTimer() {
}
$("#timerNumber").html(displayTime);
// $("#timerNumber").html(config.time - time);
if (activeFunBox === "layoutfluid") {
const layouts = ["qwerty", "dvorak", "colemak"];
let index = Math.floor(time / (config.time / 3));
changeLayout(layouts[index]);
changeKeymapLayout(layouts[index]);
updateHighlightedKeymapKey();
setActiveLayoutButton();
}
}
} else if (
config.mode === "words" ||
@ -993,8 +1012,19 @@ function updateTimer() {
outof = customText.length;
}
}
$("#timerNumber").html(`${inputHistory.length}/${outof}`);
// $("#timerNumber").html(config.time - time);
if (activeFunBox === "layoutfluid") {
const layouts = ["qwerty", "dvorak", "colemak"];
let index = Math.floor(inputHistory.length / (outof / 3));
changeLayout(layouts[index]);
changeKeymapLayout(layouts[index]);
updateHighlightedKeymapKey();
setActiveLayoutButton();
}
}
}
}
@ -2154,6 +2184,15 @@ function restartTest(withSameWordset = false) {
if (config.keymapMode !== "off") {
showKeymap();
}
if(activeFunBox === "layoutfluid") {
changeLayout("qwerty");
setActiveLayoutButton();
changeKeymapLayout("qwerty");
setActiveKeymapLayoutButton();
updateHighlightedKeymapKey();
}
$("#result").addClass("hidden");
$("#testModesNotice").removeClass("hidden").css({
opacity: 1,
@ -3448,6 +3487,7 @@ $(document).keydown((event) => {
}
}
currentWordElementIndex -= toHide.length;
if (config.smoothLineScroll) {
let word = $(document.querySelector(".word"));
$("#words").prepend(