Subversion Repositories eFlore/Applications.cel

Rev

Rev 1344 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1244 jpm 1
//+----------------------------------------------------------------------------------------------------------+
2
// Initialisation de Jquery mobile
1552 isa 3
$(document).bind('mobileinit', function() {
4
	$.mobile.defaultPageTransition = 'fade';
1244 jpm 5
});
1552 isa 6
$(document).on('online', function(event) {
7
	console.log('online');
8
	miseAJourObs();
9
});
1244 jpm 10
//+----------------------------------------------------------------------------------------------------------+
1552 isa 11
// Gestion des paramètres URL
12
$.urlParam = function(name){
13
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
14
	return decodeURIComponent(results[1]) || 0;
15
}
16
function recupererParametresUrl() {
17
	$('#referentiel').val($.urlParam('ref'));
18
	$('#nom').val($.urlParam('nom_sci'));
19
	$('#nom-sci-select').val($.urlParam('nom_sci'));
20
	$('#num-nom-select').val($.urlParam('num_nom'));
21
}
1244 jpm 22
$(document).ready(function() {
1552 isa 23
	$('body').on('pageshow', '#saisie', function(event) {
24
		obtenirPosition(event);
25
		recupererParametresUrl();
26
	});
27
	$('#geolocaliser').on('click', obtenirPosition);
28
 
29
	$('body').on('pageshow', '#infos', obtenirDate);
1244 jpm 30
});
1552 isa 31
//+----------------------------------------------------------------------------------------------------------+
32
// Géolocalisation et date du jour
33
var gps = navigator.geolocation;
1244 jpm 34
 
1552 isa 35
function obtenirPosition(event) {
36
	event.stopImmediatePropagation();
37
	event.stopPropagation();
38
	event.preventDefault();
39
 
40
	obtenirDate();
41
	geolocaliser();
42
}
43
function geolocaliser() {
1244 jpm 44
	if (gps) {
45
	    navigator.geolocation.getCurrentPosition(surSuccesGeoloc, surErreurGeoloc);
46
	} else {
1552 isa 47
	    var erreur = {code:'0', message: 'Géolocalisation non supportée par le navigateur'};
1244 jpm 48
	    surErreurGeoloc(erreur);
49
	}
50
}
51
function surSuccesGeoloc(position){
1552 isa 52
	if (position) {
53
		var lat = position.coords.latitude;
54
		var lng = position.coords.longitude;
55
		$('#lat').html(lat);
56
		$('#lng').html(lng);
57
 
58
		console.log('Geolocation SUCCESS');
59
		var url_service = SERVICE_NOM_COMMUNE_URL;
60
		var urlNomCommuneFormatee = url_service.replace('{lat}', lat).replace('{lon}', lng);
61
		var jqxhr = $.getJSON(urlNomCommuneFormatee, function(data) {
62
			console.log('NOM_COMMUNE found.');
63
			$('#location').html(data['nom']);
64
			$('#code_insee').val(data['codeINSEE']);
65
		})
66
		.complete(function() {
67
			var texte = ($('#location').html() == '') ? TEXTE_HORS_LIGNE : $('#location').html();
68
			$('#location').html(texte);
69
		})
70
		;
71
	}
1244 jpm 72
}
73
function surErreurGeoloc(error){
1552 isa 74
	alert('Echec de la géolocalisation, code: ' + error.code + ' message: '+ error.message);
1244 jpm 75
}
1552 isa 76
 
77
function obtenirDate() {
78
	var d = new Date();
79
	var jour = d.getDate();
80
	var mois = d.getMonth()+1;
81
	var annee = d.getFullYear();
82
	var aujourdhui =
83
		( (''+jour).length < 2 ? '0' : '') + jour + '/' +
84
		( (''+mois).length < 2 ? '0' : '') + mois + '/' +
85
		annee;
86
	$('#date').val(aujourdhui);
87
	$('#annee').html(annee);
88
}
1244 jpm 89
//+----------------------------------------------------------------------------------------------------------+
90
// Local Storage
91
$(document).ready(function() {
92
	$('#sauver-obs').on('click', ajouterObs);
1552 isa 93
	$('#valider_photos').on('click', ajoutPhoto);
1244 jpm 94
	$('body').on('pageshow', '#liste', chargerListeObs);
1552 isa 95
	$('body').on('pageshow', '#transmission', miseAJourObs);
1244 jpm 96
});
97
 
1552 isa 98
var bdd = window.localStorage,
99
	index_obs = (bdd.getItem('index_obs') == null) ? 1 : bdd.getItem('index_obs'),
100
	index_photos = (bdd.getItem('index_photos') == null) ? 1 : bdd.getItem('index_photos');
101
alert('space used:'+JSON.stringify(bdd).length);
102
//bdd.clear();
103
 
104
console.log(bdd);
1244 jpm 105
function ajouterObs(event) {
1552 isa 106
	if ($('#nom').val() != '') {
107
		var obs = {
108
			num:TEXTE_OBS,
109
			maj:0,
110
			date:'',
111
			referentiel:'',
112
			lat:'', lng:'',
113
			commune:'', code_insee: 0,
114
			nom:'',
115
			nom_sci_selec:'',
116
			nn_select:'',
117
			nom_sci_retenu:'',
118
			nn_retenu:'',
119
			num_taxon:'',
120
			famille:''
121
		};
122
 
123
		obs.num += index_obs++;
124
		obs.date = $('#date').val();
125
		obs.referentiel = $('#referentiel').val();
126
		obs.lat = $('#lat').html();
127
		obs.lng = $('#lng').html();
128
		obs.commune = $('#location').html();
129
		obs.code_insee = $('#code_insee').val();
130
		obs.nom = $('#nom').val();
131
		obs.referentiel = $('#referentiel').val();
132
		obs.nom_sci_selec = $('#nom_sci_select').val();
133
		obs.nn_select = $('#num_nom_select').val();
134
 
135
		var cle = obs.num;
136
		sauvegarderObs(cle, obs);
137
		bdd.setItem('index_obs', index_obs);
138
	/*
139
		var txt = 'Observation n°'+obs.num+'/'+bdd.length+' créée';
140
		$('#obs-saisie-infos').html('<p class="reponse ui-btn-inner ui-btn-corner-all">'+txt+'</p>')
141
			.fadeIn("slow")
142
			.delay(1600)
143
			.fadeOut("slow");
144
	*/
145
		$.mobile.changePage('#liste');
146
		effacerFormulaire();
147
		event.stopPropagation();
148
		event.preventDefault();
149
	} else {
150
		$.mobile.changePage('#saisie');
151
		event.stopPropagation();
152
		event.preventDefault();
153
	}
154
}
155
 
156
function sauvegarderObs(cle, obs) {
1244 jpm 157
	var val = JSON.stringify(obs);
1552 isa 158
 
159
	alert('space used:'+JSON.stringify(bdd).length+'_'+(JSON.stringify(bdd).length+val.length));
1244 jpm 160
	bdd.setItem(cle, val);
1552 isa 161
}
162
 
163
function effacerFormulaire() {
164
	$('#lat').html('');
165
	$('#lng').html('');
166
	$('#location').html('');
167
}
168
 
169
function chargerListeObs() {
170
	$('#liste_obs').empty();
1244 jpm 171
 
1552 isa 172
	var nbre = bdd.length;
173
	for (var i = 0; i < nbre; i++) {
174
		var cle = bdd.key(i);
175
		if (cle.indexOf(TEXTE_OBS) !== -1) {
176
			var obs = JSON.parse(bdd.getItem(cle));
177
			console.log(obs);
178
			$('#liste_obs').prepend(
179
				'<li>'+
180
					obs.num + ' (Nbre photos : ' + compterPhotos(obs.num) + ')<br />' +
181
					'<a href="#" onclick="detailsObs(this);" data-split-icon="next" data-split-theme="a" title="Voir la fiche" data-obs-num="'+obs.num+'">'+
182
						'<strong>'+obs.nom+'</strong> <br />'+obs.date+' à '+obs.commune+
183
					'</a>'+
184
					'<a href="#" onclick="supprimerObs(this);" title="Supprimer l\'observation" ' +
185
						'data-obs-num="'+obs.num+'">'+
186
						'Supprimer'+
187
					'</a>'+
188
				'</li>'
189
			);
190
		}
191
		$('#liste_obs').listview('refresh');
192
	}
193
}
194
 
195
function compterPhotos(num_obs) {
196
	var compteur = 0;
197
	if (num_obs != '') {
198
		var nbre = bdd.length;
199
		for (var i = 0; i < nbre; i++) {
200
			var cle = bdd.key(i);
201
			if (cle.indexOf(TEXTE_PHOTO) !== -1) {
202
				var photo = JSON.parse(bdd.getItem(cle));
203
				if (photo.parent == num_obs) {
204
					compteur++;
205
				}
206
			}
207
		}
208
	}
209
	return compteur;
210
}
211
 
212
function supprimerObs(data) {
213
	var cle_obs = data.getAttribute('data-obs-num'),
214
		obs = JSON.parse(bdd.getItem(cle_obs)),
215
		nbre = bdd.length,
216
		a_supprimer = new Array();
217
	for (var i = 0; i < nbre; i++) {
218
		var cle = bdd.key(i);
219
		if (cle.indexOf(TEXTE_PHOTO) !== -1) {
220
			var photo = JSON.parse(bdd.getItem(cle));
221
			if (photo.parent == obs.num) {
222
				a_supprimer.push(photo.num);
223
			}
224
		}
225
	}
226
	for (var c = 0; c < a_supprimer.length; c++) {
227
		bdd.removeItem(a_supprimer[c]);
228
	}
229
	bdd.removeItem(cle_obs);
230
 
231
	var txt = obs.num + ' supprimée.';
232
	$('#obs-suppression-infos').html('<p class="reponse ui-btn-inner ui-btn-corner-all">'+txt+'</p>')
233
		.fadeIn(0)
1248 jpm 234
		.delay(1600)
1552 isa 235
		.fadeOut('slow');
1248 jpm 236
 
1552 isa 237
	chargerListeObs();
1244 jpm 238
}
239
 
1552 isa 240
function detailsObs(data) {
241
	var num_obs = data.getAttribute('data-obs-num');
242
	var obs = JSON.parse(bdd.getItem(num_obs));
243
	$('#id_obs').html(obs.num);
1248 jpm 244
 
1552 isa 245
	var texte = '<strong>' + obs.nom + '</strong> vue le ' + obs.date;
246
	texte += (obs.commune == TEXTE_HORS_LIGNE ||  obs.commune == '') ? '' :  ' <br /> à ' + obs.commune;
247
	$('#details_obs').html(texte);
248
	$.mobile.changePage('#observation');
249
	afficherPhotos(obs.num);
250
}
251
 
252
function ajoutPhoto() {
253
	var id_obs = $('#id_obs').html();
254
	if (id_obs != '') {
255
		$.each($('#pic').get(0).files, function(index, valeur) {
256
			var reader = new FileReader(),
257
				binary, base64;
258
			reader.addEventListener('loadend', function (evt) {
259
				binary = reader.result; // binary data (stored as string), unsafe for most actions
260
				base64 = btoa(binary); 	// base64 data, safer but takes up more memory
261
 
262
				var photo = {
263
					num:TEXTE_PHOTO,
264
					nom: '',
265
					parent:'',
266
					base64:0
267
				};
268
				photo.num += index_photos++;
269
				photo.nom = valeur.name;
270
				photo.parent = id_obs;
271
				photo.base64 = base64;
272
 
273
				var cle = photo.num;
274
				sauvegarderObs(cle, photo);
275
				bdd.setItem('index_photos', index_photos);
276
				afficherPhotos(id_obs);
277
			}, false);
278
			reader.readAsBinaryString(valeur);
279
		});
280
	}
281
}
282
 
283
function afficherPhotos(num_obs) {
284
	$('#pic').val('');
285
	$('#photos_obs').empty();
286
	if (num_obs != '') {
287
		var nbre = bdd.length;
288
		for (var i = 0; i < nbre; i++) {
289
			var cle = bdd.key(i);
290
			if (cle.indexOf(TEXTE_PHOTO) !== -1) {
291
				var photo = JSON.parse(bdd.getItem(cle));
292
				if (photo.parent == num_obs) {
293
					$('#photos_obs').prepend(
294
						'<li>'+
295
							'<a href="#'+photo.num+'" data-rel="popup" data-role="button" data-inline="true">' +
296
								'<img src="data:image/png;base64,' + photo.base64 + '" />' +
297
								photo.nom +
298
							'</a>' +
299
							'<a href="#" onclick="supprimerPhoto(this);" title="Supprimer la photo" ' +
300
								'data-icon="delete" data-photo-num="' + photo.num + '"' +
301
								'data-photo-parent="' + num_obs + '" data-theme="c">'+
302
								'Supprimer cette photo'+
303
							'</a>'+
304
						'</li>'
305
					);
306
				}
307
			}
308
			$('#photos_obs').listview('refresh');
309
		}
310
	}
311
}
312
 
313
function compterPhotos(num_obs) {
314
	var compteur = 0;
315
	if (num_obs != '') {
316
		var nbre = bdd.length;
317
		for (var i = 0; i < nbre; i++) {
318
			var cle = bdd.key(i);
319
			if (cle.indexOf(TEXTE_PHOTO) !== -1) {
320
				var photo = JSON.parse(bdd.getItem(cle));
321
				if (photo.parent == num_obs) {
322
					compteur++;
323
				}
324
			}
325
		}
326
	}
327
	return compteur;
328
}
329
 
330
function supprimerPhoto(data) {
331
	var cle_photo = data.getAttribute('data-photo-num'),
332
		parent = data.getAttribute('data-photo-parent'),
333
		photo = JSON.parse(bdd.getItem(cle_photo));
334
	bdd.removeItem(cle_photo);
335
 
336
	var txt = photo.num + ' supprimée.';
337
	$('#photo-suppression-infos').html('<p class="reponse ui-btn-inner ui-btn-corner-all">'+txt+'</p>')
338
		.fadeIn(0)
1248 jpm 339
		.delay(1600)
1552 isa 340
		.fadeOut('slow');
1248 jpm 341
 
1552 isa 342
	afficherPhotos(parent);
1248 jpm 343
}
344
 
1552 isa 345
function miseAJourObs() {
346
	console.log('majObs');
1244 jpm 347
	var nbre = bdd.length;
348
	for (var i = 0; i < nbre; i++) {
1552 isa 349
		var cle = bdd.key(i);
350
		if (cle.indexOf(TEXTE_OBS) !== -1) {
351
			var obs = JSON.parse(bdd.getItem(cle));
352
 
353
			if (obs.maj == 0) {
354
				var maj = 1;
355
 
356
				if (obs.commune == TEXTE_HORS_LIGNE ||  obs.commune == '') {
357
					var url_service = SERVICE_NOM_COMMUNE_URL;
358
					var urlNomCommuneFormatee = url_service.replace('{lat}', lat).replace('{lon}', lng);
359
					jQuery.ajax({
360
						url: urlNomCommuneFormatee,
361
						success: function(data) {
362
							obs.commune = data['nom'];
363
							obs.code_insee = data['codeINSEE'];
364
						 },
365
						 error: function() {
366
							 maj = 0;
367
						 },
368
						async: false
369
				   });
370
				}
371
 
372
				if (obs.nom_sci_retenu == '') {
373
					jQuery.ajax({
374
						url:	'/service:eflore:0.1/' + obs.referentiel + '/noms?'
375
								 + 'masque.nn=' + obs.nn_select
376
								 + '&retour.champs=num_taxonomique',
377
						success: function(data) {
378
							var cle = '',
379
								compteur = 0;
380
							for (name in data['resultat']) {
381
								if (compteur == 0) {
382
									cle = name;
383
								}
384
								compteur++;
385
							}
386
							obs.num_taxon = data['resultat'][cle]['num_taxonomique'];
387
							jQuery.ajax({
388
								url: 	'/service:eflore:0.1/' + obs.referentiel + '/noms?'
389
										 + 'masque.nt=' + obs.num_taxon
390
										 + '&retour.champs=famille'
391
										 + '&retour.tri=retenu',
392
								success: function(data) {
393
									var cle = '',
394
										compteur = 0;
395
									for (name in data['resultat']) {
396
										if (compteur == 0) {
397
											cle = name;
398
										}
399
										compteur++;
400
									}
401
									obs.famille = data['resultat'][cle]['famille'];
402
									obs.nom_sci_retenu = data['resultat'][cle]['nom_sci'];
403
									obs.nn_retenu = cle;
404
								 },
405
								 error: function() {
406
									 maj = 0;
407
								 },
408
								async:   false
409
							});
410
						 },
411
						async:   false
412
					});
413
				}
414
 
415
				obs.maj = maj;
416
			}
417
 
418
			sauvegarderObs(obs.num, obs);
419
		}
1244 jpm 420
	}
421
}
422
 
1552 isa 423
function transmettreObs() {
424
	if ($('#courriel').val() == $('#courriel_confirmation').val() && $('#courriel').val() != '') {
425
		var nbre = bdd.length;
426
		for (var i = 0; i < nbre; i++) {
427
			var cle = bdd.key(i);
428
			if (cle.indexOf('obs') !== -1) {
429
				var obs = JSON.parse(bdd.getItem(cle));
430
				stockerObsData(obs);
431
			}
432
		}
433
		var observations = $('#details_obs').data();
434
		console.log(observations);
435
 
436
		if (observations == undefined || jQuery.isEmptyObject(observations)) {
437
			//afficherPanneau("#dialogue-zero-obs");
438
		} else {
439
			observations['projet'] = TAG_PROJET;
440
			observations['tag-obs'] = '';
441
			observations['tag-img'] = '';
442
 
443
			var utilisateur = new Object();
444
			utilisateur.id_utilisateur = $('#id_utilisateur').val();
445
			utilisateur.prenom = $('#prenom_utilisateur').val();
446
			utilisateur.nom = $('#nom_utilisateur').val();
447
			utilisateur.courriel = $('#courriel').val();
448
			observations['utilisateur'] = utilisateur;
449
			envoyerObsAuCel(observations);
450
		}
451
	}
452
}
1244 jpm 453
 
1552 isa 454
function stockerObsData(obs) {
455
	var nbre = bdd.length,
456
		img_noms = new Array(),
457
		img_codes = new Array();
458
	for (var i = 0; i < nbre; i++) {
459
		var cle = bdd.key(i);
460
		if (cle.indexOf(TEXTE_PHOTO) !== -1) {
461
			var photo = JSON.parse(bdd.getItem(cle));
462
			if (photo.parent == obs.num) {
463
				img_noms.push(photo.nom);
464
				img_codes.push(photo.base64);
465
			}
466
		}
467
	}
468
 
469
	$('#details_obs').data(obs.num, {
470
		'date' : obs.date,
471
		'notes' : '',
472
 
473
		'nom_sel' : obs.nom,
474
		'num_nom_sel' : obs.nn_select,
475
		'nom_ret' : obs.nom_sci_retenu,
476
		'num_nom_ret' : obs.nn_retenu,
477
		'num_taxon' : obs.num_taxon,
478
		'famille' : obs.famille,
479
		'referentiel' : obs.referentiel,
480
 
481
		'latitude' : obs.lat,
482
		'longitude' : obs.lng,
483
		'commune_nom' : obs.commune,
484
		'commune_code_insee' : obs.code_insee,
485
		'lieudit' : '',
486
		'station' : '',
487
		'milieu' : '',
488
 
489
		//Ajout des champs images
490
		'image_nom' : img_noms,
491
		'image_b64' : img_codes
492
	});
493
}
494
 
495
 
496
function envoyerObsAuCel(observations) {
497
/*
498
	var erreurMsg = "";
499
	$.ajax({
500
		url : SERVICE_SAISIE_URL,
501
		type : "POST",
502
		data : observations,
503
		dataType : "json",
504
		beforeSend : function() {
505
			$("#dialogue-obs-transaction-ko").hide();
506
			$("#dialogue-obs-transaction-ok").hide();
507
			$(".alert-txt .msg").remove();
508
			$(".alert-txt .msg-erreur").remove();
509
			$(".alert-txt .msg-debug").remove();
510
			$("#chargement").show();
511
		},
512
		success : function(data, textStatus, jqXHR) {
513
			$('#dialogue-obs-transaction-ok .alert-txt').append($("#tpl-transmission-ok").clone().html());
514
			supprimerMiniatures();
515
		},
516
		statusCode : {
517
			500 : function(jqXHR, textStatus, errorThrown) {
518
				erreurMsg += "Erreur 500 :\ntype : "+textStatus+' '+errorThrown+"\n";
519
		    }
520
		},
521
		error : function(jqXHR, textStatus, errorThrown) {
522
			erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n";
523
			try {
524
				reponse = jQuery.parseJSON(jqXHR.responseText);
525
				if (reponse != null) {
526
					$.each(reponse, function (cle, valeur) {
527
						erreurMsg += valeur + "\n";
528
					});
529
				}
530
			} catch(e) {
531
				erreurMsg += "L'erreur n'était pas en JSON.";
532
			}
533
		},
534
		complete : function(jqXHR, textStatus) {
535
			$("#chargement").hide();
536
			var debugMsg = extraireEnteteDebug(jqXHR);
537
 
538
			if (erreurMsg != '') {
539
				if (DEBUG) {
540
					$("#dialogue-obs-transaction-ko .alert-txt").append('<pre class="msg-erreur">'+erreurMsg+'</pre>');
541
					$("#dialogue-obs-transaction-ko .alert-txt").append('<pre class="msg-debug">Débogage : '+debugMsg+'</pre>');
542
				}
543
				var hrefCourriel = "mailto:cel@tela-botanica.org?"+
544
					"subject=Disfonctionnement du widget de saisie "+TAG_PROJET+
545
					"&body="+erreurMsg+"\nDébogage :\n"+debugMsg;
546
 
547
				$('#dialogue-obs-transaction-ko .alert-txt').append($("#tpl-transmission-ko").clone()
548
					.find('.courriel-erreur')
549
					.attr('href', hrefCourriel)
550
					.end()
551
					.html());
552
				$("#dialogue-obs-transaction-ko").show();
553
			} else {
554
				if (DEBUG) {
555
					$("#dialogue-obs-transaction-ok .alert-txt").append('<pre class="msg-debug">Débogage : '+debugMsg+'</pre>');
556
				}
557
				$("#dialogue-obs-transaction-ok").show();
558
			}
559
			initialiserObs();
560
		}
561
	});
562
*/
563
}
564
 
1244 jpm 565
//+----------------------------------------------------------------------------------------------------------+
566
// Manifest Cache
567
var appCache = window.applicationCache;
568
$(document).ready(function() {
569
	appCache.addEventListener('updateready', function() {
570
		alert('Mise à jour :'+appCache.status);
1552 isa 571
	});
1244 jpm 572
	if (appCache.status === appCache.UPDATEREADY) {
573
		surMiseAJourCache();
574
	}
575
});
576
 
577
function surMiseAJourCache() {
578
	// Browser downloaded a new app cache.
1552 isa 579
	// Swap it in and reload the page to get the new hotness.
1244 jpm 580
	appCache.swapCache();
1552 isa 581
	if (confirm('A new version of this site is available. Load it ?')) {
582
		window.location.reload();
583
	}
584
}
585
 
586
 
587
//+----------------------------------------------------------------------------------------------------------+
588
//Transmission données
589
function verifierConnexion() {
590
	return ( ('onLine' in navigator) && (navigator.onLine));
591
}
592
 
593
//+---------------------------------------------------------------------------------------------------------+
594
//IDENTITÉ
595
$(document).ready(function() {
596
	$('#courriel').on('blur', requeterIdentite);
597
	$('#courriel').on('keypress', function(event) {
598
		if (event.which == 13) {
599
			testerLancementRequeteIdentite(event);
600
		}
601
	});
602
	$('#valider_courriel').on('vmousedown', testerLancementRequeteIdentite);
603
	$('body').on('pageshow', '#transmission', testerLancementRequeteIdentite);
604
});
605
 
606
function testerLancementRequeteIdentite(event) {
607
	if (bdd.getItem('courriel') != null) {
608
		$('#courriel').val(bdd.getItem('courriel'));
609
	}
610
 
611
	requeterIdentite();
612
	event.preventDefault();
613
	event.stopPropagation();
614
}
615
 
616
function requeterIdentite() {
617
	var courriel = $('#courriel').val();
618
	if (courriel != '') {
619
		miseAJourCourriel();
620
		var urlAnnuaire = SERVICE_ANNUAIRE + courriel;	//http://localhost/applications/annuaire/jrest/
621
		$.ajax({
622
			url : urlAnnuaire,
623
			type : 'GET',
624
			success : function(data, textStatus, jqXHR) {
625
				console.log('Annuaire SUCCESS : ' + textStatus);
626
				if (data != undefined && data[courriel] != undefined) {
627
					var infos = data[courriel];
628
					$('#id_utilisateur').val(infos.id);
629
					$('#prenom_utilisateur').val(infos.prenom);
630
					$('#nom_utilisateur').val(infos.nom);
631
					$('#courriel_confirmation').val(courriel);
632
					$('#prenom_utilisateur, #nom_utilisateur, #courriel_confirmation').attr('disabled', 'disabled');
633
				} else {
634
					surErreurCompletionCourriel();
635
				}
636
			},
637
			error : function(jqXHR, textStatus, errorThrown) {
638
				console.log('Annuaire ERREUR : ' + textStatus);
639
				surErreurCompletionCourriel();
640
			},
641
			complete : function(jqXHR, textStatus) {
642
				console.log('Annuaire COMPLETE : ' + textStatus);
643
				$('#zone_prenom_nom').removeClass('hidden');
644
				$('#zone_courriel_confirmation').removeClass('hidden');
645
			}
646
		});
647
	}
648
}
649
 
650
function surErreurCompletionCourriel() {
651
	$('#prenom_utilisateur, #nom_utilisateur, #courriel_confirmation').val('');
652
	$('#prenom_utilisateur, #nom_utilisateur, #courriel_confirmation').removeAttr('disabled');
653
}
654
 
655
function miseAJourCourriel() {
656
	if ($('#courriel_memoire').is(':checked')) {
657
		bdd.setItem('courriel',  $("#courriel").val());
658
	}
659
}