From ffd32603e9f86c306cdeaf7b4077d967a836139d Mon Sep 17 00:00:00 2001 From: Octahedron Date: Mon, 3 Aug 2020 08:28:47 -0400 Subject: [PATCH 1/3] Added layoutfluid challenge to the funbox --- .firebaserc_example | 5 ----- public/css/style.scss | 2 +- public/funbox/list.json | 6 +++++- public/js/script.js | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 7 deletions(-) delete mode 100644 .firebaserc_example diff --git a/.firebaserc_example b/.firebaserc_example deleted file mode 100644 index b254e4c1f..000000000 --- a/.firebaserc_example +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "default": "project-id" - } -} diff --git a/public/css/style.scss b/public/css/style.scss index 21b2428a4..ccb6f15e9 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -2369,4 +2369,4 @@ key { .r5 { display: grid; grid-template-columns: 4fr 7.5fr 4fr; -} \ No newline at end of file +} diff --git a/public/funbox/list.json b/public/funbox/list.json index 3e99d5758..ab749e3af 100644 --- a/public/funbox/list.json +++ b/public/funbox/list.json @@ -25,5 +25,9 @@ { "name": "rAnDoMcAsE", "type": "script" + }, + { + "name": "layoutfluid", + "type": "script" } -] \ No newline at end of file +] diff --git a/public/js/script.js b/public/js/script.js index 0ce67461a..c003489fe 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -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( From 828b0482de5d5ca0b5eb963b655b239a52639510 Mon Sep 17 00:00:00 2001 From: Octahedron <40345761+OctahedronV2@users.noreply.github.com> Date: Mon, 3 Aug 2020 08:37:21 -0400 Subject: [PATCH 2/3] Update script.js --- public/js/script.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index c003489fe..2ac64553e 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1012,7 +1012,6 @@ function updateTimer() { outof = customText.length; } } - $("#timerNumber").html(`${inputHistory.length}/${outof}`); // $("#timerNumber").html(config.time - time); @@ -3487,7 +3486,6 @@ $(document).keydown((event) => { } } currentWordElementIndex -= toHide.length; - if (config.smoothLineScroll) { let word = $(document.querySelector(".word")); $("#words").prepend( From f82b7d3ee122462a50ebe6e9304a66207de68ea3 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 3 Aug 2020 19:11:23 +0100 Subject: [PATCH 3/3] fixed layoutfluid not working when timer is not visible added a notification on layout change --- public/js/script.js | 55 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index 2ac64553e..c64e0825b 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -240,14 +240,14 @@ function activateFunbox(funbox, mode) { setActiveKeymapModeButton(); restartTest(); } else if (funbox === "layoutfluid") { - config.keymapMode = "on"; - changeKeymapMode("next"); - setActiveKeymapModeButton(); - changeLayout("qwerty"); - setActiveLayoutButton(); - changeKeymapLayout("qwerty"); - setActiveKeymapLayoutButton(); - restartTest(); + config.keymapMode = "on"; + changeKeymapMode("next"); + setActiveKeymapModeButton(); + changeLayout("qwerty"); + setActiveLayoutButton(); + changeKeymapLayout("qwerty"); + setActiveKeymapLayoutButton(); + restartTest(); } activeFunBox = funbox; } @@ -963,16 +963,6 @@ 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" || @@ -1014,16 +1004,6 @@ function updateTimer() { } $("#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(); - } - } } } @@ -2048,6 +2028,23 @@ function startTest() { wpmHistory.push(wpmAndRaw.wpm); rawHistory.push(wpmAndRaw.raw); + if (activeFunBox === "layoutfluid") { + const layouts = ["qwerty", "dvorak", "colemak"]; + let index = 0; + if (config.mode === "time") { + index = Math.floor(time / (config.time / 3)); + } else if (config.mode === "words") { + index = Math.floor(inputHistory.length / (outof / 3)); + } + if (config.layout !== layouts[index]) { + showNotification(`--- !!! ${layouts[index]} !!! ---`, 3000); + } + changeLayout(layouts[index]); + changeKeymapLayout(layouts[index]); + updateHighlightedKeymapKey(); + setActiveLayoutButton(); + } + // console.timeEnd("livewpm"); keypressPerSecond.push(currentKeypressCount); currentKeypressCount = 0; @@ -2184,7 +2181,7 @@ function restartTest(withSameWordset = false) { showKeymap(); } - if(activeFunBox === "layoutfluid") { + if (activeFunBox === "layoutfluid") { changeLayout("qwerty"); setActiveLayoutButton(); changeKeymapLayout("qwerty");