Subversion Repositories eFlore/Applications.cel

Rev

Rev 2323 | Rev 2520 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2323 Rev 2345
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 = false; 
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;
10
var infoBulle = new google.maps.InfoWindow();
10
var infoBulle = new google.maps.InfoWindow();
11
var pointClique = null;
11
var pointClique = null;
12
var carteCentre = new google.maps.LatLng(46.4, 3.10);
12
var carteCentre = new google.maps.LatLng(46.4, 3.10);
13
var carteOptions = {
13
var carteOptions = {
14
	zoom: 6,
14
	zoom: 6,
15
	mapTypeId: 'OSM',
15
	mapTypeId: 'OSM',
16
	mapTypeControlOptions: {
16
	mapTypeControlOptions: {
17
		mapTypeIds: ['OSM', 
17
		mapTypeIds: ['OSM', 
18
		             google.maps.MapTypeId.ROADMAP, 
18
		             google.maps.MapTypeId.ROADMAP, 
19
		             google.maps.MapTypeId.HYBRID, 
19
		             google.maps.MapTypeId.HYBRID, 
20
		             google.maps.MapTypeId.SATELLITE, 
20
		             google.maps.MapTypeId.SATELLITE, 
21
		             google.maps.MapTypeId.TERRAIN]
21
		             google.maps.MapTypeId.TERRAIN]
22
	},
22
	},
23
	scaleControl: true
23
	scaleControl: true,
-
 
24
	center: carteCentre
24
};			
25
};			
25
var ctaLayer = null;
26
var ctaLayer = null;
26
var osmMapType = new google.maps.ImageMapType({
27
var osmMapType = new google.maps.ImageMapType({
27
	getTileUrl: function(coord, zoom) {
28
	getTileUrl: function(coord, zoom) {
28
		return "http://osm.tela-botanica.org/tuiles/osmfr/" + // cache de tuiles avec nginx
29
		return "http://osm.tela-botanica.org/tuiles/osmfr/" + // cache de tuiles avec nginx
29
		zoom + "/" + coord.x + "/" + coord.y + ".png";
30
		zoom + "/" + coord.x + "/" + coord.y + ".png";
30
	},
31
	},
31
	tileSize: new google.maps.Size(256, 256),
32
	tileSize: new google.maps.Size(256, 256),
32
	isPng: true,
33
	isPng: true,
33
	alt: "OpenStreetMap",
34
	alt: "OpenStreetMap",
34
	name: "OSM",
35
	name: "OSM",
35
	maxZoom: 19
36
	maxZoom: 19
36
});
37
});
37
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
38
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
38
var station = {'commune':'', 'obsNbre':0};
39
var station = {'commune':'', 'obsNbre':0};
39
var obsStation = new Array();
40
var obsStation = new Array();
40
var obsPage = new Array();
41
var obsPage = new Array();
41
var taxonsCarte = new Array();
42
var taxonsCarte = new Array();
42
/*+--------------------------------------------------------------------------------------------------------+*/
43
/*+--------------------------------------------------------------------------------------------------------+*/
43
// INITIALISATION DU CODE
44
// INITIALISATION DU CODE
44
 
45
 
45
//Déclenchement d'actions quand JQuery et le document HTML sont OK
46
//Déclenchement d'actions quand JQuery et le document HTML sont OK
46
$(document).ready(function() {
47
$(document).ready(function() {
47
	initialiserWidget();
48
	initialiserWidget();
48
});
49
});
49
 
50
 
50
function initialiserWidget() {
51
function initialiserWidget() {
51
	afficherStats();
52
	afficherStats();
52
	definirTailleTitre();
53
	definirTailleTitre();
53
	initialiserAffichageCarte();
54
	initialiserAffichageCarte();
54
	initialiserAffichagePanneauLateral();
55
	initialiserAffichagePanneauLateral();
55
	
56
	
56
	initialiserCarte();
57
	initialiserCarte();
57
	initialiserInfoBulle();
58
	initialiserInfoBulle();
58
	initialiserFormulaireContact();
59
	initialiserFormulaireContact();
59
	chargerLimitesCommunales();
60
	chargerLimitesCommunales();
60
	rafraichirCarte();
61
	rafraichirCarte();
61
}
62
}
62
 
63
 
63
/*+--------------------------------------------------------------------------------------------------------+*/
64
/*+--------------------------------------------------------------------------------------------------------+*/
64
// AFFICHAGE GÉNÉRAL
65
// AFFICHAGE GÉNÉRAL
65
 
66
 
66
function afficherStats() {
67
function afficherStats() {
67
	// Ajout du nombre de communes où des observations ont eu lieu
68
	// Ajout du nombre de communes où des observations ont eu lieu
68
	$('#commune-nbre').text(stations.stats.communes.formaterNombre());
69
	$('#commune-nbre').text(stations.stats.communes.formaterNombre());
69
	// Ajout du nombre d'observations
70
	// Ajout du nombre d'observations
70
	$('#obs-nbre').text(stations.stats.observations.formaterNombre());
71
	$('#obs-nbre').text(stations.stats.observations.formaterNombre());
71
}
72
}
72
 
73
 
73
function definirTailleTitre() {
74
function definirTailleTitre() {
74
	var largeurViewPort = $(window).width();
75
	var largeurViewPort = $(window).width();
75
	var taille = null;
76
	var taille = null;
76
	if (largeurViewPort < 400) {
77
	if (largeurViewPort < 400) {
77
		taille = '0.8';
78
		taille = '0.8';
78
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
79
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
79
		taille = '1.0';
80
		taille = '1.0';
80
	} else if (largeurViewPort >= 800) {
81
	} else if (largeurViewPort >= 800) {
81
		taille = '1.6';
82
		taille = '1.6';
82
	}
83
	}
83
	$("#carte-titre").css('font-size', taille+'em');
84
	$("#carte-titre").css('font-size', taille+'em');
84
}
85
}
85
 
86
 
86
/*+--------------------------------------------------------------------------------------------------------+*/
87
/*+--------------------------------------------------------------------------------------------------------+*/
87
// CARTE
88
// CARTE
88
 
89
 
89
function initialiserAffichageCarte() {
90
function initialiserAffichageCarte() {
90
	$('#carte').height($(window).height() - 35);
91
	$('#carte').height($(window).height() - 35);
91
	$('#carte').width($(window).width() - 24);
92
	$('#carte').width($(window).width() - 24);
92
	
93
	
93
	if (nt != '*') {
94
	if (nt != '*') {
94
		$('#carte').css('left', 0);
95
		$('#carte').css('left', 0);
95
	}
96
	}
96
}
97
}
97
 
98
 
98
function initialiserCarte() {
99
function initialiserCarte() {
99
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
100
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
100
	// Ajout de la couche OSM à la carte
101
	// Ajout de la couche OSM à la carte
101
	map.mapTypes.set('OSM', osmMapType);
102
	map.mapTypes.set('OSM', osmMapType);
102
 
103
 
103
	// écouteur sur changement de fond
104
	// écouteur sur changement de fond
104
	google.maps.event.addListener( map, 'maptypeid_changed', function() { 
105
	google.maps.event.addListener( map, 'maptypeid_changed', function() { 
105
		// licence par défaut
106
		// licence par défaut
106
		var mention = 'Observations du réseau <a href="http://www.tela-botanica.org/site:botanique" ' +
107
		var mention = 'Observations du réseau <a href="http://www.tela-botanica.org/site:botanique" ' +
107
				'onClick="ouvrirNouvelleFenetre(this, event)">' +
108
				'onClick="ouvrirNouvelleFenetre(this, event)">' +
108
				'Tela Botanica' +
109
				'Tela Botanica' +
109
			'</a> ';
110
			'</a> ';
110
		if (map.getMapTypeId() == 'OSM') {
111
		if (map.getMapTypeId() == 'OSM') {
111
			// ajout licence OSM
112
			// ajout licence OSM
112
			mention += ' - Carte : <a href="http://www.openstreetmap.org/copyright" target="_blank">© les contributeurs d’OpenStreetMap</a>' +
113
			mention += ' - Carte : <a href="http://www.openstreetmap.org/copyright" target="_blank">© les contributeurs d’OpenStreetMap</a>' +
113
				' - Tuiles : <a href="http://www.openstreetmap.fr" target="_blank">OsmFr</a>';
114
				' - Tuiles : <a href="http://www.openstreetmap.fr" target="_blank">OsmFr</a>';
114
		}
115
		}
115
		$('#origine-donnees').html(mention);
116
		$('#origine-donnees').html(mention);
116
	});
117
	});
117
}
118
}
118
 
119
 
119
 
120
 
120
function chargerLimitesCommunales() {
121
function chargerLimitesCommunales() {
121
	if (urlsLimitesCommunales != null) {
122
	if (urlsLimitesCommunales != null) {
122
		for (urlId in urlsLimitesCommunales) { 
123
		for (urlId in urlsLimitesCommunales) { 
123
			var url = urlsLimitesCommunales[urlId];
124
			var url = urlsLimitesCommunales[urlId];
124
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
125
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
125
			ctaLayer.setMap(map);
126
			ctaLayer.setMap(map);
126
		}
127
		}
127
	}
128
	}
128
}
129
}
129
 
130
 
130
function rafraichirCarte() {
131
function rafraichirCarte() {
131
	var points = [];
132
	var points = [];
132
	var bounds = new google.maps.LatLngBounds();
133
	var bounds = new google.maps.LatLngBounds();
133
	for (var i = 0; i < stations.stats.communes; ++i) {
134
	for (var i = 0; i < stations.stats.communes; ++i) {
134
		var maLatLng = new google.maps.LatLng(stations.points[i].latitude, stations.points[i].longitude);
135
		var maLatLng = new google.maps.LatLng(stations.points[i].latitude, stations.points[i].longitude);
135
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
136
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
136
		var point = new google.maps.Marker({
137
		var point = new google.maps.Marker({
137
			position: maLatLng,
138
			position: maLatLng,
138
			map: map,
139
			map: map,
139
			icon: pointImage,
140
			icon: pointImage,
140
			stationId: stations.points[i].id
141
			stationId: stations.points[i].id
141
		});
142
		});
142
 
143
 
143
		bounds.extend(maLatLng);
144
		bounds.extend(maLatLng);
144
		
145
		
145
		google.maps.event.addListener(point, 'click', function() {
146
		google.maps.event.addListener(point, 'click', function() {
146
			pointClique =  this;
147
			pointClique =  this;
147
			infoBulle.open(map, this);
148
			infoBulle.open(map, this);
148
			
149
			
149
			var limites = map.getBounds();
150
			var limites = map.getBounds();
150
			var centre = limites.getCenter();
151
			var centre = limites.getCenter();
151
			var nordEst = limites.getNorthEast();
152
			var nordEst = limites.getNorthEast();
152
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
153
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
153
			map.panTo(centreSudLatLng);
154
			map.panTo(centreSudLatLng);
154
			
155
			
155
			afficherInfoBulle();
156
			afficherInfoBulle();
156
			chargerObs(0, 0);
157
			chargerObs(0, 0);
157
		});
158
		});
158
		
159
		
159
		points.push(point);
160
		points.push(point);
160
	}
161
	}
161
 
162
 
162
	if (pointsOrigine == null && boundsOrigine == null) {
163
	if (pointsOrigine == null && boundsOrigine == null) {
163
		pointsOrigine = points;
164
		pointsOrigine = points;
164
		boundsOrigine = bounds;
165
		boundsOrigine = bounds;
165
	}
166
	}
166
	
167
	
167
	executerMarkerClusterer(points, bounds);
168
	executerMarkerClusterer(points, bounds);
168
}
169
}
169
 
170
 
170
function deplacerCartePointClique() {
171
function deplacerCartePointClique() {
171
	map.panTo(pointClique.position);
172
	map.panTo(pointClique.position);
172
}
173
}
173
 
174
 
174
function executerMarkerClusterer(points, bounds) {
175
function executerMarkerClusterer(points, bounds) {
-
 
176
	if (points.length > 0) {
175
	if (markerClusterer) {
177
		if (markerClusterer) {
176
		markerClusterer.clearMarkers();
178
			markerClusterer.clearMarkers();
-
 
179
		}
-
 
180
		markerClusterer = new MarkerClusterer(map, points);
-
 
181
		map.fitBounds(bounds);
177
	}
182
	}
178
	markerClusterer = new MarkerClusterer(map, points);
-
 
179
	map.fitBounds(bounds);
-
 
180
}
183
}
181
 
184
 
182
/*+--------------------------------------------------------------------------------------------------------+*/
185
/*+--------------------------------------------------------------------------------------------------------+*/
183
// INFO BULLE
186
// INFO BULLE
184
 
187
 
185
function initialiserInfoBulle() {
188
function initialiserInfoBulle() {
186
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
189
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
187
	google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique);
190
	google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique);
188
}
191
}
189
 
192
 
190
function afficherInfoBulle() {
193
function afficherInfoBulle() {
191
	var obsHtml = $("#tpl-obs").html();
194
	var obsHtml = $("#tpl-obs").html();
192
	var largeur = definirLargeurInfoBulle();
195
	var largeur = definirLargeurInfoBulle();
193
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
196
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
194
	infoBulle.setContent(obsHtml);
197
	infoBulle.setContent(obsHtml);
195
}
198
}
196
 
199
 
197
function definirLargeurInfoBulle() {
200
function definirLargeurInfoBulle() {
198
	var largeurViewPort = $(window).width();
201
	var largeurViewPort = $(window).width();
199
	var lageurInfoBulle = null;
202
	var lageurInfoBulle = null;
200
	if (largeurViewPort < 800) {
203
	if (largeurViewPort < 800) {
201
		largeurInfoBulle = 400;
204
		largeurInfoBulle = 400;
202
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
205
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
203
		largeurInfoBulle = 500;
206
		largeurInfoBulle = 500;
204
	} else if (largeurViewPort >= 1200) {
207
	} else if (largeurViewPort >= 1200) {
205
		largeurInfoBulle = 600;
208
		largeurInfoBulle = 600;
206
	}
209
	}
207
	return largeurInfoBulle;
210
	return largeurInfoBulle;
208
}
211
}
209
 
212
 
210
function afficherMessageChargement(element) {
213
function afficherMessageChargement(element) {
211
	if ($('#chargement').get() == '') {
214
	if ($('#chargement').get() == '') {
212
		$('#tpl-chargement').tmpl().appendTo(element);
215
		$('#tpl-chargement').tmpl().appendTo(element);
213
	}
216
	}
214
}
217
}
215
 
218
 
216
function supprimerMessageChargement() {
219
function supprimerMessageChargement() {
217
	$('#chargement').remove();
220
	$('#chargement').remove();
218
}
221
}
219
 
222
 
220
function chargerObs(depart, total) {
223
function chargerObs(depart, total) {
221
	if (depart == 0 || depart < total) {
224
	if (depart == 0 || depart < total) {
222
		var limite = 300;
225
		var limite = 300;
223
		if (depart == 0) {
226
		if (depart == 0) {
224
			obsStation = new Array();
227
			obsStation = new Array();
225
		}
228
		}
226
		//console.log("Chargement de "+depart+" à "+(depart+limite));
229
		//console.log("Chargement de "+depart+" à "+(depart+limite));
227
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
230
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
228
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
231
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
229
		urlObs = urlObs.replace(/\{nt\}/g, nt);
232
		urlObs = urlObs.replace(/\{nt\}/g, nt);
230
		urlObs = urlObs.replace(/\{start\}/g, depart);
233
		urlObs = urlObs.replace(/\{start\}/g, depart);
231
		
234
		
232
		$.getJSON(urlObs, function(observations){
235
		$.getJSON(urlObs, function(observations){
233
			obsStation = obsStation.concat(observations.observations);
236
			obsStation = obsStation.concat(observations.observations);
234
			if (depart == 0) {
237
			if (depart == 0) {
235
				actualiserInfosStation(observations);
238
				actualiserInfosStation(observations);
236
				actualiserPagineur();
239
				actualiserPagineur();
237
				creerTitreInfoBulle();
240
				creerTitreInfoBulle();
238
			}
241
			}
239
			//console.log("Chargement ok");
242
			//console.log("Chargement ok");
240
			chargerObs(depart+limite, station.obsNbre);
243
			chargerObs(depart+limite, station.obsNbre);
241
		});
244
		});
242
	} else {
245
	} else {
243
		if (pagineur.limite < total) {
246
		if (pagineur.limite < total) {
244
			afficherPagination();
247
			afficherPagination();
245
		} else {
248
		} else {
246
			surClicPagePagination(0, null);
249
			surClicPagePagination(0, null);
247
			selectionnerOnglet("#obs-vue-"+pagineur.format);
250
			selectionnerOnglet("#obs-vue-"+pagineur.format);
248
		}
251
		}
249
	}
252
	}
250
}
253
}
251
 
254
 
252
function actualiserInfosStation(infos) {
255
function actualiserInfosStation(infos) {
253
	station.commune = infos.commune;
256
	station.commune = infos.commune;
254
	station.obsNbre = infos.total;
257
	station.obsNbre = infos.total;
255
}
258
}
256
 
259
 
257
function actualiserPagineur() {
260
function actualiserPagineur() {
258
	pagineur.stationId = pointClique.stationId;
261
	pagineur.stationId = pointClique.stationId;
259
	pagineur.total = station.obsNbre;
262
	pagineur.total = station.obsNbre;
260
	//console.log("Total pagineur: "+pagineur.total);
263
	//console.log("Total pagineur: "+pagineur.total);
261
	if (pagineur.total > 4) {
264
	if (pagineur.total > 4) {
262
		pagineur.format = 'tableau';
265
		pagineur.format = 'tableau';
263
	} else {
266
	} else {
264
		pagineur.format = 'liste';
267
		pagineur.format = 'liste';
265
	}
268
	}
266
}
269
}
267
 
270
 
268
function afficherPagination(observations) {
271
function afficherPagination(observations) {
269
	$(".navigation").pagination(pagineur.total, {
272
	$(".navigation").pagination(pagineur.total, {
270
		items_per_page:pagineur.limite,
273
		items_per_page:pagineur.limite,
271
		callback:surClicPagePagination,
274
		callback:surClicPagePagination,
272
		next_text:'Suivant',
275
		next_text:'Suivant',
273
		prev_text:'Précédent',
276
		prev_text:'Précédent',
274
		prev_show_always:false,
277
		prev_show_always:false,
275
		num_edge_entries:1,
278
		num_edge_entries:1,
276
		num_display_entries:4,
279
		num_display_entries:4,
277
		load_first_page:true
280
		load_first_page:true
278
	});
281
	});
279
}
282
}
280
 
283
 
281
function surClicPagePagination(pageIndex, paginationConteneur) {
284
function surClicPagePagination(pageIndex, paginationConteneur) {
282
	var index = pageIndex * pagineur.limite;
285
	var index = pageIndex * pagineur.limite;
283
	var indexMax = index + pagineur.limite;
286
	var indexMax = index + pagineur.limite;
284
	pagineur.depart = index;
287
	pagineur.depart = index;
285
	obsPage = new Array();
288
	obsPage = new Array();
286
    for(index; index < indexMax; index++) {
289
    for(index; index < indexMax; index++) {
287
    	obsPage.push(obsStation[index]);
290
    	obsPage.push(obsStation[index]);
288
    }
291
    }
289
    
292
    
290
    supprimerMessageChargement();
293
    supprimerMessageChargement();
291
    mettreAJourObservations();
294
    mettreAJourObservations();
292
	return false;
295
	return false;
293
}
296
}
294
 
297
 
295
function mettreAJourObservations() {
298
function mettreAJourObservations() {
296
	$("#obs-"+pagineur.format+"-lignes").empty();
299
	$("#obs-"+pagineur.format+"-lignes").empty();
297
   	$("#obs-vue-"+pagineur.format).css('display', 'block');
300
   	$("#obs-vue-"+pagineur.format).css('display', 'block');
298
   	$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart);
301
   	$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart);
299
	$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes");
302
	$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes");
300
	
303
	
301
	// Actualisation de Fancybox
304
	// Actualisation de Fancybox
302
	ajouterFomulaireContact("a.contact");
305
	ajouterFomulaireContact("a.contact");
303
	if (pagineur.format == 'liste') {
306
	if (pagineur.format == 'liste') {
304
		ajouterGaleriePhoto("a.cel-img");
307
		ajouterGaleriePhoto("a.cel-img");
305
	}
308
	}
306
}
309
}
307
 
310
 
308
function creerTitreInfoBulle() {
311
function creerTitreInfoBulle() {
309
	$("#obs-total").text(station.obsNbre);
312
	$("#obs-total").text(station.obsNbre);
310
	$("#obs-commune").text(station.commune);	
313
	$("#obs-commune").text(station.commune);	
311
}
314
}
312
 
315
 
313
function initialiserContenuInfoBulle() {
316
function initialiserContenuInfoBulle() {
314
	afficherOnglets();
317
	afficherOnglets();
315
	afficherMessageChargement('#observations');
318
	afficherMessageChargement('#observations');
316
	ajouterTableauTriable("#obs-tableau");
319
	ajouterTableauTriable("#obs-tableau");
317
	afficherTextStationId();
320
	afficherTextStationId();
318
	corrigerLargeurInfoWindow();
321
	corrigerLargeurInfoWindow();
319
}
322
}
320
 
323
 
321
function afficherOnglets() {
324
function afficherOnglets() {
322
	var $tabs = $('#obs').tabs();
325
	var $tabs = $('#obs').tabs();
323
	$('#obs').bind('tabsselect', function(event, ui) {
326
	$('#obs').bind('tabsselect', function(event, ui) {
324
		if (ui.panel.id == 'obs-vue-tableau') {
327
		if (ui.panel.id == 'obs-vue-tableau') {
325
			surClicAffichageTableau();
328
			surClicAffichageTableau();
326
		} else if (ui.panel.id == 'obs-vue-liste') {
329
		} else if (ui.panel.id == 'obs-vue-liste') {
327
			surClicAffichageListe();
330
			surClicAffichageListe();
328
		}
331
		}
329
	});
332
	});
330
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
333
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
331
}
334
}
332
 
335
 
333
function selectionnerOnglet(onglet) {
336
function selectionnerOnglet(onglet) {
334
	$('#obs').tabs('select', onglet);
337
	$('#obs').tabs('select', onglet);
335
}
338
}
336
 
339
 
337
function afficherTextStationId() {
340
function afficherTextStationId() {
338
	$('#obs-station-id').text(pointClique.stationId);
341
	$('#obs-station-id').text(pointClique.stationId);
339
}
342
}
340
 
343
 
341
function corrigerLargeurInfoWindow() {
344
function corrigerLargeurInfoWindow() {
342
	$("#info-bulle").width($("#info-bulle").width() - 17);
345
	$("#info-bulle").width($("#info-bulle").width() - 17);
343
}
346
}
344
 
347
 
345
function surClicAffichageTableau(event) {
348
function surClicAffichageTableau(event) {
346
	//console.log('tableau');
349
	//console.log('tableau');
347
	pagineur.format = 'tableau';
350
	pagineur.format = 'tableau';
348
	mettreAJourObservations();
351
	mettreAJourObservations();
349
	mettreAJourTableauTriable("#obs-tableau");
352
	mettreAJourTableauTriable("#obs-tableau");
350
}
353
}
351
 
354
 
352
function surClicAffichageListe(event) {
355
function surClicAffichageListe(event) {
353
	//console.log('liste');
356
	//console.log('liste');
354
	pagineur.format = 'liste';
357
	pagineur.format = 'liste';
355
	mettreAJourObservations();
358
	mettreAJourObservations();
356
	ajouterGaleriePhoto("a.cel-img");
359
	ajouterGaleriePhoto("a.cel-img");
357
}
360
}
358
 
361
 
359
function ajouterTableauTriable(element) {
362
function ajouterTableauTriable(element) {
360
	// add parser through the tablesorter addParser method 
363
	// add parser through the tablesorter addParser method 
361
	$.tablesorter.addParser({ 
364
	$.tablesorter.addParser({ 
362
		// Définition d'un id unique pour ce parsseur 
365
		// Définition d'un id unique pour ce parsseur 
363
		id: 'date_cel', 
366
		id: 'date_cel', 
364
		is: function(s) { 
367
		is: function(s) { 
365
			// doit retourner false si le parsseur n'est pas autodétecté
368
			// doit retourner false si le parsseur n'est pas autodétecté
366
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
369
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
367
		}, 
370
		}, 
368
		format: function(date) { 
371
		format: function(date) { 
369
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
372
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
370
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
373
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
371
			// Remplace la date par un nombre de millisecondes pour trier numériquement
374
			// Remplace la date par un nombre de millisecondes pour trier numériquement
372
			return $.tablesorter.formatFloat(new Date(date).getTime());
375
			return $.tablesorter.formatFloat(new Date(date).getTime());
373
		}, 
376
		}, 
374
		// set type, either numeric or text 
377
		// set type, either numeric or text 
375
		type: 'numeric' 
378
		type: 'numeric' 
376
	});
379
	});
377
	$(element).tablesorter({ 
380
	$(element).tablesorter({ 
378
        headers: { 
381
        headers: { 
379
			1: { 
382
			1: { 
380
            	sorter:'date_cel' 
383
            	sorter:'date_cel' 
381
        	} 
384
        	} 
382
    	} 
385
    	} 
383
	});
386
	});
384
}
387
}
385
 
388
 
386
function mettreAJourTableauTriable(element) {
389
function mettreAJourTableauTriable(element) {
387
	$(element).trigger('update');
390
	$(element).trigger('update');
388
}
391
}
389
 
392
 
390
function ajouterGaleriePhoto(element) {
393
function ajouterGaleriePhoto(element) {
391
	$(element).fancybox({
394
	$(element).fancybox({
392
		transitionIn:'elastic',
395
		transitionIn:'elastic',
393
		transitionOut:'elastic',
396
		transitionOut:'elastic',
394
		speedIn	:600, 
397
		speedIn	:600, 
395
		speedOut:200,
398
		speedOut:200,
396
		overlayShow:true,
399
		overlayShow:true,
397
		titleShow:true,
400
		titleShow:true,
398
		titlePosition:'inside',
401
		titlePosition:'inside',
399
		titleFormat:function (titre, currentArray, currentIndex, currentOpts) {
402
		titleFormat:function (titre, currentArray, currentIndex, currentOpts) {
400
			var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/;
403
			var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/;
401
			motif.exec(titre);
404
			motif.exec(titre);
402
			var id = RegExp.$1;
405
			var id = RegExp.$1;
403
			var info = $('#cel-info-'+id).clone().html();
406
			var info = $('#cel-info-'+id).clone().html();
404
			var tpl = 
407
			var tpl = 
405
				'<div class="cel-legende">'+
408
				'<div class="cel-legende">'+
406
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
409
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
407
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
410
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
408
				'<\/div>';
411
				'<\/div>';
409
			return tpl;
412
			return tpl;
410
		}
413
		}
411
		}).live('click', function(e) {
414
		}).live('click', function(e) {
412
			if (e.stopPropagation) {
415
			if (e.stopPropagation) {
413
				e.stopPropagation();
416
				e.stopPropagation();
414
			}
417
			}
415
			return false;
418
			return false;
416
		});
419
		});
417
}
420
}
418
 
421
 
419
function ajouterFomulaireContact(element) {
422
function ajouterFomulaireContact(element) {
420
	$(element).fancybox({
423
	$(element).fancybox({
421
		transitionIn:'elastic',
424
		transitionIn:'elastic',
422
		transitionOut:'elastic',
425
		transitionOut:'elastic',
423
		speedIn	:600, 
426
		speedIn	:600, 
424
		speedOut:200,
427
		speedOut:200,
425
		scrolling: 'no',
428
		scrolling: 'no',
426
		titleShow: false,
429
		titleShow: false,
427
		onStart: function(selectedArray, selectedIndex, selectedOpts) {
430
		onStart: function(selectedArray, selectedIndex, selectedOpts) {
428
			var element = selectedArray[selectedIndex];
431
			var element = selectedArray[selectedIndex];
429
 
432
 
430
			var motif = / contributeur-([0-9]+)$/;
433
			var motif = / contributeur-([0-9]+)$/;
431
			motif.exec($(element).attr('class'));
434
			motif.exec($(element).attr('class'));
432
			var id = RegExp.$1;
435
			var id = RegExp.$1;
433
			//console.log('Destinataire id : '+id);
436
			//console.log('Destinataire id : '+id);
434
			$("#fc_destinataire_id").attr('value', id);
437
			$("#fc_destinataire_id").attr('value', id);
435
		
438
		
436
			var motif = / obs-([0-9]+) /;
439
			var motif = / obs-([0-9]+) /;
437
			motif.exec($(element).attr('class'));
440
			motif.exec($(element).attr('class'));
438
			var id = RegExp.$1;
441
			var id = RegExp.$1;
439
			//console.log('Obs id : '+id);
442
			//console.log('Obs id : '+id);
440
			chargerInfoObsPourMessage(id);
443
			chargerInfoObsPourMessage(id);
441
		},
444
		},
442
		onCleanup: function() {
445
		onCleanup: function() {
443
			//console.log('Avant fermeture fancybox');
446
			//console.log('Avant fermeture fancybox');
444
			$("#fc_destinataire_id").attr('value', '');
447
			$("#fc_destinataire_id").attr('value', '');
445
			$("#fc_sujet").attr('value', '');
448
			$("#fc_sujet").attr('value', '');
446
			$("#fc_message").text('');
449
			$("#fc_message").text('');
447
		},
450
		},
448
		onClosed: function(e) {
451
		onClosed: function(e) {
449
			//console.log('Fermeture fancybox');
452
			//console.log('Fermeture fancybox');
450
			if (e.stopPropagation) {
453
			if (e.stopPropagation) {
451
				e.stopPropagation();
454
				e.stopPropagation();
452
			}
455
			}
453
			return false;
456
			return false;
454
		}
457
		}
455
	});
458
	});
456
}
459
}
457
 
460
 
458
function chargerInfoObsPourMessage(idObs) {
461
function chargerInfoObsPourMessage(idObs) {
459
	var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
462
	var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
460
	var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
463
	var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
461
	var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
464
	var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
462
	var sujet = "Observation #"+idObs+" de "+nomSci;
465
	var sujet = "Observation #"+idObs+" de "+nomSci;
463
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
466
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
464
	$("#fc_sujet").attr('value', sujet);
467
	$("#fc_sujet").attr('value', sujet);
465
	$("#fc_message").text(message);
468
	$("#fc_message").text(message);
466
}
469
}
467
 
470
 
468
function initialiserFormulaireContact() {
471
function initialiserFormulaireContact() {
469
	//console.log('Initialisation du form contact');
472
	//console.log('Initialisation du form contact');
470
	$("#form-contact").validate({
473
	$("#form-contact").validate({
471
		rules: {
474
		rules: {
472
			fc_sujet : "required",
475
			fc_sujet : "required",
473
			fc_message : "required",
476
			fc_message : "required",
474
			fc_utilisateur_courriel : {
477
			fc_utilisateur_courriel : {
475
				required : true,
478
				required : true,
476
				email : true}
479
				email : true}
477
		}
480
		}
478
	});
481
	});
479
	$("#form-contact").bind("submit", envoyerCourriel);
482
	$("#form-contact").bind("submit", envoyerCourriel);
480
	$("#fc_annuler").bind("click", function() {$.fancybox.close();});
483
	$("#fc_annuler").bind("click", function() {$.fancybox.close();});
481
	
484
	
482
}
485
}
483
 
486
 
484
function envoyerCourriel() {
487
function envoyerCourriel() {
485
	//console.log('Formulaire soumis');
488
	//console.log('Formulaire soumis');
486
	if ($("#form-contact").valid()) {
489
	if ($("#form-contact").valid()) {
487
		//console.log('Formulaire valide');
490
		//console.log('Formulaire valide');
488
		//$.fancybox.showActivity();
491
		//$.fancybox.showActivity();
489
		var destinataireId = $("#fc_destinataire_id").attr('value');
492
		var destinataireId = $("#fc_destinataire_id").attr('value');
490
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
493
		var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message"
491
		var erreurMsg = "";
494
		var erreurMsg = "";
492
		var donnees = new Array();
495
		var donnees = new Array();
493
		$.each($(this).serializeArray(), function (index, champ) {
496
		$.each($(this).serializeArray(), function (index, champ) {
494
			var cle = champ.name;
497
			var cle = champ.name;
495
			cle = cle.replace(/^fc_/, '');
498
			cle = cle.replace(/^fc_/, '');
496
			
499
			
497
			if (cle == 'sujet') {
500
			if (cle == 'sujet') {
498
				champ.value += " - Carnet en ligne - Tela Botanica";
501
				champ.value += " - Carnet en ligne - Tela Botanica";
499
			}
502
			}
500
			if (cle == 'message') {
503
			if (cle == 'message') {
501
				champ.value += "\n--\n"+
504
				champ.value += "\n--\n"+
502
					"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+
505
					"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+
503
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
506
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
504
					"http://www.tela-botanica.org/widget:cel:carto";
507
					"http://www.tela-botanica.org/widget:cel:carto";
505
			}
508
			}
506
			
509
			
507
			donnees[index] = {'name':cle,'value':champ.value};
510
			donnees[index] = {'name':cle,'value':champ.value};
508
		});
511
		});
509
		$.ajax({
512
		$.ajax({
510
			type : "POST",
513
			type : "POST",
511
			cache : false,
514
			cache : false,
512
			url : urlMessage,
515
			url : urlMessage,
513
			data : donnees,
516
			data : donnees,
514
			beforeSend : function() {
517
			beforeSend : function() {
515
				$(".msg").remove();
518
				$(".msg").remove();
516
			},
519
			},
517
			success : function(data) {
520
			success : function(data) {
518
				$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>');
521
				$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>');
519
			},
522
			},
520
			error : function(jqXHR, textStatus, errorThrown) {
523
			error : function(jqXHR, textStatus, errorThrown) {
521
				erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n";
524
				erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n";
522
				reponse = jQuery.parseJSON(jqXHR.responseText);
525
				reponse = jQuery.parseJSON(jqXHR.responseText);
523
				if (reponse != null) {
526
				if (reponse != null) {
524
					$.each(reponse, function (cle, valeur) {
527
					$.each(reponse, function (cle, valeur) {
525
						erreurMsg += valeur + "\n";
528
						erreurMsg += valeur + "\n";
526
					});
529
					});
527
				}				
530
				}				
528
			},
531
			},
529
			complete : function(jqXHR, textStatus) {
532
			complete : function(jqXHR, textStatus) {
530
				var debugMsg = '';
533
				var debugMsg = '';
531
				if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') {
534
				if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') {
532
					debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data"));
535
					debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data"));
533
					if (debugInfos != null) {
536
					if (debugInfos != null) {
534
						$.each(debugInfos, function (cle, valeur) {
537
						$.each(debugInfos, function (cle, valeur) {
535
							debugMsg += valeur + "\n";
538
							debugMsg += valeur + "\n";
536
						});
539
						});
537
					}
540
					}
538
				}
541
				}
539
				if (erreurMsg != '') {
542
				if (erreurMsg != '') {
540
					$("#fc-zone-dialogue").append('<p class="msg">'+
543
					$("#fc-zone-dialogue").append('<p class="msg">'+
541
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
544
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
542
							'Vous pouvez signaler le disfonctionnement à <a href="'+
545
							'Vous pouvez signaler le disfonctionnement à <a href="'+
543
							'mailto:cel@tela-botanica.org'+'?'+
546
							'mailto:cel@tela-botanica.org'+'?'+
544
							'subject=Disfonctionnement du widget de Cartographie'+
547
							'subject=Disfonctionnement du widget de Cartographie'+
545
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
548
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
546
							'">cel@tela-botanica.org</a>.'+
549
							'">cel@tela-botanica.org</a>.'+
547
							'</p>');
550
							'</p>');
548
				}
551
				}
549
				if (DEBUG) {
552
				if (DEBUG) {
550
					console.log('Débogage : '+debugMsg);
553
					console.log('Débogage : '+debugMsg);
551
				}
554
				}
552
				//console.log('Débogage : '+debugMsg);
555
				//console.log('Débogage : '+debugMsg);
553
				//console.log('Erreur : '+erreurMsg);
556
				//console.log('Erreur : '+erreurMsg);
554
			}
557
			}
555
		});
558
		});
556
	}
559
	}
557
	return false;
560
	return false;
558
}
561
}
559
/*+--------------------------------------------------------------------------------------------------------+*/
562
/*+--------------------------------------------------------------------------------------------------------+*/
560
// PANNEAU LATÉRAL
563
// PANNEAU LATÉRAL
561
 
564
 
562
function initialiserAffichagePanneauLateral() {
565
function initialiserAffichagePanneauLateral() {
563
	$('#panneau-lateral').height($(window).height() - 35);
566
	$('#panneau-lateral').height($(window).height() - 35);
564
	
567
	
565
	if (nt == '*') {
568
	if (nt == '*') {
566
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
569
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
567
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
570
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
568
	}
571
	}
569
	chargerTaxons(0, 0);
572
	chargerTaxons(0, 0);
570
}
573
}
571
 
574
 
572
function chargerTaxons(depart, total) {
575
function chargerTaxons(depart, total) {
573
	if (depart == 0 || depart < total) {
576
	if (depart == 0 || depart < total) {
574
		var limite = 7000;
577
		var limite = 7000;
575
		//console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
578
		//console.log("Chargement des taxons de "+depart+" à "+(depart+limite));
576
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
579
		var urlTax = taxonsUrl+'&start={start}&limit='+limite;
577
		urlTax = urlTax.replace(/\{start\}/g, depart);
580
		urlTax = urlTax.replace(/\{start\}/g, depart);
578
		$.getJSON(urlTax, function(infos) {
581
		$.getJSON(urlTax, function(infos) {
579
			taxonsCarte = taxonsCarte.concat(infos.taxons);
582
			taxonsCarte = taxonsCarte.concat(infos.taxons);
580
			//console.log("Nbre taxons :"+taxonsCarte.length);
583
			//console.log("Nbre taxons :"+taxonsCarte.length);
581
			chargerTaxons(depart+limite, infos.total);
584
			chargerTaxons(depart+limite, infos.total);
582
		});
585
		});
583
	} else {
586
	} else {
584
		if (nt == '*') {
587
		if (nt == '*') {
585
			afficherTaxons();
588
			afficherTaxons();
586
		} else {
589
		} else {
587
			afficherNomPlante();
590
			afficherNomPlante();
588
		}
591
		}
589
	}
592
	}
590
}
593
}
591
 
594
 
592
function afficherTaxons() {
595
function afficherTaxons() {
593
	// Ajout du nombre de plantes au titre
596
	// Ajout du nombre de plantes au titre
594
	$('.plantes-nbre').text(taxonsCarte.length.formaterNombre());
597
	$('.plantes-nbre').text(taxonsCarte.length.formaterNombre());
595
	
598
	
596
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
599
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
597
	$('.taxon').live('click', filtrerParTaxon);
600
	$('.taxon').live('click', filtrerParTaxon);
598
}
601
}
599
 
602
 
600
function afficherNomPlante() {
603
function afficherNomPlante() {
601
	if (nt != '*') {
604
	if (nt != '*') {
602
		var taxon = taxonsCarte[0];
605
		var taxon = taxonsCarte[0];
603
		$('.plante-titre').text('pour '+taxon.nom);
606
		$('.plante-titre').text('pour '+taxon.nom);
604
	}
607
	}
605
}
608
}
606
 
609
 
607
function afficherPanneauLateral() {
610
function afficherPanneauLateral() {
608
	$('#panneau-lateral').width(300);
611
	$('#panneau-lateral').width(300);
609
	$('#pl-contenu').css('display', 'block');
612
	$('#pl-contenu').css('display', 'block');
610
	$('#pl-ouverture').css('display', 'none');
613
	$('#pl-ouverture').css('display', 'none');
611
	$('#pl-fermeture').css('display', 'block');
614
	$('#pl-fermeture').css('display', 'block');
612
	$('#carte').css('left', '300px');
615
	$('#carte').css('left', '300px');
613
 
616
 
614
	google.maps.event.trigger(map, 'resize');
617
	google.maps.event.trigger(map, 'resize');
615
};
618
};
616
 
619
 
617
function cacherPanneauLateral() {
620
function cacherPanneauLateral() {
618
	$('#panneau-lateral').width(24);
621
	$('#panneau-lateral').width(24);
619
	$('#pl-contenu').css('display', 'none');
622
	$('#pl-contenu').css('display', 'none');
620
	$('#pl-ouverture').css('display', 'block');
623
	$('#pl-ouverture').css('display', 'block');
621
	$('#pl-fermeture').css('display', 'none');
624
	$('#pl-fermeture').css('display', 'none');
622
	$('#carte').css('left', '24px');
625
	$('#carte').css('left', '24px');
623
	
626
	
624
	google.maps.event.trigger(map, 'resize');
627
	google.maps.event.trigger(map, 'resize');
625
};
628
};
626
 
629
 
627
function ouvrirPopUp(url, nom) {
630
function ouvrirPopUp(url, nom) {
628
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
631
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
629
};
632
};
630
 
633
 
631
function filtrerParTaxon() {
634
function filtrerParTaxon() {
632
	var ntAFiltrer = $('.nt', this).text();
635
	var ntAFiltrer = $('.nt', this).text();
633
	infoBulle.close();
636
	infoBulle.close();
634
	$('#taxon-'+nt).removeClass('taxon-actif');
637
	$('#taxon-'+nt).removeClass('taxon-actif');
635
	if (nt == ntAFiltrer) {
638
	if (nt == ntAFiltrer) {
636
		nt = '*';
639
		nt = '*';
637
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
640
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
638
	} else {
641
	} else {
639
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+
642
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+
640
			'&formatRetour=jsonP'+
643
			'&formatRetour=jsonP'+
641
			'&callback=?';
644
			'&callback=?';
642
		$.getJSON(url, function (stationsFiltrees) {
645
		$.getJSON(url, function (stationsFiltrees) {
643
			stations = stationsFiltrees;
646
			stations = stationsFiltrees;
644
			nt = ntAFiltrer;
647
			nt = ntAFiltrer;
645
			$('#taxon-'+nt).addClass('taxon-actif');
648
			$('#taxon-'+nt).addClass('taxon-actif');
646
			rafraichirCarte();
649
			rafraichirCarte();
647
		});
650
		});
648
	}
651
	}
649
};
652
};
650
 
653
 
651
/*+--------------------------------------------------------------------------------------------------------+*/
654
/*+--------------------------------------------------------------------------------------------------------+*/
652
// FONCTIONS UTILITAIRES
655
// FONCTIONS UTILITAIRES
653
 
656
 
654
function arreter(event) {
657
function arreter(event) {
655
	if (event.stopPropagation) {
658
	if (event.stopPropagation) {
656
		event.stopPropagation();
659
		event.stopPropagation();
657
	} else if (window.event) {
660
	} else if (window.event) {
658
		window.event.cancelBubble = true;
661
		window.event.cancelBubble = true;
659
	}
662
	}
660
	return false;
663
	return false;
661
}
664
}
662
 
665
 
663
/**
666
/**
664
 * +-------------------------------------+
667
 * +-------------------------------------+
665
 * Number.prototype.formaterNombre
668
 * Number.prototype.formaterNombre
666
 * +-------------------------------------+
669
 * +-------------------------------------+
667
 * Params (facultatifs):
670
 * Params (facultatifs):
668
 * - Int decimales: nombre de decimales (exemple: 2)
671
 * - Int decimales: nombre de decimales (exemple: 2)
669
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
672
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
670
 * - String separateurMilliers: comme son nom l'indique
673
 * - String separateurMilliers: comme son nom l'indique
671
 * Returns:
674
 * Returns:
672
 * - String chaine formatee
675
 * - String chaine formatee
673
 * @author	::mastahbenus::
676
 * @author	::mastahbenus::
674
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
677
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
675
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
678
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
676
 */
679
 */
677
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
680
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
678
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
681
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
679
	
682
	
680
	function is_int(nbre) {
683
	function is_int(nbre) {
681
		nbre = nbre.replace(',', '.');
684
		nbre = nbre.replace(',', '.');
682
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
685
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
683
	}
686
	}
684
 
687
 
685
	if (decimales == undefined) {
688
	if (decimales == undefined) {
686
		if (is_int(_sNombre)) {
689
		if (is_int(_sNombre)) {
687
			decimales = 0;
690
			decimales = 0;
688
		} else {
691
		} else {
689
			decimales = 2;
692
			decimales = 2;
690
		}
693
		}
691
	}
694
	}
692
	if (signe == undefined) {
695
	if (signe == undefined) {
693
		if (is_int(_sNombre)) {
696
		if (is_int(_sNombre)) {
694
			signe = '';
697
			signe = '';
695
		} else {
698
		} else {
696
			signe = '.';
699
			signe = '.';
697
		}
700
		}
698
	}
701
	}
699
	if (separateurMilliers == undefined) {
702
	if (separateurMilliers == undefined) {
700
		separateurMilliers = ' ';
703
		separateurMilliers = ' ';
701
	}
704
	}
702
	
705
	
703
	function separeMilliers (sNombre) {
706
	function separeMilliers (sNombre) {
704
		var sRetour = "";
707
		var sRetour = "";
705
		while (sNombre.length % 3 != 0) {
708
		while (sNombre.length % 3 != 0) {
706
			sNombre = "0"+sNombre;
709
			sNombre = "0"+sNombre;
707
		}
710
		}
708
		for (i = 0; i < sNombre.length; i += 3) {
711
		for (i = 0; i < sNombre.length; i += 3) {
709
			if (i == sNombre.length-1) separateurMilliers = '';
712
			if (i == sNombre.length-1) separateurMilliers = '';
710
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
713
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
711
		}
714
		}
712
		while (sRetour.substr(0, 1) == "0") {
715
		while (sRetour.substr(0, 1) == "0") {
713
			sRetour = sRetour.substr(1);
716
			sRetour = sRetour.substr(1);
714
		}
717
		}
715
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
718
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
716
	}
719
	}
717
	
720
	
718
	if (_sNombre.indexOf('.') == -1) {
721
	if (_sNombre.indexOf('.') == -1) {
719
		for (i = 0; i < decimales; i++) {
722
		for (i = 0; i < decimales; i++) {
720
			_sDecimales += "0";
723
			_sDecimales += "0";
721
		}
724
		}
722
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
725
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
723
	} else {
726
	} else {
724
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
727
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
725
		if (sDecimalesTmp.length > decimales) {
728
		if (sDecimalesTmp.length > decimales) {
726
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
729
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
727
			var nDiv = 1;
730
			var nDiv = 1;
728
			for (i = 0; i < nDecimalesManquantes; i++) {
731
			for (i = 0; i < nDecimalesManquantes; i++) {
729
				nDiv *= 10;
732
				nDiv *= 10;
730
			}
733
			}
731
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
734
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
732
		}
735
		}
733
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
736
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
734
	}
737
	}
735
	return _sRetour;
738
	return _sRetour;
736
}
739
}
737
 
740
 
738
function debug(objet) {
741
function debug(objet) {
739
	var msg = '';
742
	var msg = '';
740
	if (objet != null) {
743
	if (objet != null) {
741
		$.each(objet, function (cle, valeur) {
744
		$.each(objet, function (cle, valeur) {
742
			msg += cle+":"+valeur + "\n";
745
			msg += cle+":"+valeur + "\n";
743
		});
746
		});
744
	} else {
747
	} else {
745
		msg = "La variable vaut null.";
748
		msg = "La variable vaut null.";
746
	}
749
	}
747
	console.log(msg);
750
	console.log(msg);
748
}
751
}
749
 
752
 
750
function trim (chaine) {
753
function trim (chaine) {
751
	return chaine.replace(/^\s+/g, '').replace(/\s+$/g, '');
754
	return chaine.replace(/^\s+/g, '').replace(/\s+$/g, '');
752
}
755
}