@ -27,6 +27,8 @@ function show_page(id, historyPush) {
}
}
//show_page("#demande-page");
$ ( "#login-button" ) . click ( function ( e ) {
var data = JSON . stringify ( {
user : $ ( "#login" ) . val ( ) ,
@ -52,9 +54,24 @@ $("#login-button").click(function (e) {
show_page ( '#demande-page' ) ;
}
} else {
alert ( data . why ) ;
$ ( '#error-message' ) . empty ( ) ;
t = new TypeIt ( '#error-message' , {
speed : 110 ,
lifeLike : true
} )
. type ( data . why )
. go ( ) ;
}
} ,
error : function ( e , status , i ) {
$ ( '#error-message' ) . empty ( ) ;
t = new TypeIt ( '#error-message' , {
speed : 110 ,
lifeLike : true
} )
. type ( status )
. go ( ) ;
}
} ) ;
@ -498,7 +515,6 @@ function refreshListener() {
}
$ ( window ) . on ( "load" , function ( ) {
/* Register the Service Worker */
if ( 'serviceWorker' in navigator ) {
navigator . serviceWorker . register ( './js/sw.js' ) ;
@ -508,6 +524,33 @@ $(window).on("load", function() {
$ ( page [ i ] ) . css ( 'z-index' , page . length - i ) ;
}
$ . ajax ( {
type : "GET" ,
url : base_url + "lastActivity" ,
contentType : "application/json; charset=utf-8" ,
dataType : "json" ,
success : ( data ) => {
if ( data . success ) {
opt = { speed : 100 , likeLike : true } ;
new TypeIt ( "#activite-title" , opt )
. type ( data . activity . title )
. go ( ) ;
new TypeIt ( "#activite-desc" , opt )
. type ( data . activity . desc )
. go ( ) ;
let diff = Math . ceil ( ( data . activity . start - new Date ( ) ) / 1000 )
let h = Math . round ( diff / 3600 )
let m = Math . round ( diff / 60 ) - h * 60
let s = diff - m * 60
$ ( "#timer" ) . text ( ( new Date ( 'December 17, 1995 ' + [ h , m , s ] . join ( ':' ) ) ) . toLocaleTimeString ( 'default' , {
hour : '2-digit' ,
minute : '2-digit' ,
second : '2-digit'
} ) ) ;
}
}
} )
/* load timer */
window . setInterval ( function ( ) {
var time = $ ( "#timer" ) . text ( ) ;
@ -526,11 +569,12 @@ $(window).on("load", function() {
t [ 1 ] = 0 ;
t [ 2 ] = 0 ;
}
$ ( "#timer" ) . text ( ( new Date ( 'December 17, 1995 ' + t . join ( ':' ) ) ) . toLocaleTimeString ( 'default' , {
$ ( '#timer' ) . text ( ( new Date ( 'December 17, 1995 ' + t . join ( ':' ) ) ) . toLocaleTimeString ( 'default' , {
hour : '2-digit' ,
minute : '2-digit' ,
second : '2-digit'
} ) ) ;
} , 1000 ) ;
} ) ;