Subversion Repositories eFlore/Applications.cel

Rev

Rev 3260 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3260 Rev 3271
Line 1... Line 1...
1
// configuration
1
// configuration
2
var urlRacine = window.location.origin;
2
var urlRacine = window.location.origin;
Line 3... Line 3...
3
 
3
 
-
 
4
$( document ).ready( function() {
4
$( document ).ready( function() {
5
  $( '#form-observateur' )[0].reset();
5
  var mode = $( '#tb-observateur' ).data( 'mode' ) || 'prod',
6
  var mode = $( '#tb-observateur' ).data( 'mode' ) || 'prod',
Line 6... Line 7...
6
      urlBaseAuth = urlRacine + '/service:annuaire:auth';
7
      urlBaseAuth = urlRacine + '/service:annuaire:auth';
7
 
8
 
Line 19... Line 20...
19
  var urlAuth = urlBaseAuth + '/identite';
20
  var urlAuth = urlBaseAuth + '/identite';
Line 20... Line 21...
20
 
21
 
21
  if( 'local' !== mode ) {
22
  if( 'local' !== mode ) {
22
    connexion( urlAuth, true );
23
    connexion( urlAuth, true );
23
  } else {
24
  } else {
24
    urlAuth = urlRacine + '/widget:cel:modules/apa/test-token.json';
25
    urlAuth = urlRacine + '/widget:cel:modules/saisie2/test-token.json';
25
    $( '#connexion' ).click( function() {
26
    $( '#connexion' ).click( function() {
26
      connexion( urlAuth, true );
27
      connexion( urlAuth, true );
27
      return false;
28
      return false;
28
    });
29
    });
Line 67... Line 68...
67
    // dans l'interface actuelle sans que ce soit moche
68
    // dans l'interface actuelle sans que ce soit moche
68
    //afficherErreurServeur();
69
    //afficherErreurServeur();
69
  });
70
  });
70
}
71
}
Line 71... Line -...
71
 
-
 
72
 
72
 
73
function definirUtilisateur( jeton ) {
73
function definirUtilisateur( jeton ) {
74
  var idUtilisateur = '',
74
  var idUtilisateur = '',
75
      nomComplet    = '',
75
      nomComplet    = '',
-
 
76
      courriel      = '',
76
      courriel      = '',
77
      pseudo        = '',
77
      prenom        = '',
78
      prenom        = '',
Line 78... Line 79...
78
      nom           = '';
79
      nom           = '';
79
 
80
 
80
  // affichage
81
  // affichage
81
  if ( undefined !== jeton ) {
82
  if ( undefined !== jeton ) {
82
    // décodage jeton
83
    // décodage jeton
Line 83... Line 84...
83
    var jetonDecode = decoderJeton( jeton );
84
    var jetonDecode = decoderJeton( jeton );
84
    // console.log(jetonDecode);
85
    console.log(jetonDecode);
85
 
86
 
-
 
87
    idUtilisateur = jetonDecode.id;
86
    idUtilisateur = jetonDecode.id;
88
    nomComplet    = jetonDecode.intitule;
87
    nomComplet    = jetonDecode.intitule;
89
    courriel      = jetonDecode.sub;
88
    courriel      = jetonDecode.sub;
90
    pseudo        = jetonDecode.pseudo;
89
    prenom        = jetonDecode.prenom;
91
    prenom        = jetonDecode.prenom;
90
    nom           = jetonDecode.nom;
92
    nom           = jetonDecode.nom;
Line 96... Line 98...
96
    $( '#date-releve' ).focus();
98
    $( '#date-releve' ).focus();
97
  }
99
  }
98
  $( '.warning' ).remove();
100
  $( '.warning' ).remove();
99
  $( '#nom-complet' ).html( nomComplet );
101
  $( '#nom-complet' ).html( nomComplet );
100
  $( '#courriel, #courriel_confirmation' ).val( courriel );
102
  $( '#courriel, #courriel_confirmation' ).val( courriel );
-
 
103
  $( '#profil-utilisateur a' ).attr( 'href', urlProfilUtilisateur( pseudo ) );
101
  $( '#id_utilisateur' ).val( idUtilisateur );
104
  $( '#id_utilisateur' ).val( idUtilisateur );
102
  $( '#prenom' ).val( prenom );
105
  $( '#prenom' ).val( prenom );
103
  $( '#nom' ).val( nom );
106
  $( '#nom' ).val( nom );
104
}
107
}
Line 130... Line 133...
130
  }
133
  }
131
  input = input.replace( '-', '+' );
134
  input = input.replace( '-', '+' );
132
  input = input.replace( '_', '/' );
135
  input = input.replace( '_', '/' );
133
  return atob( input );
136
  return atob( input );
134
}
137
}
-
 
138
 
-
 
139
function urlProfilUtilisateur( pseudo ) {
-
 
140
  var mode = $( '#tb-observateur' ).data( 'mode' ) || 'prod';
-
 
141
  var urlPart = ( 'prod' === mode ) ? 'www.tela-botanica.org/' : 'beta.tela-botanica.org/test/';
-
 
142
 
-
 
143
  return 'https://' + urlPart + 'membres/' + pseudo.toLowerCase().replace( ' ', '-' );
-
 
144
}