diff --git a/public/js/script.js b/public/js/script.js index 0d49fce09..d77fbcbdf 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -752,84 +752,6 @@ function showResult(difficultyFailed = false) { mode2 = "custom"; } - - if (firebase.auth().currentUser != null) { - $("#result .loginTip").addClass('hidden'); - } else { - $("#result .loginTip").removeClass('hidden'); - } - - - let testType = ""; - - - testType += config.mode; - if (config.mode == "time") { - testType += " " + config.time - } else if (config.mode == "words") { - testType += " " + config.words - } - if (config.mode != "custom") { - testType += "
" + config.language.replace('_', ' '); - } - if (config.punctuation) { - testType += "
punctuation" - } - if (config.blindMode) { - testType += "
blind" - } - if (config.difficulty == "expert") { - testType += "
expert"; - } else if (config.difficulty == "master") { - testType += "
master"; - } - - $("#result .stats .testType .bottom").html(testType); - - - let otherText = ""; - if (difficultyFailed) { - otherText += "
failed" - } - if (afkDetected) { - otherText += "
afk detected" - } - if (testInvalid) { - otherText += "
invalid" - } - if (sameWordset) { - otherText += "
repeated" - } - - if (otherText == "") { - $("#result .stats .info").addClass('hidden'); - } else { - $("#result .stats .info").removeClass('hidden'); - otherText = otherText.substring(4); - $("#result .stats .info .bottom").html(otherText); - } - - let tagsText = ""; - try { - dbSnapshot.tags.forEach(tag => { - if (tag.active === true) { - tagsText += "
" + tag.name; - } - }) - } catch (e) { - - } - - if (tagsText == "") { - $("#result .stats .tags").addClass('hidden'); - } else { - $("#result .stats .tags").removeClass('hidden'); - tagsText = tagsText.substring(4); - $("#result .stats .tags .bottom").html(tagsText); - } - - $("#result .stats .source .bottom").html(randomQuote.source); - let labels = []; for (let i = 1; i <= wpmHistory.length; i++) { labels.push(i.toString()); @@ -999,6 +921,87 @@ function showResult(difficultyFailed = false) { } } + + if (firebase.auth().currentUser != null) { + $("#result .loginTip").addClass('hidden'); + } else { + $("#result .loginTip").removeClass('hidden'); + } + + + let testType = ""; + + + testType += config.mode; + if (config.mode == "time") { + testType += " " + config.time + } else if (config.mode == "words") { + testType += " " + config.words + } + if (config.mode != "custom") { + testType += "
" + config.language.replace('_', ' '); + } + if (config.punctuation) { + testType += "
punctuation" + } + if (config.blindMode) { + testType += "
blind" + } + if (config.difficulty == "expert") { + testType += "
expert"; + } else if (config.difficulty == "master") { + testType += "
master"; + } + + $("#result .stats .testType .bottom").html(testType); + + + let otherText = ""; + if (difficultyFailed) { + otherText += "
failed" + } + if (afkDetected) { + otherText += "
afk detected" + } + if (testInvalid) { + otherText += "
invalid" + } + if (sameWordset) { + otherText += "
repeated" + } + + if (otherText == "") { + $("#result .stats .info").addClass('hidden'); + } else { + $("#result .stats .info").removeClass('hidden'); + otherText = otherText.substring(4); + $("#result .stats .info .bottom").html(otherText); + } + + let tagsText = ""; + try { + dbSnapshot.tags.forEach(tag => { + if (tag.active === true) { + tagsText += "
" + tag.name; + } + }) + } catch (e) { + + } + + if (tagsText == "") { + $("#result .stats .tags").addClass('hidden'); + } else { + $("#result .stats .tags").removeClass('hidden'); + tagsText = tagsText.substring(4); + $("#result .stats .tags .bottom").html(tagsText); + } + + if(config.mode === "quote"){ + $("#result .stats .source .bottom").html(randomQuote.source); + } + + wpmOverTimeChart.options.scales.yAxes[0].ticks.max = maxChartVal; wpmOverTimeChart.options.scales.yAxes[1].ticks.max = maxChartVal;