From 56c51add7d1bed0171f69bdddd932abcb30a4767 Mon Sep 17 00:00:00 2001 From: Arivappa <114223788+4rivappa@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:48:21 +0530 Subject: [PATCH 1/6] Add code lua quotes (#4143) 4rivappa * adding code_lua.json file for quotes section * adding lua quotes from lua manual --------- Co-authored-by: 4rivappa --- frontend/static/quotes/code_lua.json | 83 ++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 frontend/static/quotes/code_lua.json diff --git a/frontend/static/quotes/code_lua.json b/frontend/static/quotes/code_lua.json new file mode 100644 index 000000000..d4736a690 --- /dev/null +++ b/frontend/static/quotes/code_lua.json @@ -0,0 +1,83 @@ +{ + "language": "code_lua", + "groups": [ + [0, 100], + [101, 300], + [301, 600], + [601, 9999] + ], + "quotes": [ + { + "text": "local MultiSelect = {}\\nMultiSelect.__index = MultiSelect\\n\\nfunction MultiSelect:new()\\n\\treturn setmetatable({\\n\\t\\t_entries = {},\\n\\t}, MultiSelect)\\nend", + "source": "Github nvim-telescope/telescope.nvim - pickers", + "length": 156, + "id": 1 + }, + { + "text": "function histories.History:append(line, picker, no_reset)\\n\\tif not self.enabled then\\n\\t\\treturn\\n\\tend\\n\\tself._append(self, line, picker, no_reset)\\nend", + "source": "Github nvim-telescope/telescope.nvim - actions", + "length": 155, + "id": 2 + }, + { + "text": "local function require_on_exported_call(mod)\\n\\treturn setmetatable({}, {\\n\\t\\t__index = function(_, picker)\\n\\t\\t\\treturn function(...)\\n\\t\\t\\t\\treturn require(mod)[picker](...)\\n\\t\\t\\tend\\n\\t\\tend,\\n\\t})\\nend", + "source": "Github nvim-telescope/telescope.nvim - builtin", + "length": 210, + "id": 3 + }, + { + "text": "function M.get_length()\\n\\tlog.trace(\"_get_length()\")\\n\\treturn table.maxn(harpoon.get_term_config().cmds)\\nend", + "source": "Github ThePrimeagen/harpoon - tmux", + "length": 111, + "id": 4 + }, + { + "text": "for _, v in pairs(log_levels) do\\n\\toverride(v)\\nend", + "source": "Github ThePrimeagen/harpoon - dev", + "length": 52, + "id": 5 + }, + { + "text": "function M.clear_all()\\n\\tharpoon.get_mark_config().marks = {}\\n\\tlog.trace(\"clear_all(): Clearing all marks.\")\\n\\temit_changed()\\nend", + "source": "Github ThePrimeagen/harpoon - mark", + "length": 134, + "id": 6 + }, + { + "text": "s = \"hello world from Lua\"\\nfor w in string.gmatch(s, \"%a+\") do\\n\\tprint(w)\\nend", + "source": "Lua 5.4 manual - string.gmatch", + "length": 80, + "id": 7 + }, + { + "text": "local i = 1\\nwhile a[i] do\\n\\tprint(a[i])\\n\\ti = i + 1\\nend", + "source": "Lua pil - while", + "length": 59, + "id": 8 + }, + { + "text": "-- print the first non-empty line\\nrepeat\\n\\tline = io.read()\\nuntil line ~= \"\"\\nprint(line)", + "source": "Lua pil - repeat", + "length": 92, + "id": 9 + }, + { + "text": "function perm (a)\\n\\tlocal n = table.getn(a)\\n\\treturn coroutine.wrap(function () permgen(a, n) end)\\nend", + "source": "Lua pil - coroutines", + "length": 105, + "id": 10 + }, + { + "text": "function Set (list)\\n\\tlocal set = {}\\n\\tfor _, l in ipairs(list) do set[l] = true end\\n\\treturn set\\nend", + "source": "Lua pil - set", + "length": 105, + "id": 11 + }, + { + "text": "line = io.read()\\nn = tonumber(line)\\nif n == nil then\\n\\terror(line .. \" is not a valid number\")\\nelse\\n\\tprint(n*2)\\nend", + "source": "Lua pil - strings", + "length": 122, + "id": 12 + } + ] +} From 6c2014e3afcd407e54f3b37f4347234afe939fb6 Mon Sep 17 00:00:00 2001 From: PeasfulTown <126224325+PeasfulTown@users.noreply.github.com> Date: Fri, 7 Apr 2023 07:18:53 -0400 Subject: [PATCH 2/6] fix: added missing dot to quote (#4144) PeasfulTown --- frontend/static/quotes/english.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index 3caf434fe..c09feaf66 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -37553,9 +37553,9 @@ "id": 6623 }, { - "text": "A darkness approaches. A day will come in the future where everything you care about will change... Until then I'll be watching you! I'll be watching you..", + "text": "A darkness approaches. A day will come in the future where everything you care about will change... Until then I'll be watching you! I'll be watching you...", "source": "Bill Cipher, Gravity Falls", - "length": 155, + "length": 156, "approvedBy": "Smithster", "id": 6624 }, From 98156ac0811361c1ed3062b236a827170a06badb Mon Sep 17 00:00:00 2001 From: RusDoomer <126584145+RusDoomer@users.noreply.github.com> Date: Fri, 7 Apr 2023 07:19:25 -0400 Subject: [PATCH 3/6] added xenia layout (#4145) RusDoomer --- frontend/static/layouts/_list.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/static/layouts/_list.json b/frontend/static/layouts/_list.json index abe9590e0..00a7810ac 100644 --- a/frontend/static/layouts/_list.json +++ b/frontend/static/layouts/_list.json @@ -1342,6 +1342,17 @@ "row5": [" "] } }, + "xenia": { + "keymapShowTopRow": false, + "type": "ansi", + "keys": { + "row1": ["`~", "1!", "2@", "3#", "4$", "5%", "6^", "7&", "8*", "9(", "0)", "-_", "=+"], + "row2": [",<", "oO", "uU", "rR", "qQ", "jJ", "fF", "dD", "vV", "gG", "[{", "]}", "\\|"], + "row3": ["iI", "aA", "eE", "nN", "xX", "yY", "hH", "tT", "sS", "cC", "/?"], + "row4": [".>", "'\"", ";:", "lL", "zZ", "kK", "pP", "mM", "bB", "wW"], + "row5": [" "] + } + }, "burmese": { "keymapShowTopRow": true, "type": "ansi", From ac4158986c055777170e44d48b9296972773ab2b Mon Sep 17 00:00:00 2001 From: Henning Meyer <82178058+meyerhenning@users.noreply.github.com> Date: Fri, 7 Apr 2023 13:58:46 +0200 Subject: [PATCH 4/6] Add German Quotes (#4123) meyerhenning * feat: add german quotes * feat: add german quotes --- frontend/static/quotes/german.json | 86 ++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/frontend/static/quotes/german.json b/frontend/static/quotes/german.json index 8fc13b824..657a7072b 100644 --- a/frontend/static/quotes/german.json +++ b/frontend/static/quotes/german.json @@ -3326,10 +3326,88 @@ "id": 561 }, { - "text": "Es ist besser, ein einziges kleines Licht anzuzünden, als die Dunkelheit zu verfluchen.", - "source": "Konfuzius", - "length": 87, - "id": 562 + "text": "Es ist besser, ein einziges kleines Licht anzuzünden, als die Dunkelheit zu verfluchen.", + "source": "Konfuzius", + "length": 87, + "id": 562 + }, + { + "text": "Die Summe unseres Lebens sind die Stunden, in denen wir liebten.", + "source": "Wilhelm Busch", + "length": 64, + "id": 563 + }, + { + "text": "Das Trinkgeschirr, sobald es leer, macht keine rechte Freude mehr.", + "source": "Wilhelm Busch", + "length": 66, + "id": 564 + }, + { + "text": "Merkmal großer Menschen ist, dass sie an andere weit geringere Anforderungen stellen, als an sich selbst.", + "source": "Marie von Ebner-Eschenbach", + "length": 105, + "id": 565 + }, + { + "text": "Das Gleiche lässt uns in Ruhe, aber der Widerspruch ist es, der uns produktiv macht.", + "source": "Johann Wolfgang von Goethe", + "length": 84, + "id": 566 + }, + { + "text": "Lerne zuzuhören und du wirst auch von denjenigen Nutzen ziehen, die nur dummes Zeug reden.", + "source": "Platon", + "length": 90, + "id": 567 + }, + { + "text": "Nicht den Tod sollte man fürchten, sondern dass man nie beginnen wird zu leben.", + "source": "Mark Aurel", + "length": 79, + "id": 568 + }, + { + "text": "Der Schwache kann nicht verzeihen. Verzeihen ist eine Eigenschaft des Starken.", + "source": "Mahatma Gandhi", + "length": 78, + "id": 569 + }, + { + "text": "Nichts ist leichter, als so zu schreiben, dass kein Mensch es versteht; wie hingegen nichts schwerer, als bedeutende Gedanken so auszudrücken, dass jeder sie verstehen muss.", + "source": "Arthur Schopenhauer", + "length": 173, + "id": 570 + }, + { + "text": "Die Demokratie lebt vom Kompromiss. Wer keine Kompromisse machen kann, ist für die Demokratie nicht zu gebrauchen.", + "source": "Helmut Schmidt", + "length": 114, + "id": 571 + }, + { + "text": "Die Demokratie, wie ich sie verstehe, muss den Schwächsten die gleichen Chancen zusichern wie den Stärksten.", + "source": "Mahatma Gandhi", + "length": 108, + "id": 572 + }, + { + "text": "Politik ist ein Streit der Interessen, der sich als Wettstreit der Prinzipien maskiert.", + "source": "Ambrose Bierce", + "length": 87, + "id": 573 + }, + { + "text": "Reich wird man nicht durch das, was man verdient, sondern durch das, was man nicht ausgibt.", + "source": "Henry Ford", + "length": 91, + "id": 574 + }, + { + "text": "Als ich jung war, glaubte ich, Geld sei das Wichtigste im Leben. Jetzt wo ich alt bin, weiß ich, dass es das Wichtigste ist.", + "source": "Oscar Wilde", + "length": 124, + "id": 575 } ] } From 7835cac0f51e035e1249c81aabc54e3dbd714c1c Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 6 Apr 2023 21:50:40 +0200 Subject: [PATCH 5/6] checking performance.now once, and passing it around checking performance.now before a setTimeout setting test end as soon as possible --- .../src/ts/controllers/input-controller.ts | 15 ++++++----- frontend/src/ts/test/test-input.ts | 11 +++----- frontend/src/ts/test/test-logic.ts | 26 +++++++++++++------ 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index ded10b2d2..881ba3c7d 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -394,6 +394,9 @@ function handleChar( if (TestUI.resultCalculating || TestUI.resultVisible) { return; } + + const now = performance.now(); + const isCharKorean: boolean = TestInput.input.getKoreanStatus(); if (char === "…") { for (let i = 0; i < 3; i++) { @@ -442,7 +445,7 @@ function handleChar( } //start the test - if (!TestState.isActive && !TestLogic.startTest()) { + if (!TestState.isActive && !TestLogic.startTest(now)) { return; } @@ -464,7 +467,7 @@ function handleChar( } if (TestInput.input.current === "") { - TestInput.setBurstStart(performance.now()); + TestInput.setBurstStart(now); } if (!isCharKorean && !Config.language.startsWith("korean")) { @@ -958,21 +961,21 @@ $(document).keydown(async (event) => { $("#wordsInput").keydown((event) => { if (event.originalEvent?.repeat) return; - + const now = performance.now(); setTimeout(() => { const isAndroid = event.key === "Unidentified" && event.code === "" && event.which === 229; - TestInput.recordKeydownTime(isAndroid ? "Android" : event.code); + TestInput.recordKeydownTime(now, isAndroid ? "Android" : event.code); }, 0); }); $("#wordsInput").keyup((event) => { if (event.originalEvent?.repeat) return; - + const now = performance.now(); setTimeout(() => { const isAndroid = event.key === "Unidentified" && event.code === "" && event.which === 229; - TestInput.recordKeyupTime(isAndroid ? "Android" : event.code); + TestInput.recordKeyupTime(now, isAndroid ? "Android" : event.code); }, 0); }); diff --git a/frontend/src/ts/test/test-input.ts b/frontend/src/ts/test/test-input.ts index aa0381f4c..ecfd74711 100644 --- a/frontend/src/ts/test/test-input.ts +++ b/frontend/src/ts/test/test-input.ts @@ -285,7 +285,7 @@ export function incrementAccuracy(correctincorrect: boolean): void { } } -export function forceKeyup(): void { +export function forceKeyup(now: number): void { //using mean here because for words mode, the last keypress ends the test. //if we then force keyup on that last keypress, it will record a duration of 0 //skewing the average and standard deviation @@ -293,7 +293,7 @@ export function forceKeyup(): void { const keysOrder = Object.entries(keyDownData); keysOrder.sort((a, b) => a[1].timestamp - b[1].timestamp); for (let i = 0; i < keysOrder.length - 1; i++) { - recordKeyupTime(keysOrder[i][0]); + recordKeyupTime(now, keysOrder[i][0]); } const last = keysOrder[keysOrder.length - 1]; if (last !== undefined) { @@ -303,7 +303,7 @@ export function forceKeyup(): void { let androidIndex = 0; -export function recordKeyupTime(key: string): void { +export function recordKeyupTime(now: number, key: string): void { if (!keysToTrack.includes(key)) return; if (key === "Android") { @@ -313,7 +313,6 @@ export function recordKeyupTime(key: string): void { if (keyDownData[key] === undefined) return; - const now = performance.now(); const diff = Math.abs(keyDownData[key].timestamp - now); keypressTimings.duration.array[keyDownData[key].index] = diff; delete keyDownData[key]; @@ -321,7 +320,7 @@ export function recordKeyupTime(key: string): void { updateOverlap(now); } -export function recordKeydownTime(key: string): void { +export function recordKeydownTime(now: number, key: string): void { if (!keysToTrack.includes(key)) { if (spacingDebug) { console.log( @@ -353,8 +352,6 @@ export function recordKeydownTime(key: string): void { return; } - const now = performance.now(); - keyDownData[key] = { timestamp: now, index: keypressTimings.duration.array.length, diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index f4aa96748..b444df9a4 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -307,7 +307,7 @@ async function applyEnglishPunctuationToWord(word: string): Promise { return EnglishPunctuation.replace(word); } -export function startTest(): boolean { +export function startTest(now: number): boolean { if (PageTransition.get()) { return false; } @@ -348,7 +348,7 @@ export function startTest(): boolean { } } catch (e) {} //use a recursive self-adjusting timer to avoid time drift - TestStats.setStart(performance.now()); + TestStats.setStart(now); TestTimer.start(); return true; } @@ -1386,9 +1386,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { Config.mode === "zen" ? 0 : Misc.roundTo2(TestStats.end - TestInput.keypressTimings.spacing.last), - startToFirstKey: Misc.roundTo2( - TestInput.keypressTimings.spacing.first - TestStats.start - ), + startToFirstKey: undefined, consistency: undefined, keyConsistency: undefined, funbox: Config.funbox, @@ -1403,6 +1401,16 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { afkDuration: undefined, }; + const stfk = Misc.roundTo2( + TestInput.keypressTimings.spacing.first - TestStats.start + ); + + if (stfk > 0) { + completedEvent.startToFirstKey = stfk; + } else { + completedEvent.startToFirstKey = 0; + } + // stats const stats = TestStats.calculateStats(); if (stats.time % 1 != 0 && Config.mode !== "time") { @@ -1527,19 +1535,21 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { } export async function finish(difficultyFailed = false): Promise { - await Misc.sleep(1); //this is needed to make sure the last keypress is registered if (!TestState.isActive) return; + const now = performance.now(); + TestStats.setEnd(now); + + await Misc.sleep(1); //this is needed to make sure the last keypress is registered if (TestInput.input.current.length != 0) { TestInput.input.pushHistory(); TestInput.corrected.pushHistory(); Replay.replayGetWordsList(TestInput.input.history); } - TestInput.forceKeyup(); //this ensures that the last keypress(es) are registered + TestInput.forceKeyup(now); //this ensures that the last keypress(es) are registered TestUI.setResultCalculating(true); TestUI.setResultVisible(true); - TestStats.setEnd(performance.now()); TestState.setActive(false); Replay.stopReplayRecording(); Focus.set(false); From c60d3bff3835a5511b9c8444e79ee2e4f690d54d Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 6 Apr 2023 23:03:17 +0200 Subject: [PATCH 6/6] fixed 422 errors --- frontend/src/ts/test/test-logic.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index b444df9a4..b54b24077 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -1382,10 +1382,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { keySpacing: TestInput.keypressTimings.spacing.array, keyDuration: TestInput.keypressTimings.duration.array, keyOverlap: Misc.roundTo2(TestInput.keyOverlap.total), - lastKeyToEnd: - Config.mode === "zen" - ? 0 - : Misc.roundTo2(TestStats.end - TestInput.keypressTimings.spacing.last), + lastKeyToEnd: undefined, startToFirstKey: undefined, consistency: undefined, keyConsistency: undefined, @@ -1405,10 +1402,20 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent { TestInput.keypressTimings.spacing.first - TestStats.start ); - if (stfk > 0) { - completedEvent.startToFirstKey = stfk; - } else { + if (stfk < 0) { completedEvent.startToFirstKey = 0; + } else { + completedEvent.startToFirstKey = stfk; + } + + const lkte = Misc.roundTo2( + TestStats.end - TestInput.keypressTimings.spacing.last + ); + + if (lkte < 0 || Config.mode === "zen") { + completedEvent.lastKeyToEnd = 0; + } else { + completedEvent.lastKeyToEnd = lkte; } // stats