From 702278a58a2a3df3dece908553e68e3ffee05750 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 18 Jan 2022 00:01:36 +0100 Subject: [PATCH] added ability to use unsmoothed raw (for fun) --- src/js/global-dependencies.js | 1 + src/js/test/result.js | 23 ++++++++++++++++++++--- src/js/test/test-logic.js | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/js/global-dependencies.js b/src/js/global-dependencies.js index 51a0b64b1..f4e2c0479 100644 --- a/src/js/global-dependencies.js +++ b/src/js/global-dependencies.js @@ -27,3 +27,4 @@ import * as Account from "./account"; import * as TestStats from "./test-stats"; import * as Replay from "./replay"; import * as TestTimer from "./test-timer"; +import * as Result from "./test-timer"; diff --git a/src/js/test/result.js b/src/js/test/result.js index 5eb57202b..eb4922bb0 100644 --- a/src/js/test/result.js +++ b/src/js/test/result.js @@ -11,10 +11,18 @@ import * as TodayTracker from "./today-tracker"; import * as PbCrown from "./pb-crown"; import * as RateQuotePopup from "./rate-quote-popup"; import * as TestLogic from "./test-logic"; +import * as Notifications from "./notifications"; let result; let maxChartVal; +let useUnsmoothedRaw = false; + +export function toggleUnsmoothed() { + useUnsmoothedRaw = !useUnsmoothedRaw; + Notifications.add(useUnsmoothedRaw ? "on" : "off", 1); +} + async function updateGraph() { ChartController.result.options.annotation.annotations = []; let labels = []; @@ -33,9 +41,18 @@ async function updateGraph() { let chartData1 = Config.alwaysShowCPM ? TestStats.wpmHistory.map((a) => a * 5) : TestStats.wpmHistory; - let chartData2 = Config.alwaysShowCPM - ? result.chartData.raw.map((a) => a * 5) - : result.chartData.raw; + + let chartData2; + + if (useUnsmoothedRaw) { + chartData2 = Config.alwaysShowCPM + ? result.chartData.unsmoothedRaw.map((a) => a * 5) + : result.chartData.unsmoothedRaw; + } else { + chartData2 = Config.alwaysShowCPM + ? result.chartData.raw.map((a) => a * 5) + : result.chartData.raw; + } ChartController.result.data.datasets[0].data = chartData1; ChartController.result.data.datasets[1].data = chartData2; diff --git a/src/js/test/test-logic.js b/src/js/test/test-logic.js index 5f972fb07..69fba5111 100644 --- a/src/js/test/test-logic.js +++ b/src/js/test/test-logic.js @@ -1480,6 +1480,7 @@ function buildCompletedEvent(difficultyFailed) { completedEvent.consistency = consistency; let smoothedraw = Misc.smooth(rawPerSecond, 1); completedEvent.chartData.raw = smoothedraw; + completedEvent.chartData.unsmoothedRaw = rawPerSecond; //smoothed consistency let stddev2 = Misc.stdDev(smoothedraw); @@ -1676,6 +1677,8 @@ export async function finish(difficultyFailed = false) { dontSave ); + delete completedEvent.chartData.unsmoothedRaw; + if (completedEvent.testDuration > 122) { completedEvent.chartData = "toolong"; TestStats.setKeypressTimingsTooLong();