@@ -436,7 +436,7 @@ <h2>Results</h2>
436436 renderTable ( ) ;
437437 drawCircle ( ) ;
438438 drawMiniCircle ( ) ;
439- startTimer ( ) ;
439+ // startTimer();
440440 doneBtn . disabled = false ;
441441}
442442
@@ -447,23 +447,41 @@ <h2>Results</h2>
447447 setTimeout ( checkAnswers , 10 ) ;
448448} ;
449449
450- restartBtn . onclick = init ;
450+ restartBtn . onclick = ( ) => startPractice ( true ) ;
451451
452- init ( ) ;
452+ window . addEventListener ( "load" , ( ) => startPractice ( false ) ) ;
453453
454- /* ---------- LICENSE POPUP LOGIC ---------- */
455- window . addEventListener ( "load" , ( ) => {
456- if ( ! localStorage . getItem ( "hideLicensePopup" ) ) {
457- document . getElementById ( "licenseOverlay" ) . style . display = "flex" ;
458- }
459- } ) ;
454+ function startPractice ( isRestart = false ) {
455+ init ( ) ; // set up the problems and draw circles
456+
457+ if ( ! isRestart ) {
458+ const hidePopup = localStorage . getItem ( "hideLicensePopup" ) ;
459+
460+ if ( hidePopup ) {
461+ startTimer ( ) ; // start immediately if user has chosen not to see the popup
462+ } else {
463+ const licenseOverlay = document . getElementById ( "licenseOverlay" ) ;
464+ const closeBtn = document . getElementById ( "closeLicenseBtn" ) ;
465+
466+ // define the click handler first
467+ closeBtn . onclick = ( ) => {
468+ if ( document . getElementById ( "dontShowAgain" ) . checked ) {
469+ localStorage . setItem ( "hideLicensePopup" , "true" ) ;
470+ }
471+ licenseOverlay . style . display = "none" ;
472+ startTimer ( ) ; // timer starts after popup closed
473+ } ;
474+
475+ // then show the popup
476+ licenseOverlay . style . display = "flex" ;
477+ }
478+ } else {
479+ // Restart pressed → start timer immediately
480+ startTimer ( ) ;
481+ }
482+
483+ }
460484
461- document . getElementById ( "closeLicenseBtn" ) . onclick = ( ) => {
462- if ( document . getElementById ( "dontShowAgain" ) . checked ) {
463- localStorage . setItem ( "hideLicensePopup" , "true" ) ;
464- }
465- document . getElementById ( "licenseOverlay" ) . style . display = "none" ;
466- } ;
467485
468486</ script >
469487
0 commit comments