This repository was archived by the owner on Mar 23, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -167,12 +167,19 @@ function selectChapter(id) {
167167function nextPage ( ) {
168168 const page = parseInt ( mango . storage ( 'page' ) ) ;
169169 const atHome = JSON . parse ( mango . storage ( 'atHomeData' ) ) ;
170- const filename = atHome . chapter . data [ page ]
171- mango . storage ( 'page' , ( page + 1 ) . toString ( ) ) ;
170+ const filename = atHome . chapter . data [ page ] ;
172171 if ( ! filename ) return JSON . stringify ( { } ) ;
173172
173+ //Get the number of 'numbers' of pages
174+ const len = Math . ceil ( Math . log ( atHome . chapter . data . length + 1 ) / Math . LN10 ) ;
175+ //Pad the page number with zeroes depending of the number of pages
176+ const pageNum = Array ( Math . max ( len - String ( page + 1 ) . length + 1 , 0 ) ) . join ( 0 ) + ( page + 1 ) ;
177+
178+ const finalFilename = pageNum + '.' + filename . split ( '.' ) [ filename . split ( '.' ) . length - 1 ] ;
179+ mango . storage ( 'page' , ( page + 1 ) . toString ( ) ) ;
180+
174181 return JSON . stringify ( {
175182 url : atHome . baseUrl + '/data/' + atHome . chapter . hash + '/' + filename ,
176- filename : filename ,
183+ filename : finalFilename ,
177184 } ) ;
178185}
You can’t perform that action at this time.
0 commit comments