@@ -154,7 +154,10 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
154
154
let thumbnails = [ ] ;
155
155
156
156
// Get comic reading progress image
157
- let readingProgress = storage . get ( 'readingProgress' ) ;
157
+ let _readingProgress = storage . get ( 'readingProgress' ) ;
158
+
159
+ let readingProgress = _readingProgress [ mainPath ] || false ;
160
+ let readingProgressCurrentPath = ( mainPath != path ) ? ( _readingProgress [ path ] || false ) : false ;
158
161
159
162
if ( files )
160
163
{
@@ -170,14 +173,24 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
170
173
}
171
174
}
172
175
173
- if ( readingProgress [ mainPath ] && readingProgress [ mainPath ] . lastReading > 0 )
176
+ if ( readingProgress )
177
+ {
178
+ let path = readingProgress . path ;
179
+ let sha = sha1 ( path ) ;
180
+
181
+ images . push ( { path : path , sha : sha } ) ;
182
+
183
+ readingProgress . sha = sha ;
184
+ }
185
+
186
+ if ( readingProgressCurrentPath )
174
187
{
175
- let path = readingProgress [ mainPath ] . path ;
188
+ let path = readingProgressCurrentPath . path ;
176
189
let sha = sha1 ( path ) ;
177
190
178
191
images . push ( { path : path , sha : sha } ) ;
179
192
180
- readingProgress [ mainPath ] . sha = sha ;
193
+ readingProgressCurrentPath . sha = sha ;
181
194
}
182
195
183
196
thumbnails = cache . returnThumbnailsImages ( images , function ( data ) {
@@ -228,59 +241,81 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
228
241
}
229
242
else
230
243
{
231
- if ( readingProgress [ mainPath ] && readingProgress [ mainPath ] . lastReading > 0 )
244
+ let images = [ ] ;
245
+
246
+ if ( readingProgress )
232
247
{
233
- let path = readingProgress [ mainPath ] . path ;
248
+ let path = readingProgress . path ;
234
249
let sha = sha1 ( path ) ;
235
250
236
- let thumbnail = cache . returnThumbnailsImages ( { path : path , sha : sha } , function ( data ) {
251
+ images . push ( { path : path , sha : sha } ) ;
237
252
238
- addImageToDom ( data . sha , data . path ) ;
253
+ readingProgress . sha = sha ;
254
+ }
239
255
240
- } , file ) ;
256
+ if ( readingProgressCurrentPath )
257
+ {
258
+ let path = readingProgressCurrentPath . path ;
259
+ let sha = sha1 ( path ) ;
241
260
242
- readingProgress [ mainPath ] . sha = sha ;
243
- thumbnails [ sha ] = thumbnail ;
261
+ images . push ( { path : path , sha : sha } ) ;
262
+
263
+ readingProgressCurrentPath . sha = sha ;
244
264
}
265
+
266
+ thumbnails = cache . returnThumbnailsImages ( images , function ( data ) {
267
+
268
+ addImageToDom ( data . sha , data . path ) ;
269
+
270
+ } , file ) ;
245
271
}
246
272
247
273
handlebarsContext . comics = pathFiles ;
248
274
249
275
// Comic reading progress
250
- if ( readingProgress [ mainPath ] && readingProgress [ mainPath ] . lastReading > 0 )
276
+ if ( readingProgress )
251
277
{
252
- let path = readingProgress [ mainPath ] . path ;
253
- let sha = readingProgress [ mainPath ] . sha ;
254
-
278
+ let sha = readingProgress . sha ;
255
279
let thumbnail = thumbnails [ sha ] ;
256
280
257
- readingProgress [ mainPath ] . sha = sha ;
258
- readingProgress [ mainPath ] . thumbnail = ( thumbnail . cache ) ? thumbnail . path : '' ;
259
- readingProgress [ mainPath ] . mainPath = mainPath ;
260
- readingProgress [ mainPath ] . pathText = returnTextPath ( readingProgress [ mainPath ] . path , mainPath , true ) ;
261
- handlebarsContext . comicsReadingProgress = readingProgress [ mainPath ] ;
281
+ readingProgress . sha = sha ;
282
+ readingProgress . thumbnail = ( thumbnail . cache ) ? thumbnail . path : '' ;
283
+ readingProgress . mainPath = mainPath ;
284
+ readingProgress . pathText = returnTextPath ( readingProgress . path , mainPath , true , ! readingProgress . ebook ) ;
285
+ handlebarsContext . comicsReadingProgress = readingProgress ;
262
286
}
263
287
else
264
288
{
265
289
handlebarsContext . comicsReadingProgress = false ;
266
290
}
267
291
268
- /*if(keepScroll > 1)
269
- template.contentRight().children().html(template.load('index.content.right.'+config.view+'.html')).scrollTop(keepScroll);
292
+ // Current folder reading progress
293
+ if ( readingProgressCurrentPath )
294
+ {
295
+ let sha = readingProgressCurrentPath . sha ;
296
+ let thumbnail = thumbnails [ sha ] ;
297
+
298
+ readingProgressCurrentPath . sha = sha ;
299
+ readingProgressCurrentPath . thumbnail = ( thumbnail . cache ) ? thumbnail . path : '' ;
300
+ readingProgressCurrentPath . mainPath = mainPath ;
301
+ readingProgressCurrentPath . pathText = returnTextPath ( readingProgressCurrentPath . path , path , true , ! readingProgressCurrentPath . ebook ) ;
302
+ handlebarsContext . comicsReadingProgressCurrentPath = readingProgressCurrentPath ;
303
+ }
270
304
else
271
- template.contentRight().children().html(template.load('index.content.right.'+config.view+'.html'));*/
305
+ {
306
+ handlebarsContext . comicsReadingProgressCurrentPath = false ;
307
+ }
272
308
273
- //template.loadContentRight('index.content.right.'+config.view+'.html', animation, keepScroll);
274
309
events . events ( ) ;
275
310
276
- return { files : pathFiles , readingProgress : readingProgress [ mainPath ] || { } , html : template . load ( 'index.content.right.' + config . view + '.html' ) } ;
311
+ return { files : pathFiles , readingProgress : readingProgress || { } , readingProgressCurrentPath : readingProgressCurrentPath || { } , html : template . load ( 'index.content.right.' + config . view + '.html' ) } ;
277
312
278
313
} ) . catch ( function ( error ) {
279
314
280
315
console . error ( error ) ;
281
316
dom . compressedError ( error ) ;
282
317
283
- return { files : [ ] , readingProgress : { } , html : '' } ;
318
+ return { files : [ ] , readingProgress : { } , readingProgressCurrentPath : { } , html : '' } ;
284
319
285
320
} ) ;
286
321
@@ -495,22 +530,29 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
495
530
queue . stop ( 'folderThumbnails' ) ;
496
531
497
532
// Get comic reading progress image
498
- let readingProgress = storage . get ( 'readingProgress' ) ;
499
- readingProgress = readingProgress [ mainPath ] || { } ;
533
+ let _readingProgress = storage . get ( 'readingProgress' ) ;
534
+ let readingProgress = _readingProgress [ mainPath ] || false ;
535
+ let readingProgressCurrentPath = ( mainPath != path ) ? ( _readingProgress [ path ] || false ) : false ;
500
536
501
537
let isCompressed = fileManager . isCompressed ( path ) ;
502
538
503
539
let openContinueReading = false ;
504
540
let openFirstImage = ( ( ! isCompressed && config . whenOpenFolderFirstImageOrContinueReading ) || ( isCompressed && config . whenOpenFileFirstImageOrContinueReading ) ) ? true : false ;
505
541
506
- if ( ( config . whenOpenFolderContinueReading || config . whenOpenFileContinueReading || config . whenOpenFolderFirstImageOrContinueReading || config . whenOpenFileFirstImageOrContinueReading ) && ! fromGoBack && ! notAutomaticBrowsing && readingProgress && readingProgress . lastReading > 0 )
542
+ if ( ( config . whenOpenFolderContinueReading || config . whenOpenFileContinueReading || config . whenOpenFolderFirstImageOrContinueReading || config . whenOpenFileFirstImageOrContinueReading ) && ! fromGoBack && ! notAutomaticBrowsing && readingProgress )
507
543
{
508
544
let isParentPath = fileManager . isParentPath ( path , readingProgress . path ) ;
509
545
510
- if ( ( ! isCompressed && ( config . whenOpenFolderContinueReading || config . whenOpenFolderFirstImageOrContinueReading ) ) && isParentPath )
511
- openContinueReading = true ;
512
- else if ( ( isCompressed && ( config . whenOpenFileContinueReading || config . whenOpenFileFirstImageOrContinueReading ) ) && isParentPath )
513
- openContinueReading = true ;
546
+ if ( isParentPath || readingProgressCurrentPath )
547
+ {
548
+ if ( ! isParentPath && readingProgressCurrentPath )
549
+ readingProgress = readingProgressCurrentPath ;
550
+
551
+ if ( ( ! isCompressed && ( config . whenOpenFolderContinueReading || config . whenOpenFolderFirstImageOrContinueReading ) ) )
552
+ openContinueReading = true ;
553
+ else if ( ( isCompressed && ( config . whenOpenFileContinueReading || config . whenOpenFileFirstImageOrContinueReading ) ) )
554
+ openContinueReading = true ;
555
+ }
514
556
}
515
557
516
558
let file = fileManager . file ( path ) ;
@@ -600,17 +642,19 @@ function addSepToEnd(path)
600
642
return path ;
601
643
}
602
644
603
- function returnTextPath ( path , mainPath , image = false )
645
+ function returnTextPath ( path , mainPath , image = false , extension = true )
604
646
{
605
647
mainPathR = addSepToEnd ( p . dirname ( mainPath ) ) ;
606
648
607
- var files = path . replace ( new RegExp ( '^\s*' + pregQuote ( mainPathR ) ) , '' ) . split ( p . sep ) ;
649
+ let files = path . replace ( new RegExp ( '^\s*' + pregQuote ( mainPathR ) ) , '' ) . split ( p . sep ) ;
650
+ path = [ ] ;
608
651
609
- var path = [ ] ;
610
-
611
- for ( let index in files )
652
+ for ( let i = 0 , len = files . length ; i < len ; i ++ )
612
653
{
613
- path . push ( translatePageName ( image ? htmlEntities ( files [ index ] ) : files [ index ] ) ) ;
654
+ if ( ! extension && i == len - 1 )
655
+ files [ i ] = p . parse ( files [ i ] ) . name ;
656
+
657
+ path . push ( translatePageName ( image ? htmlEntities ( files [ i ] ) : files [ i ] ) ) ;
614
658
}
615
659
616
660
return path . join ( image ? '<i class="material-icon navegation">chevron_right</i>' : ' / ' ) ;
0 commit comments