File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 182182 ( Math . floor ( selected . r / 3 ) === Math . floor ( r / 3 ) && Math . floor ( selected . c / 3 ) === Math . floor ( c / 3 ) ) ;
183183 }
184184
185+ function normalizeElapsed ( value ) {
186+ const parsed = Number ( value ) ;
187+ if ( ! Number . isFinite ( parsed ) || parsed < 0 ) return 0 ;
188+ return Math . floor ( parsed ) ;
189+ }
190+
185191 function formatTime ( t ) {
186- return `${ String ( Math . floor ( t / 60 ) ) . padStart ( 2 , '0' ) } :${ String ( t % 60 ) . padStart ( 2 , '0' ) } ` ;
192+ const normalized = normalizeElapsed ( t ) ;
193+ return `${ String ( Math . floor ( normalized / 60 ) ) . padStart ( 2 , '0' ) } :${ String ( normalized % 60 ) . padStart ( 2 , '0' ) } ` ;
187194 }
188195
189196 // ── Notes ────────────────────────────────────────────────────────────────
566573 startingGrid = data . startingGrid || data . grid . map ( row => row . slice ( ) ) ;
567574 notes = data . notes . map ( row => row . map ( arr => new Set ( arr ) ) ) ;
568575 selected = data . selected ;
569- elapsed = data . elapsed || 0 ;
576+ elapsed = normalizeElapsed ( data . elapsed ?? data . timeElapsed ?? data . timer ?? data . timeSeconds ) ;
570577 notesMode = ! ! data . notesMode ;
571578 autoCleanup = data . autoCleanup !== false ;
572579 difficultyEl . value = data . difficulty || 'medium' ;
946953 try {
947954 const saved = JSON . parse ( raw ) ;
948955 const modal = document . getElementById ( 'resumeModal' ) ;
949- timeStat . textContent = formatTime ( Number ( saved . elapsed ) || 0 ) ;
956+ timeStat . textContent = formatTime ( saved . elapsed ?? saved . timeElapsed ?? saved . timer ?? saved . timeSeconds ) ;
950957 modal . hidden = false ;
951958 document . getElementById ( 'resumeYesBtn' ) . onclick = ( ) => { modal . hidden = true ; applyLoadedData ( saved ) ; } ;
952959 document . getElementById ( 'resumeNoBtn' ) . onclick = ( ) => { modal . hidden = true ; newGame ( ) ; } ;
You can’t perform that action at this time.
0 commit comments