Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 941 Rev 950
Line 1... Line 1...
1
/*+--------------------------------------------------------------------------------------------------------+*/
1
/*+--------------------------------------------------------------------------------------------------------+*/
2
// PARAMÊTRES et CONSTANTES
2
// PARAMÊTRES et CONSTANTES
3
// Mettre à true pour afficher les messages de débogage
3
// Mettre à true pour afficher les messages de débogage
4
var DEBUG = true; 
4
var DEBUG = false; 
5
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
5
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
6
var pointsOrigine = null;
6
var pointsOrigine = null;
7
var boundsOrigine = null;
7
var boundsOrigine = null;
8
var markerClusterer = null;
8
var markerClusterer = null;
9
var map = null;
9
var map = null;
Line 176... Line 176...
176
	if (depart == 0 || depart < total) {
176
	if (depart == 0 || depart < total) {
177
		var limite = 300;
177
		var limite = 300;
178
		if (depart == 0) {
178
		if (depart == 0) {
179
			obsStation = new Array();
179
			obsStation = new Array();
180
		}
180
		}
181
		console.log("Chargement de "+depart+" à "+(depart+limite));
181
		//console.log("Chargement de "+depart+" à "+(depart+limite));
182
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
182
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
183
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
183
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
184
		urlObs = urlObs.replace(/\{nt\}/g, nt);
184
		urlObs = urlObs.replace(/\{nt\}/g, nt);
185
		urlObs = urlObs.replace(/\{start\}/g, depart);
185
		urlObs = urlObs.replace(/\{start\}/g, depart);
Line 189... Line 189...
189
			if (depart == 0) {
189
			if (depart == 0) {
190
				actualiserInfosStation(observations);
190
				actualiserInfosStation(observations);
191
				actualiserPagineur();
191
				actualiserPagineur();
192
				creerTitreInfoBulle();
192
				creerTitreInfoBulle();
193
			}
193
			}
194
			console.log("Chargement ok");
194
			//console.log("Chargement ok");
195
			chargerObs(depart+limite, station.obsNbre);
195
			chargerObs(depart+limite, station.obsNbre);
196
		});
196
		});
197
	} else {
197
	} else {
198
		if (pagineur.limite < total) {
198
		if (pagineur.limite < total) {
199
			afficherPagination();
199
			afficherPagination();
Line 210... Line 210...
210
}
210
}
Line 211... Line 211...
211
 
211
 
212
function actualiserPagineur() {
212
function actualiserPagineur() {
213
	pagineur.stationId = pointClique.stationId;
213
	pagineur.stationId = pointClique.stationId;
214
	pagineur.total = station.obsNbre;
214
	pagineur.total = station.obsNbre;
215
	console.log("Total pagineur: "+pagineur.total);
215
	//console.log("Total pagineur: "+pagineur.total);
216
	if (pagineur.total > 4) {
216
	if (pagineur.total > 4) {
217
		pagineur.format = 'tableau';
217
		pagineur.format = 'tableau';
218
	} else {
218
	} else {
219
		pagineur.format = 'liste';
219
		pagineur.format = 'liste';
Line 296... Line 296...
296
function corrigerLargeurInfoWindow() {
296
function corrigerLargeurInfoWindow() {
297
	$("#info-bulle").width($("#info-bulle").width() - 16);
297
	$("#info-bulle").width($("#info-bulle").width() - 16);
298
}
298
}
Line 299... Line 299...
299
 
299
 
300
function surClicAffichageTableau(event) {
300
function surClicAffichageTableau(event) {
301
	console.log('tableau');
301
	//console.log('tableau');
302
	pagineur.format = 'tableau';
302
	pagineur.format = 'tableau';
303
	mettreAJourObservations();
303
	mettreAJourObservations();
304
	mettreAJourTableauTriable("#obs-tableau");
304
	mettreAJourTableauTriable("#obs-tableau");
Line 305... Line 305...
305
}
305
}
306
 
306
 
307
function surClicAffichageListe(event) {
307
function surClicAffichageListe(event) {
308
	console.log('liste');
308
	//console.log('liste');
309
	pagineur.format = 'liste';
309
	pagineur.format = 'liste';
310
	mettreAJourObservations();
310
	mettreAJourObservations();
Line 383... Line 383...
383
			var element = selectedArray[selectedIndex];
383
			var element = selectedArray[selectedIndex];
Line 384... Line 384...
384
 
384
 
385
			var motif = / contributeur-([0-9]+)$/;
385
			var motif = / contributeur-([0-9]+)$/;
386
			motif.exec($(element).attr('class'));
386
			motif.exec($(element).attr('class'));
387
			var id = RegExp.$1;
387
			var id = RegExp.$1;
388
			console.log('Destinataire id : '+id);
388
			//console.log('Destinataire id : '+id);
Line 389... Line 389...
389
			$("#fc_destinataire_id").attr('value', id);
389
			$("#fc_destinataire_id").attr('value', id);
390
		
390
		
391
			var motif = / obs-([0-9]+) /;
391
			var motif = / obs-([0-9]+) /;
392
			motif.exec($(element).attr('class'));
392
			motif.exec($(element).attr('class'));
393
			var id = RegExp.$1;
393
			var id = RegExp.$1;
394
			console.log('Obs id : '+id);
394
			//console.log('Obs id : '+id);
395
			chargerInfoObsPourMessage(id);
395
			chargerInfoObsPourMessage(id);
396
		},
396
		},
397
		onCleanup: function() {
397
		onCleanup: function() {
398
			console.log('Avant fermeture fancybox');
398
			//console.log('Avant fermeture fancybox');
399
			$("#fc_destinataire_id").attr('value', '');
399
			$("#fc_destinataire_id").attr('value', '');
400
			$("#fc_sujet").attr('value', '');
400
			$("#fc_sujet").attr('value', '');
401
			$("#fc_message").text('');
401
			$("#fc_message").text('');
402
		},
402
		},
403
		onClosed: function(e) {
403
		onClosed: function(e) {
404
			console.log('Fermeture fancybox');
404
			//console.log('Fermeture fancybox');
405
			if (e.stopPropagation) {
405
			if (e.stopPropagation) {
406
				e.stopPropagation();
406
				e.stopPropagation();
407
			}
407
			}
Line 419... Line 419...
419
	$("#fc_sujet").attr('value', sujet);
419
	$("#fc_sujet").attr('value', sujet);
420
	$("#fc_message").text(message);
420
	$("#fc_message").text(message);
421
}
421
}
Line 422... Line 422...
422
 
422
 
423
function initialiserFormulaireContact() {
423
function initialiserFormulaireContact() {
424
	console.log('Initialisation du form contact');
424
	//console.log('Initialisation du form contact');
425
	$("#form-contact").validate({
425
	$("#form-contact").validate({
426
		rules: {
426
		rules: {
427
			fc_sujet : "required",
427
			fc_sujet : "required",
428
			fc_message : "required",
428
			fc_message : "required",
429
			fc_courriel : {
429
			fc_courriel : {
430
			required : true,
430
			required : true,
431
			email : true}
431
			email : true}
432
		}
432
		}
433
	});
433
	});
434
	$("#form-contact").bind("submit", envoyerCourriel);
434
	$("#form-contact").bind("submit", envoyerCourriel);
Line 435... Line 435...
435
	$("#fc_annuler").bind("click", function() {console.log('clic annuler');$.fancybox.close();});
435
	$("#fc_annuler").bind("click", function() {$.fancybox.close();});
Line 436... Line 436...
436
	
436
	
437
}
437
}
438
 
438
 
439
function envoyerCourriel() {
439
function envoyerCourriel() {
440
	console.log('Formulaire soumis');
440
	//console.log('Formulaire soumis');
441
	if ($("#form-contact").valid()) {
441
	if ($("#form-contact").valid()) {
442
		console.log('Formulaire valide');
442
		//console.log('Formulaire valide');
443
		//$.fancybox.showActivity();
443
		//$.fancybox.showActivity();
444
		var destinataireId = $("#fc_destinataire_id").attr('value');
444
		var destinataireId = $("#fc_destinataire_id").attr('value');
445
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
445
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
446
		var erreurMsg = "";
446
		var erreurMsg = "";
447
		var donnees = new Array();
447
		var donnees = new Array();
448
		$.each($(this).serializeArray(), function (index, champ) {
448
		$.each($(this).serializeArray(), function (index, champ) {
449
			var cle = champ.name;
449
			var cle = champ.name;
450
			cle = cle.replace(/^fc_/, '');
450
			cle = cle.replace(/^fc_/, '');
451
			console.log('Clé:'+cle);
451
			//console.log('Clé:'+cle);
452
			donnees[index] = {'name':cle,'value':champ.value};
452
			donnees[index] = {'name':cle,'value':champ.value};
453
		});
453
		});
Line 492... Line 492...
492
							'</p>');
492
							'</p>');
493
				}
493
				}
494
				if (DEBUG) {
494
				if (DEBUG) {
495
					console.log('Débogage : '+debugMsg);
495
					console.log('Débogage : '+debugMsg);
496
				}
496
				}
497
				console.log('Débogage : '+debugMsg);
497
				//console.log('Débogage : '+debugMsg);
498
				console.log('Erreur : '+erreurMsg);
498
				//console.log('Erreur : '+erreurMsg);
499
			}
499
			}
500
		});
500
		});
501
	}
501
	}
502
	return false;
502
	return false;
503
}
503
}
Line 515... Line 515...
515
}
515
}
Line 516... Line 516...
516
 
516
 
517
function chargerTaxons(depart, total) {
517
function chargerTaxons(depart, total) {
518
	if (depart == 0 || depart < total) {
518
	if (depart == 0 || depart < total) {
519
		var limite = 7000;
519
		var limite = 7000;
520
		console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
520
		//console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
521
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
521
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
522
		urlTax = urlTax.replace(/\{start\}/g, depart);
522
		urlTax = urlTax.replace(/\{start\}/g, depart);
523
		$.getJSON(urlTax, function(infos) {
523
		$.getJSON(urlTax, function(infos) {
524
			taxonsCarte = taxonsCarte.concat(infos.taxons);
524
			taxonsCarte = taxonsCarte.concat(infos.taxons);
525
			console.log("Nbre taxons :"+taxonsCarte.length);
525
			//console.log("Nbre taxons :"+taxonsCarte.length);
526
			chargerTaxons(depart+limite, infos.total);
526
			chargerTaxons(depart+limite, infos.total);
527
		});
527
		});
528
	} else {
528
	} else {
529
		if (nt == '*') {
529
		if (nt == '*') {