Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 915 Rev 939
Line 33... Line 33...
33
});
33
});
34
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
34
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
35
var station = {'commune':'', 'obsNbre':0};
35
var station = {'commune':'', 'obsNbre':0};
36
var obsStation = new Array();
36
var obsStation = new Array();
37
var obsPage = new Array();
37
var obsPage = new Array();
-
 
38
var taxonsCarte = new Array();
38
/*+--------------------------------------------------------------------------------------------------------+*/
39
/*+--------------------------------------------------------------------------------------------------------+*/
39
// INITIALISATION DU CODE
40
// INITIALISATION DU CODE
Line 40... Line 41...
40
 
41
 
41
//Déclenchement d'actions quand JQuery et le document HTML sont OK
42
//Déclenchement d'actions quand JQuery et le document HTML sont OK
Line 57... Line 58...
57
/*+--------------------------------------------------------------------------------------------------------+*/
58
/*+--------------------------------------------------------------------------------------------------------+*/
58
// AFFICHAGE GÉNÉRAL
59
// AFFICHAGE GÉNÉRAL
Line 59... Line 60...
59
 
60
 
60
function afficherStats() {
61
function afficherStats() {
61
	// Ajout du nombre de communes où des observations ont eu lieu
62
	// Ajout du nombre de communes où des observations ont eu lieu
62
	$('#commune-nbre').append(obs.stats.communes.formaterNombre());
63
	$('#commune-nbre').text(stations.stats.communes.formaterNombre());
63
	// Ajout du nombre d'observations
64
	// Ajout du nombre d'observations
64
	$('#obs-nbre').append(obs.stats.observations.formaterNombre());
-
 
65
	// Ajout du nombre de plantes
-
 
66
	$('.plantes-nbre').append(plantesNbre.formaterNombre());
65
	$('#obs-nbre').text(stations.stats.observations.formaterNombre());
Line 67... Line 66...
67
}
66
}
68
 
67
 
Line 96... Line 95...
96
}
95
}
Line 97... Line 96...
97
 
96
 
98
function rafraichirCarte() {
97
function rafraichirCarte() {
99
	var points = [];
98
	var points = [];
100
	var bounds = new google.maps.LatLngBounds();
99
	var bounds = new google.maps.LatLngBounds();
101
	for (var i = 0; i < obs.stats.communes; ++i) {
100
	for (var i = 0; i < stations.stats.communes; ++i) {
102
		var maLatLng = new google.maps.LatLng(obs.points[i].coord_x, obs.points[i].coord_y);
101
		var maLatLng = new google.maps.LatLng(stations.points[i].coord_x, stations.points[i].coord_y);
103
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
102
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
104
		var point = new google.maps.Marker({
103
		var point = new google.maps.Marker({
105
			position: maLatLng,
104
			position: maLatLng,
106
			map: map,
105
			map: map,
107
			icon: pointImage,
106
			icon: pointImage,
108
			stationId: obs.points[i].id
107
			stationId: stations.points[i].id
Line 109... Line 108...
109
		});
108
		});
Line 110... Line 109...
110
 
109
 
Line 119... Line 118...
119
			var nordEst = limites.getNorthEast();
118
			var nordEst = limites.getNorthEast();
120
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
119
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
121
			map.panTo(centreSudLatLng);
120
			map.panTo(centreSudLatLng);
Line 122... Line 121...
122
			
121
			
123
			afficherInfoBulle();
122
			afficherInfoBulle();
124
			lancerChargementObs();
123
			chargerObs(0, 0);
Line 125... Line 124...
125
		});
124
		});
126
		
125
		
Line 168... Line 167...
168
 
167
 
169
function supprimerMessageChargement() {
168
function supprimerMessageChargement() {
170
	$('#chargement').remove();
169
	$('#chargement').remove();
Line 171... Line -...
171
}
-
 
172
 
-
 
173
function lancerChargementObs() {
-
 
174
	var urlObsNbre = urlObsStation;
-
 
175
	urlObsNbre = urlObsNbre.replace(/\{action\}/g, 'observations-nombre');
-
 
176
	urlObsNbre = urlObsNbre.replace(/\{stationId\}/g, pointClique.stationId);
-
 
177
	console.log("Lancement recup nombre");
-
 
178
	$.getJSON(urlObsNbre, function(infos){
-
 
179
		console.log("Lancement charger obs");
-
 
180
		chargerObs(0, infos.obsNbre);
-
 
181
		station = infos;
-
 
182
		actualiserPagineur();
-
 
183
		creerTitreInfoBulle();
-
 
184
	});
-
 
185
}
-
 
186
 
-
 
187
function actualiserPagineur() {
-
 
188
	pagineur.stationId = pointClique.stationId;
-
 
189
	pagineur.total = station.obsNbre;
-
 
190
	console.log(pagineur.total);
-
 
191
	if (pagineur.total > 4) {
-
 
192
		pagineur.format = 'tableau';
-
 
193
	} else {
-
 
194
		pagineur.format = 'liste';
-
 
195
	}
-
 
196
}
170
}
197
 
171
 
198
function chargerObs(depart, total) {
172
function chargerObs(depart, total) {
199
	if (depart < total) {
173
	if (depart == 0 || depart < total) {
200
		var limite = 300;
174
		var limite = 300;
201
		if (depart == 0) {
175
		if (depart == 0) {
202
			obsStation = new Array();
176
			obsStation = new Array();
203
		}
177
		}
204
		console.log("Chargement de "+depart+" à "+(depart+limite));
-
 
205
		var urlObs = urlObsStation+'&start={start}&limit='+limite;
178
		console.log("Chargement de "+depart+" à "+(depart+limite));
-
 
179
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
206
		urlObs = urlObs.replace(/\{action\}/g, 'observations');
180
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
Line 207... Line 181...
207
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
181
		urlObs = urlObs.replace(/\{nt\}/g, nt);
208
		urlObs = urlObs.replace(/\{start\}/g, depart);
182
		urlObs = urlObs.replace(/\{start\}/g, depart);
-
 
183
		
-
 
184
		$.getJSON(urlObs, function(observations){
-
 
185
			obsStation = obsStation.concat(observations.observations);
-
 
186
			if (depart == 0) {
-
 
187
				actualiserInfosStation(observations);
209
		
188
				actualiserPagineur();
210
		$.getJSON(urlObs, function(observations){
189
				creerTitreInfoBulle();
211
			obsStation = obsStation.concat(observations.observations);
190
			}
212
			console.log("Chargement ok");
191
			console.log("Chargement ok");
213
			chargerObs(depart+limite, total);
192
			chargerObs(depart+limite, station.obsNbre);
214
		});
193
		});
215
	} else {
194
	} else {
216
		if (pagineur.limite < total) {
195
		if (pagineur.limite < total) {
-
 
196
			afficherPagination();
217
			afficherPagination();
197
		} else {
218
		} else {
198
			surClicPagePagination(0, null);
219
			surClicPagePagination(0, null);
199
			selectionnerOnglet("#obs-vue-"+pagineur.format);
Line -... Line 200...
-
 
200
		}
-
 
201
	}
-
 
202
}
-
 
203
 
-
 
204
function actualiserInfosStation(infos) {
-
 
205
	station.commune = infos.commune;
-
 
206
	station.obsNbre = infos.total;
-
 
207
}
-
 
208
 
-
 
209
function actualiserPagineur() {
-
 
210
	pagineur.stationId = pointClique.stationId;
-
 
211
	pagineur.total = station.obsNbre;
-
 
212
	console.log("Total pagineur: "+pagineur.total);
-
 
213
	if (pagineur.total > 4) {
-
 
214
		pagineur.format = 'tableau';
Line 220... Line 215...
220
		}
215
	} else {
221
	}
216
		pagineur.format = 'liste';
222
}
217
	}
223
 
218
}
Line 284... Line 279...
284
		}
279
		}
285
	});
280
	});
286
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
281
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
287
}
282
}
Line -... Line 283...
-
 
283
 
-
 
284
function selectionnerOnglet(onglet) {
-
 
285
	$('#obs').tabs('select', onglet);
-
 
286
}
288
 
287
 
289
function afficherTextStationId() {
288
function afficherTextStationId() {
290
	$('#obs-station-id').text(pointClique.stationId);
289
	$('#obs-station-id').text(pointClique.stationId);
Line 291... Line 290...
291
}
290
}
Line 375... Line 374...
375
	$('#panneau-lateral').height($(window).height() - 35);
374
	$('#panneau-lateral').height($(window).height() - 35);
Line 376... Line 375...
376
	
375
	
377
	if (nt == '*') {
376
	if (nt == '*') {
378
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
377
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
-
 
378
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
-
 
379
	}
-
 
380
	chargerTaxons(0, 0);
-
 
381
}
-
 
382
 
-
 
383
function chargerTaxons(depart, total) {
-
 
384
	if (depart == 0 || depart < total) {
-
 
385
		var limite = 7000;
-
 
386
		console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
-
 
387
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
-
 
388
		urlTax = urlTax.replace(/\{start\}/g, depart);
-
 
389
		$.getJSON(urlTax, function(infos) {
-
 
390
			taxonsCarte = taxonsCarte.concat(infos.taxons);
-
 
391
			console.log("Nbre taxons :"+taxonsCarte.length);
-
 
392
			chargerTaxons(depart+limite, infos.total);
-
 
393
		});
-
 
394
	} else {
-
 
395
		if (nt == '*') {
-
 
396
			afficherTaxons();
-
 
397
		} else {
-
 
398
			afficherNomPlante();
-
 
399
		}
-
 
400
	}
-
 
401
}
-
 
402
 
-
 
403
function afficherTaxons() {
-
 
404
	// Ajout du nombre de plantes au titre
-
 
405
	$('.plantes-nbre').text(taxonsCarte.length.formaterNombre());
-
 
406
	
379
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
407
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
-
 
408
	$('.taxon').live('click', filtrerParTaxon);
-
 
409
}
-
 
410
 
-
 
411
function afficherNomPlante() {
-
 
412
	if (nt != '*') {
-
 
413
		var taxon = taxonsCarte[0];
380
		$('.taxon').live('click', filtrerParTaxon);
414
		$('.plante-titre').text('pour '+taxon.nom);
381
	}
415
	}
Line 382... Line 416...
382
}
416
}
383
 
417
 
Line 411... Line 445...
411
	$('#taxon-'+nt).removeClass('taxon-actif');
445
	$('#taxon-'+nt).removeClass('taxon-actif');
412
	if (nt == ntAFiltrer) {
446
	if (nt == ntAFiltrer) {
413
		nt = '*';
447
		nt = '*';
414
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
448
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
415
	} else {
449
	} else {
416
		var url = urlObsCarte+'&'+
450
		var url = stationsUrl+'&'+
417
			'num_taxon='+ntAFiltrer+'&'+
451
			'num_taxon='+ntAFiltrer+'&'+
418
			'formatRetour=jsonp'+'&'+
452
			'formatRetour=jsonP'+'&'+
419
			'callback=?';
453
			'callback=?';
420
		$.getJSON(url, function (observations) {
454
		$.getJSON(url, function (stationsFiltrees) {
421
			obs = observations;
455
			stations = stationsFiltrees;
422
			nt = ntAFiltrer;
456
			nt = ntAFiltrer;
423
			$('#taxon-'+nt).addClass('taxon-actif');
457
			$('#taxon-'+nt).addClass('taxon-actif');
424
			rafraichirCarte();
458
			rafraichirCarte();
425
		});
459
		});
426
	}
460
	}