From d29b0334e620330b192e88ad64dd3a0da5fb57de Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 30 Aug 2020 01:14:57 +0100 Subject: [PATCH] added a try catch to avoid errors --- public/js/script.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index 6646e0d50..e54943dca 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -4077,18 +4077,20 @@ let wpmOverTimeChart = new Chart(ctx, { intersect: false, callbacks: { afterLabel: function (ti, data) { - $(".wordInputAfter").remove(); + try { + $(".wordInputAfter").remove(); - let wordsToHighlight = - keypressPerSecond[parseInt(ti.xLabel) - 1].words; + let wordsToHighlight = + keypressPerSecond[parseInt(ti.xLabel) - 1].words; - let unique = [...new Set(wordsToHighlight)]; - unique.forEach((wordIndex) => { - let wordEl = $($("#words .word")[wordIndex]); - let input = wordEl.attr("input"); - if (input != undefined) - wordEl.append(`
${input}
`); - }); + let unique = [...new Set(wordsToHighlight)]; + unique.forEach((wordIndex) => { + let wordEl = $($("#words .word")[wordIndex]); + let input = wordEl.attr("input"); + if (input != undefined) + wordEl.append(`
${input}
`); + }); + } catch (e) {} }, }, },