@@ -299,18 +299,38 @@ function toggleFolder(element,folder){
299
299
}
300
300
301
301
function addFavorite ( element , id ) {
302
- $ ( element ) . attr ( 'onclick' , 'removeFavorite(this,' + id + ');' ) . html ( 'Défavoriser' ) ;
302
+ var activeScreen = $ ( '#pageTop' ) . html ( ) ;
303
303
$ . ajax ( {
304
304
url : "./action.php?action=addFavorite" ,
305
- data :{ id :id }
305
+ data :{ id :id } ,
306
+ success :function ( msg ) {
307
+ if ( msg . status == 'noconnect' ) {
308
+ alert ( msg . texte )
309
+ } else {
310
+ if ( console && console . log && msg != "" ) console . log ( msg ) ;
311
+ $ ( element ) . attr ( 'onclick' , 'removeFavorite(this,' + id + ');' ) . html ( 'Défavoriser' ) ;
312
+ // on compte combien d'article ont été remis en favoris sur la pages favoris (scroll infini)
313
+ if ( activeScreen == 'favorites' ) $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) - 1 ) ;
314
+ }
315
+ }
306
316
} ) ;
307
317
}
308
318
309
319
function removeFavorite ( element , id ) {
310
- $ ( element ) . attr ( 'onclick' , 'addFavorite(this,' + id + ');' ) . html ( 'Favoriser' ) ;
320
+ var activeScreen = $ ( '#pageTop' ) . html ( ) ;
311
321
$ . ajax ( {
312
322
url : "./action.php?action=removeFavorite" ,
313
- data :{ id :id }
323
+ data :{ id :id } ,
324
+ success :function ( msg ) {
325
+ if ( msg . status == 'noconnect' ) {
326
+ alert ( msg . texte )
327
+ } else {
328
+ if ( console && console . log && msg != "" ) console . log ( msg ) ;
329
+ $ ( element ) . attr ( 'onclick' , 'addFavorite(this,' + id + ');' ) . html ( 'Favoriser' ) ;
330
+ // on compte combien d'article ont été remis en favoris sur la pages favoris (scroll infini)
331
+ if ( activeScreen == 'favorites' ) $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) + 1 ) ;
332
+ }
333
+ }
314
334
} ) ;
315
335
}
316
336
@@ -380,74 +400,93 @@ function changeFeedFolder(element,id){
380
400
381
401
382
402
function readThis ( element , id , from , callback ) {
383
- var hide = ( $ ( '#pageTop' ) . html ( ) == '' ? true : false ) ;
403
+ var activeScreen = $ ( '#pageTop' ) . html ( ) ;
384
404
var parent = $ ( element ) . parent ( ) . parent ( ) ;
385
405
var nextEvent = $ ( '#' + id ) . next ( ) ;
386
406
//sur les éléments non lus
387
407
if ( ! parent . hasClass ( 'eventRead' ) ) {
388
-
389
- if ( hide ) {
390
- // cas de la page d'accueil
391
- parent . addClass ( 'eventRead' ) ;
392
- parent . fadeOut ( 200 , function ( ) {
393
- if ( callback ) {
394
- //alert(callback);
395
- callback ( ) ;
396
- } else {
397
- targetThisEvent ( nextEvent , true ) ;
398
- }
399
- // on simule un scroll si tous les events sont cachés
400
- if ( $ ( 'article section:last' ) . attr ( 'style' ) == 'display: none;' ) {
401
- $ ( window ) . scrollTop ( $ ( document ) . height ( ) ) ;
402
- }
403
- } ) ;
404
- // on compte combien d'article ont été lus afin de les soustraires de la requête pour le scroll infini
405
- $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) + 1 ) ;
406
- } else {
407
- // autres cas : favoris, selectedFolder, selectedFeed ...
408
- parent . addClass ( 'eventRead' ) ;
409
- targetThisEvent ( nextEvent , true ) ;
410
- }
411
-
412
408
$ . ajax ( {
413
409
url : "./action.php?action=readContent" ,
414
410
data :{ id :id } ,
415
411
success :function ( msg ) {
416
- if ( msg != "" ) alert ( 'Erreur de lecture : ' + msg ) ;
412
+ if ( msg . status == 'noconnect' ) {
413
+ alert ( msg . texte )
414
+ } else {
415
+ if ( console && console . log && msg != "" ) console . log ( msg ) ;
416
+ switch ( activeScreen ) {
417
+ case '' :
418
+ // cas de la page d'accueil
419
+ parent . addClass ( 'eventRead' ) ;
420
+ parent . fadeOut ( 200 , function ( ) {
421
+ if ( callback ) {
422
+ callback ( ) ;
423
+ } else {
424
+ targetThisEvent ( nextEvent , true ) ;
425
+ }
426
+ // on simule un scroll si tous les events sont cachés
427
+ if ( $ ( 'article section:last' ) . attr ( 'style' ) == 'display: none;' ) {
428
+ $ ( window ) . scrollTop ( $ ( document ) . height ( ) ) ;
429
+ }
430
+ } ) ;
431
+ // on compte combien d'article ont été lus afin de les soustraires de la requête pour le scroll infini
432
+ $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) + 1 ) ;
433
+ break ;
434
+ case 'selectedFolder' :
435
+ parent . addClass ( 'eventRead' ) ;
436
+ targetThisEvent ( nextEvent , true ) ;
437
+ // on compte combien d'article ont été lus afin de les soustraires de la requête pour le scroll infini
438
+ $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) + 1 ) ;
439
+ break ;
440
+ default :
441
+ // autres cas : favoris, selectedFeed ...
442
+ parent . addClass ( 'eventRead' ) ;
443
+ targetThisEvent ( nextEvent , true ) ;
444
+ break ;
445
+ }
446
+ }
417
447
}
418
448
} ) ;
419
449
} else { // sur les éléments lus
420
450
// si ce n'est pas un clic sur le titre de l'event
421
451
if ( from != 'title' ) {
422
-
423
- parent . removeClass ( 'eventRead' ) ;
424
452
$ . ajax ( {
425
- url : "./action.php?action=unreadContent" ,
426
- data :{ id :id } ,
427
- success :function ( msg ) {
428
- if ( msg != "" ) alert ( 'Erreur de lecture : ' + msg ) ;
429
- }
453
+ url : "./action.php?action=unreadContent" ,
454
+ data :{ id :id } ,
455
+ success :function ( msg ) {
456
+ if ( msg . status == 'noconnect' ) {
457
+ alert ( msg . texte )
458
+ } else {
459
+ if ( console && console . log && msg != "" ) console . log ( msg ) ;
460
+ Parent . removeClass ( 'eventRead' ) ;
461
+ // on compte combien d'article ont été remis à non lus
462
+ if ( ( activeScreen == '' ) || ( activeScreen == 'selectedFolder' ) ) $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) - 1 ) ;
463
+ }
464
+ }
430
465
} ) ;
431
466
}
432
467
}
433
468
434
469
}
435
470
436
471
function unReadThis ( element , id , from ) {
437
- var hide = ( $ ( '#pageTop' ) . html ( ) == '' ? true : false ) ;
472
+ var activeScreen = $ ( '#pageTop' ) . html ( ) ;
438
473
var parent = $ ( element ) . parent ( ) . parent ( ) ;
439
474
if ( parent . hasClass ( 'eventRead' ) ) {
440
475
if ( from != 'title' ) {
441
- parent . removeClass ( 'eventRead' ) ;
442
476
$ . ajax ( {
443
477
url : "./action.php?action=unreadContent" ,
444
478
data :{ id :id } ,
445
479
success :function ( msg ) {
446
- if ( msg != "" ) alert ( 'Erreur de lecture : ' + msg ) ;
447
- }
480
+ if ( msg . status == 'noconnect' ) {
481
+ alert ( msg . texte )
482
+ } else {
483
+ if ( console && console . log && msg != "" ) console . log ( msg ) ;
484
+ parent . removeClass ( 'eventRead' ) ;
485
+ // on compte combien d'article ont été remis à non lus
486
+ if ( ( activeScreen == '' ) || ( activeScreen == 'selectedFolder' ) ) $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) - 1 ) ;
487
+ }
488
+ }
448
489
} ) ;
449
- // on compte combien d'article ont été remis à non lus (uniquement pour la page d'accueil)
450
- if ( hide ) $ ( window ) . data ( 'nblus' , $ ( window ) . data ( 'nblus' ) - 1 ) ;
451
490
}
452
491
}
453
492
0 commit comments