Subversion Repositories wimsdev

Rev

Rev 13573 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13400 obado 1
/* Display a warning to the connected user when his session is about to close */
2
 
3
/**  var swarn_sessionAlive = must be set to the actual session delay */
4
var swarn_notifyBefore = 60; // Give client these seconds to choose.
5
var swarn_rtick=swarn_notifyBefore;
6
var swarn_enterDate=null;
7
 
8
$(function() {
9
  console.log("session close in "+swarn_sessionAlive+"s...");
10
  setTimeout(function() {
11
    console.log("session close in "+swarn_notifyBefore+"s...");
12
    $("#sess_dialog1").dialog({
13
      autoOpen: true,
14
      hide: 'fold',
15
      show: 'fade',
16
      modal: true,
17
      open: function(event, ui) {
18
          // On décompte les swarn_notifyBefore secondes restantes
19
          Timer= setTimeout("swarn_clock(1000)",1000);
20
      },
21
    });
22
  }, (swarn_sessionAlive - swarn_notifyBefore) * 1000);
23
});
24
 
25
/** Compte le nombre de secondes écoulées depuis startDate **/
26
function swarn_tempo(startDate) {
27
  now=new Date();
28
  return Math.ceil((now.getTime()-startDate.getTime())/1000);
29
}
30
 
31
/** Affiche un décompte depuis la valeur "swarn_notifyBefore" jusqu'à 0,
32
    en rafraichissant tous les "interval"
33
    le texte de l'élément "#js_session_timer" **/
34
function swarn_clock() {
35
  if (swarn_enterDate==null){
36
    swarn_enterDate=new Date()
37
  }
38
  document.getElementById("js_session_timer").innerHTML=swarn_rtick;
39
  swarn_rtick=swarn_notifyBefore-swarn_tempo(swarn_enterDate);
40
  if(swarn_rtick<0){
41
    swarn_rtick=0;
42
    $("#sess_dialog1").dialog('close')
43
    $("#sess_dialog2").dialog({
44
      autoOpen: true,
45
      modal: true,
46
      show: {effect: 'bounce', duration: 350, /* SPECIF ARGUMENT */ times: 3}
47
    });
48
 
49
  }else{
50
    Timer= setTimeout("swarn_clock(1000)",1000);
51
  }
52
}