@@ -57,6 +57,7 @@ import * as XPBar from "../elements/xp-bar";
5757import * as ModesNotice from "../elements/modes-notice" ;
5858import * as Last10Average from "../elements/last-10-average" ;
5959import * as MemoryFunboxTimer from "./funbox/memory-funbox-timer" ;
60+ import { qsr } from "../utils/dom" ;
6061
6162export const updateHintsPositionDebounced = Misc . debounceUntilResolved (
6263 updateHintsPosition ,
@@ -67,6 +68,7 @@ const wordsEl = document.querySelector(".pageTest #words") as HTMLElement;
6768const wordsWrapperEl = document . querySelector (
6869 ".pageTest #wordsWrapper" ,
6970) as HTMLElement ;
71+ const resultWordsHistoryEl = qsr ( ".pageTest #resultWordsHistory" ) ;
7072
7173export let activeWordTop = 0 ;
7274export let activeWordHeight = 0 ;
@@ -1391,42 +1393,18 @@ async function loadWordsHistory(): Promise<boolean> {
13911393 return true ;
13921394}
13931395
1394- export function toggleResultWords ( noAnimation = false ) : void {
1395- if ( TestState . resultVisible ) {
1396- ResultWordHighlight . updateToggleWordsHistoryTime ( ) ;
1397- if ( $ ( "#resultWordsHistory" ) . stop ( true , true ) . hasClass ( "hidden" ) ) {
1398- //show
1399-
1400- if ( $ ( "#resultWordsHistory .words .word" ) . length === 0 ) {
1401- void loadWordsHistory ( ) . then ( ( ) => {
1402- if ( Config . burstHeatmap ) {
1403- void applyBurstHeatmap ( ) ;
1404- }
1405- $ ( "#resultWordsHistory" )
1406- . removeClass ( "hidden" )
1407- . css ( "display" , "none" )
1408- . slideDown ( noAnimation ? 0 : 250 , ( ) => {
1409- if ( Config . burstHeatmap ) {
1410- void applyBurstHeatmap ( ) ;
1411- }
1412- } ) ;
1413- } ) ;
1414- } else {
1415- if ( Config . burstHeatmap ) {
1416- void applyBurstHeatmap ( ) ;
1417- }
1418- $ ( "#resultWordsHistory" )
1419- . removeClass ( "hidden" )
1420- . css ( "display" , "none" )
1421- . slideDown ( noAnimation ? 0 : 250 ) ;
1422- }
1423- } else {
1424- //hide
1396+ export async function toggleResultWords ( noAnimation = false ) : Promise < void > {
1397+ if ( ! TestState . resultVisible ) return ;
1398+ ResultWordHighlight . updateToggleWordsHistoryTime ( ) ;
14251399
1426- $ ( "#resultWordsHistory" ) . slideUp ( 250 , ( ) => {
1427- $ ( "#resultWordsHistory" ) . addClass ( "hidden" ) ;
1428- } ) ;
1400+ if ( resultWordsHistoryEl . isHidden ( ) ) {
1401+ if ( resultWordsHistoryEl . qsa ( ".words .word" ) . length === 0 ) {
1402+ await loadWordsHistory ( ) ;
14291403 }
1404+ void resultWordsHistoryEl . slideDown ( noAnimation ? 0 : 250 ) ;
1405+ void applyBurstHeatmap ( ) ;
1406+ } else {
1407+ void resultWordsHistoryEl . slideUp ( noAnimation ? 0 : 250 ) ;
14301408 }
14311409}
14321410
@@ -2005,7 +1983,7 @@ $("#wordsInput").on("focusout", () => {
20051983} ) ;
20061984
20071985$ ( ".pageTest" ) . on ( "click" , "#showWordHistoryButton" , ( ) => {
2008- toggleResultWords ( ) ;
1986+ void toggleResultWords ( ) ;
20091987} ) ;
20101988
20111989$ ( "#wordsWrapper" ) . on ( "click" , ( ) => {
0 commit comments