Subversion Repositories Sites.obs-saisons.fr

Rev

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

Rev 302 Rev 320
1
function getUrlBaseJrest() {
1
function getUrlBaseJrest() {
2
	return urlBaseJrest;
2
	return urlBaseJrest;
3
}
3
}
4
 
4
 
5
/** 
5
/**
6
	************************************************************************************************
6
	************************************************************************************************
7
	************************************************************************************************
7
	************************************************************************************************
8
	
8
 
9
	   Fonction permettant de transformer les élements de la classe pliage en accordéon
9
	   Fonction permettant de transformer les élements de la classe pliage en accordéon
10
	
10
 
11
	************************************************************************************************
11
	************************************************************************************************
12
	************************************************************************************************
12
	************************************************************************************************
13
**/  
13
**/
14
function initialiserElementsPliables() {
14
function initialiserElementsPliables() {
15
 
15
 
16
	$('.pliage h4').addClass('lien_pliage');
16
	$('.pliage h4').addClass('lien_pliage');
17
 
17
 
18
	$('.pliage ul').hide();
18
	$('.pliage ul').hide();
19
	$('.pliage > ul:first-child').hide();
19
	$('.pliage > ul:first-child').hide();
20
 
20
 
21
	$('.1er_element_date ul').show();
21
	$('.1er_element_date ul').show();
22
	$('.1er_element_date > ul:first-child').show();
22
	$('.1er_element_date > ul:first-child').show();
23
 
23
 
24
	$('.lien_pliage').bind('click', function() {
24
	$('.lien_pliage').bind('click', function() {
25
		
25
 
26
		$(this).nextAll('ul').slideToggle();
26
		$(this).nextAll('ul').slideToggle();
27
		return false;
27
		return false;
28
	});
28
	});
29
}
29
}
30
 
30
 
31
$('.pliage').ready(function() {
31
$('.pliage').ready(function() {
32
	initialiserElementsPliables();
32
	initialiserElementsPliables();
33
});
33
});
34
 
34
 
35
 
35
 
36
/** 
36
/**
37
	************************************************************************************************
37
	************************************************************************************************
38
	************************************************************************************************
38
	************************************************************************************************
39
	
39
 
40
	   Fonctions de gestion des onglets du formulaire de saisie d'espèce
40
	   Fonctions de gestion des onglets du formulaire de saisie d'espèce
41
	
41
 
42
	************************************************************************************************
42
	************************************************************************************************
43
	************************************************************************************************
43
	************************************************************************************************
44
**/  
44
**/
45
function initialiserOnglets() {
45
function initialiserOnglets() {
46
	$(".contenu_onglet").hide(); 
46
	$(".contenu_onglet").hide();
47
	$("ul.liste_onglets li:first").addClass("active").show(); 
47
	$("ul.liste_onglets li:first").addClass("active").show();
48
	$(".contenu_onglet:first").show();
48
	$(".contenu_onglet:first").show();
49
 
49
 
50
	$("ul.liste_onglets li").click(function() {
50
	$("ul.liste_onglets li").click(function() {
51
 
51
 
52
		$("ul.liste_onglets li").removeClass("active"); 
52
		$("ul.liste_onglets li").removeClass("active");
53
		$(this).addClass("active"); 
53
		$(this).addClass("active");
54
		$(".contenu_onglet").hide();
54
		$(".contenu_onglet").hide();
55
 
55
 
56
		var activeTab = $(this).find("a").attr("href"); 
56
		var activeTab = $(this).find("a").attr("href");
57
		$(activeTab).fadeIn();
57
		$(activeTab).fadeIn();
58
		return false;
58
		return false;
59
	});
59
	});
60
}
60
}
61
 
61
 
62
$('.contenu_onglet').ready(function() {
62
$('.contenu_onglet').ready(function() {
63
	initialiserOnglets();
63
	initialiserOnglets();
64
});
64
});
65
 
65
 
66
function agrandirZoneCLicBoutonsRadios() {
66
function agrandirZoneCLicBoutonsRadios() {
67
	
67
 
68
	$('.formulaire_informations_espece_mini').addClass("element_cliquable");
68
	$('.formulaire_informations_espece_mini').addClass("element_cliquable");
69
	
69
 
70
	$('#form_saisie_espece').children('input[type="submit"]').hide();
70
	$('#form_saisie_espece').children('input[type="submit"]').hide();
71
	$('.formulaire_informations_espece_mini').children('input[type="radio"]').hide();
71
	$('.formulaire_informations_espece_mini').children('input[type="radio"]').hide();
72
	$('.titre_type').hide();
72
	$('.titre_type').hide();
73
	
73
 
74
	$('.formulaire_informations_espece_mini').bind('click',function() {
74
	$('.formulaire_informations_espece_mini').bind('click',function() {
75
		$(this).children('input[type="radio"]').attr('checked','checked');
75
		$(this).children('input[type="radio"]').attr('checked','checked');
76
		$('.formulaire_informations_espece_mini').removeClass('element_clique');
76
		$('.formulaire_informations_espece_mini').removeClass('element_clique');
77
		$(this).addClass('element_clique');
77
		$(this).addClass('element_clique');
78
		
78
 
79
		$('#form_saisie_espece').submit();
79
		$('#form_saisie_espece').submit();
80
	});	
80
	});
81
}
81
}
82
 
82
 
83
$('#form_saisie_espece').ready(function() {
83
$('#form_saisie_espece').ready(function() {
84
	agrandirZoneCLicBoutonsRadios();
84
	agrandirZoneCLicBoutonsRadios();
85
});
85
});
86
 
86
 
87
 
87
 
88
 
88
 
89
 
89
 
90
/** 
90
/**
91
	************************************************************************************************
91
	************************************************************************************************
92
	************************************************************************************************
92
	************************************************************************************************
93
	
93
 
94
	   Fonctions permettant de transformer les cases du tableau d'évenements en mini formulaire
94
	   Fonctions permettant de transformer les cases du tableau d'évenements en mini formulaire
95
	
95
 
96
	************************************************************************************************
96
	************************************************************************************************
97
	************************************************************************************************
97
	************************************************************************************************
98
**/
98
**/
99
 
99
 
100
htmlEnCours = '';
100
htmlEnCours = '';
101
elementEnCours = null;
101
elementEnCours = null;
102
ancienneValeurEnCours = null;
102
ancienneValeurEnCours = null;
-
 
103
id_formulaire = null;
103
 
104
 
104
function initialiserLignesCliquables() {
105
function initialiserLignesCliquables() {
105
	
106
 
106
	$('.conteneur_element_modifier').hide();
-
 
107
	
-
 
108
	$(".date_observation_individu").each(function() {
-
 
109
		
-
 
110
		$(this).bind('click', function() {
-
 
111
			
-
 
112
			if($(this).hasClass('element_clique')) {
-
 
113
				return false;
-
 
114
			} else {
-
 
115
				
-
 
116
				conteneur_obs = $(this).children('span');
-
 
117
				id_formulaire = conteneur_obs.attr('id');
-
 
118
				
-
 
119
				remplacerElementDateParFormulaireAjax(id_formulaire, $(this));
-
 
120
										
-
 
121
				return false;
-
 
122
			}
-
 
123
		});
-
 
124
	});	
-
 
125
}
-
 
126
 
-
 
127
function initialiserCalendrierFormulaire() {
-
 
128
	
-
 
129
	dateMin = getDateMinCalendrier();
-
 
130
	dateMax = getDateMaxCalendrier();
107
	$('.conteneur_element_modifier').hide();
131
	
-
 
132
	$(".calendrier").each(function() {
-
 
133
		$(this).find("input").datepicker({
-
 
134
			disabled: true,
-
 
135
			altFormat: 'dd/mm/yyyy',
108
 
136
			minDate: dateMin,
-
 
137
			maxDate: dateMax
-
 
138
		
-
 
139
		});
-
 
140
	});
109
	$(".date_observation_individu").live("click", function(e) {
141
}
110
		e.preventDefault();
-
 
111
 
-
 
112
		if($(e.target).hasClass('conteneur_supprimer_observation') || $(e.target).hasClass('supprimer_observation')) {
-
 
113
			return;
-
 
114
		}
-
 
115
 
-
 
116
		$('.element_clique').removeClass('element_clique');
-
 
117
		if($(this).hasClass('element_clique')) {
-
 
118
			fermerDatePicker();
-
 
119
			return false;
-
 
120
		} else {
142
 
121
			$(this).addClass('element_clique');
-
 
122
			afficherSaisieObservation($(this));
-
 
123
			return false;
-
 
124
		}
143
$(document).ready(function() {
125
	});
144
	initialiserCalendrierFormulaire();
126
 
145
 
127
	$(".date_observation_individu .conteneur_supprimer_observation").live("click", function(e) {
146
});
128
		e.preventDefault();
-
 
129
		if(window.confirm('Êtes-vous sûr de vouloir supprimer cette observation ?')) {
147
 
130
			// les obs ne sont jamais vraiment supprimées
148
function estUneDateValide(peutEtreUneDate) {
-
 
149
	var reg= new RegExp("^[0-3][0-9][/]{1}[0-1][0-2][/]{1}[0-9]{4}$","g");
131
			// mais seulement remplacées par des dates au format 00/00/yyyy
150
	return reg.test(peutEtreUneDate);
-
 
151
}
132
			envoyerRequeteAjaxSaisieObservation('', $(this).parent('.date_observation_individu'));
152
 
133
		}
153
function getAnneeEnCoursDeConsultation() {
134
	});
154
	
135
 
155
	anneeEnCours = jQuery.trim($("#annee_en_cours").html());
136
	// pour fermer le datepicker sur esc
156
	
-
 
157
	if(typeof(anneeEnCours)=='undefined'){ 
137
	$(document).keyup(function(e) {
158
		dateCourante = new Date(); 
138
	  if (e.keyCode === 27) {
159
		anneeEnCours = dateCourante.getFullYear(); 
-
 
160
	}
-
 
161
	
-
 
162
	return anneeEnCours;
-
 
163
}
-
 
164
 
139
			$('.element_clique').removeClass('element_clique');
165
function getDateMinCalendrier() {
140
			fermerDatePicker();   // esc
166
	anneeEnCours = getAnneeEnCoursDeConsultation();
141
		}
167
	dateMin = '01/01/'+anneeEnCours;
-
 
168
	
142
	});
169
	return dateMin;
143
}
-
 
144
 
170
}
145
function afficherSaisieObservation($obs) {
171
 
-
 
-
 
146
 
-
 
147
	fermerDatePicker();
-
 
148
 
172
function getDateMaxCalendrier() {
149
	var dateMin = getDateMinCalendrier();
173
	
150
	var dateMax = getDateMaxCalendrier();
174
	anneeEnCours = getAnneeEnCoursDeConsultation();
151
 
175
	
-
 
176
	dateMax = '31/12/'+anneeEnCours;
-
 
177
	
-
 
178
	dateCourante = new Date();
-
 
179
	
-
 
180
	if(anneeEnCours == dateCourante.getFullYear()) {
-
 
181
		dateMax = dateCourante.getDate()+'/'+(dateCourante.getMonth()+ 1)+'/'+anneeEnCours;
152
	var dateCouranteStr = $obs.data('date-observation');
182
	}
-
 
183
	
-
 
184
	return dateMax;
-
 
185
}
-
 
186
 
153
	var dateCourante = new Date();
187
/** Fonctions de manipulation des éléments du tableau pour les transformer en élements cliquables et calendriers **/
154
	if(!!dateCouranteStr && dateCouranteStr != '' && dateCouranteStr != '+') {
188
function initialiserMiniCalendrierFormulaire(id_element) {
155
		var jour   = parseInt(dateCouranteStr.substring(0,2));
189
	
156
		var mois  = parseInt(dateCouranteStr.substring(3,5));
190
	dateMin = getDateMinCalendrier();
157
		var annee   = parseInt(dateCouranteStr.substring(6,10));
191
	dateMax = getDateMaxCalendrier();
158
		dateCourante = new Date(annee, mois-1, jour);
192
	
159
	}
193
	$('#'+id_element)
160
 
194
	.datepicker({
161
	$obs.find('.datepicker_container').datepicker({
195
		disabled: true,
162
		disabled: true,
196
		constrainInput: true,
163
		constrainInput: true,
197
		altFormat: 'dd/mm/yyyy',
164
		altFormat: 'dd/mm/yyyy',
198
		minDate: dateMin,
165
		minDate: dateMin,
199
		maxDate: dateMax,
166
		maxDate: dateMax,
-
 
167
		changeMonth: true,
-
 
168
		defaultDate: dateCourante,
200
		onSelect: function(dateText, inst) {
169
		onSelect: function(dateText, inst) {
201
			$('#'+id_element).val(dateText);
170
			validerSaisieObservation(dateText, $obs)
202
			donnees_obs = collecterDonneesMiniFormulaire(id_formulaire);
-
 
203
			envoyerRequeteAjaxValidationMiniFormulaire(donnees_obs, id_formulaire);
-
 
204
		},
171
		},
205
		onClose: function(dateText, inst) {
172
		beforeShowDay: function(date) {
-
 
173
			var dates_a_exclure = getDatesSaisiesPourStadeEtIndividu($obs.data('id-individu'), $obs.data('id-stade-observation'));
-
 
174
      var string = jQuery.datepicker.formatDate('dd/mm/yy', date);
206
			gererFermetureMiniCalendrier(dateText,id_formulaire);
175
      return [dates_a_exclure.indexOf(string) == -1]
207
		}
176
    }
208
	});
177
	});
209
 
178
 
-
 
179
	$obs.datepicker("show");
210
	$('#'+id_element).datepicker( "show" );
180
	$('.ui-datepicker').attr("title", "Appuyez sur échap pour annuler l'édition");
211
}
181
}
212
 
182
 
213
function gererFermetureMiniCalendrier(dateText, id_formulaire) {
-
 
214
	
183
function validerSaisieObservation(dateStr, $obs) {
215
	ancienne_valeur_date = jQuery.trim(ancienneValeurEnCours);
-
 
216
	nouvelle_valeur_date = jQuery.trim(dateText);
-
 
217
	
-
 
218
	if(nouvelle_valeur_date == '' && ancienne_valeur_date != '-' && ancienne_valeur_date != nouvelle_valeur_date) {
-
 
219
		if(window.confirm("Voulez vous supprimer cette observation ?")) {
-
 
220
			$('#'+id_formulaire).val(nouvelle_valeur_date);
184
 
221
			donnees_obs = collecterDonneesMiniFormulaire(id_formulaire);
-
 
222
			envoyerRequeteAjaxValidationMiniFormulaire(donnees_obs, id_formulaire);
-
 
223
		} else {
-
 
224
			$('#'+id_formulaire).val(ancienne_valeur_date);
-
 
225
			remplacerMiniFormulaireParElementDate(id_formulaire);	
185
	if(estUneDateValide(dateStr)) {
226
		}
186
		envoyerRequeteAjaxSaisieObservation(dateStr, $obs);
227
	}
187
	}
228
}
188
}
229
 
189
 
230
function remplacerElementDateParFormulaireAjax(id_element, conteneur_selectionne) {
190
function formaterDonneesObservationPourEnvoi(dateStr, $obs) {
231
	
191
 
232
	if(elementEnCours != null) {
-
 
233
		elementEnCours.removeClass('element_clique');
-
 
234
		elementEnCours.html(htmlEnCours);
192
	if(dateStr == null ) {
235
		ancienneValeurEnCours = null;
193
		return false ;
236
	}
194
	}
237
	
195
 
238
	ancienneValeurEnCours = conteneur_selectionne.children('span').html()
196
	var anneeEnCours = getAnneeEnCoursDeConsultation();
239
	elementEnCours = conteneur_selectionne;
197
	if(jQuery.trim(dateStr) == '') {
-
 
198
		dateStr = '00/00/'+anneeEnCours;
240
	htmlEnCours = conteneur_selectionne.html();
199
	}
241
	
200
 
242
	conteneur_obs = $('#'+id_element);
201
	donnees_obs = {
243
	valeur_date = conteneur_obs.html();
202
		"id_individu": $obs.data('id-individu'),
244
	valeur_date = valeur_date.replace('-','');
-
 
245
		
203
		"id_evenement": $obs.data('id-stade-observation'),
246
	conteneur_selectionne.addClass('element_clique');
-
 
247
	conteneur_selectionne.html('<span class="calendrier"><input type="text" value="'+jQuery.trim(valeur_date)+'" class="calendrier" id="'+id_formulaire+'" size="7" maxlenght="10" /></div>');			
204
		"date_evenement": dateStr,
248
	initialiserMiniCalendrierFormulaire(id_formulaire);
-
 
249
	
205
		"annee_en_cours": anneeEnCours
250
}
-
 
251
 
-
 
252
function remplacerMiniFormulaireParElementDate(id_element) { 
-
 
253
	
-
 
254
	valeur_date_pour_stade = $('#'+id_element).val();
206
	};
255
	
207
 
256
	if(jQuery.trim(valeur_date_pour_stade) == '') {
208
	if(!!$obs.data('id-observation')) {
257
		valeur_date_pour_stade = '-';
209
		donnees_obs.id_observation = $obs.data('id-observation');
258
	}
-
 
259
	
-
 
260
	elementEnCours.html('<span id="'+id_element+'">'+valeur_date_pour_stade+' </span>');
-
 
261
	elementEnCours.removeClass('element_clique');
-
 
262
	elementEnCours = null;
-
 
-
 
210
	}
263
	ancienneValeurEnCours = null;
211
 
264
 
212
	return donnees_obs;
265
}
213
}
266
 
214
 
267
 
215
 
268
/** Fonctions d'envoi et de récupération des élements du formulaire ajax **/
216
/** Fonctions d'envoi et de récupération des élements du formulaire ajax **/
269
function envoyerRequeteAjaxValidationMiniFormulaire(donnees_obs, id_formulaire) {
217
function envoyerRequeteAjaxSaisieObservation(dateStr, $obs) {
-
 
218
 
-
 
219
	var est_obs_existante = !!$obs.data('id-observation');
-
 
220
	var donnees_obs = formaterDonneesObservationPourEnvoi(dateStr, $obs);
270
		
221
 
271
	url_page_courante = document.URL;
222
	url_page_courante = document.URL;
272
	url_page_courante = url_page_courante.replace('module=Individu','module=Observation');
223
	url_page_courante = url_page_courante.replace('module=Individu','module=Observation');
273
	url_page_courante = url_page_courante.replace('action=afficherListeIndividu','action=validerFormulaireModificationObservationAjax');
224
	url_page_courante = url_page_courante.replace('action=afficherListeIndividu','action=validerFormulaireModificationObservationAjax');
274
	url_ajax = url_page_courante.replace('action=validerFormulaireSaisieIndividu','action=validerFormulaireModificationObservationAjax');
225
	url_ajax = url_page_courante.replace('action=validerFormulaireSaisieIndividu','action=validerFormulaireModificationObservationAjax');
275
		
226
 
-
 
227
	$conteneurAjout = null;
-
 
228
	if(!est_obs_existante) {
-
 
229
		var id_conteneur_ajout = 'ajouter_observation_individu_'+donnees_obs['id_individu']+'_evenement_'+donnees_obs['id_evenement'];
-
 
230
		var $conteneurAjout = $('#'+id_conteneur_ajout).clone();
-
 
231
	}
-
 
232
 
-
 
233
	var donnees_obs = formaterDonneesObservationPourEnvoi(dateStr, $obs);
276
	$.post(url_ajax, donnees_obs, function(obj_retour) {
234
	$.post(url_ajax, donnees_obs, function(obj_retour) {
277
		
235
 
-
 
236
		if(obj_retour.data.erreurs) {
-
 
237
			var message = 'Une ou plusieurs erreurs se sont produites : '+"\n";
-
 
238
			for (var key in obj_retour.data.erreurs) {
-
 
239
  		if (obj_retour.data.erreurs.hasOwnProperty(key))
-
 
240
    		message += '- '+obj_retour.data.erreurs[key]+"\n";
-
 
241
			}
-
 
242
			window.alert(message);
-
 
243
			return;
-
 
244
		}
-
 
245
 
278
		if(obj_retour.reponse === 'OK') {
246
		if(obj_retour.reponse === 'OK') {
-
 
247
 
-
 
248
			// les obs ne sont jamais vraiment supprimées
-
 
249
			// mais seulement remplacées par des dates au format 00/00/yyyy
-
 
250
			if(estUneDateSuppressionObs(dateStr)) {
-
 
251
				$obs.remove();
-
 
252
				delete $obs;
-
 
253
				return;
-
 
254
			}
-
 
255
 
-
 
256
			$obs.find('.date_observation').text(dateStr);
-
 
257
			$obs.data('date-observation', dateStr);
-
 
258
 
-
 
259
			if(!est_obs_existante) {
-
 
260
				$obs.removeClass('ajouter_observation');
-
 
261
				$obs.attr('title', 'Cliquez pour modifier la date de cette observation')
279
			remplacerMiniFormulaireParElementDate(id_formulaire);
262
				$obs.data('id-observation', obj_retour.data.id_observation);
-
 
263
 
-
 
264
				var id_conteneur_observation = 'individu_'+donnees_obs['id_individu']+'_evenement_'+donnees_obs['id_evenement']+'_observation_'+obj_retour.data.id_observation;
-
 
265
				$obs.attr('id', id_conteneur_observation);
-
 
266
 
-
 
267
				$obs.after($conteneurAjout);
-
 
268
			}
-
 
269
 
-
 
270
			$('.element_clique').removeClass('element_clique');
-
 
271
			fermerDatePicker();
280
		}
272
		}
281
	});
273
	});
282
}
274
}
283
 
275
 
-
 
276
function estUneDateSuppressionObs(dateStr) {
-
 
277
	var date_vide_pattern = /^00\/00\/\d{4}$/;
284
function collecterDonneesMiniFormulaire(id_formulaire) {
278
	return dateStr == '' || date_vide_pattern.test(dateStr);
285
	
-
 
286
	valeur_date_pour_stade = $('#'+id_formulaire).val();
279
}
-
 
280
 
287
	
281
function fermerDatePicker() {
288
	if(valeur_date_pour_stade == null ) {
282
	if($(".hasDatepicker").length == 0) {
289
		return false ;
283
		return;
290
	}
284
	}
-
 
285
 
291
	
286
	$(".hasDatepicker").each(function() {
292
	if(jQuery.trim(valeur_date_pour_stade) == '') {
287
		$(this).datepicker("destroy");
293
		valeur_date_pour_stade = '00/00/'+anneeEnCours;
288
		$(this).removeClass(".hasDatepicker").removeAttr('id');
294
	}
289
	});
295
	
-
 
296
	id_individu_stade_obs = id_formulaire.split('_');
290
}
297
	
291
 
298
	stade_obs = 'observation_'+id_individu_stade_obs[3];
292
function obtenirAttributsData(el) {
299
	date_annee_en_cours = jQuery.trim($("#annee_en_cours").html());
293
	return [].filter.call(el.attributes, function(at) { return /^data-/.test(at.name); });
300
	
-
 
301
	donnees_obs = { "id_individu": id_individu_stade_obs[1], 
-
 
302
					"annee_en_cours": date_annee_en_cours
-
 
303
					};
294
}
-
 
295
 
304
	
296
// vérifie qu'une date est au format d/m/y
305
	identifiant_observation = 'observation_'+id_individu_stade_obs[3];
-
 
-
 
297
// merci stacky https://stackoverflow.com/questions/5812220/how-to-validate-a-date
-
 
298
function estUneDateValide(s) {
306
	
299
  var bits = s.split('/');
307
	donnees_obs[identifiant_observation] = valeur_date_pour_stade;
-
 
308
	
300
  var d = new Date(bits[2], bits[1] - 1, bits[0]);
309
	return donnees_obs;
301
  return d && (d.getMonth() + 1) == bits[1];
-
 
302
}
-
 
303
 
-
 
304
function getDatesSaisiesPourStadeEtIndividu(id_individu, id_stade) {
-
 
305
	var selecteur_data = '[data-id-individu="'+id_individu+'"]'+
-
 
306
												'[data-id-stade-observation="'+id_stade+'"]';
-
 
307
 
-
 
308
	return $('.date_observation_individu'+selecteur_data).map(function() {
-
 
309
    return $(this).data("date-observation");
-
 
310
	}).get();
-
 
311
}
-
 
312
 
-
 
313
function getAnneeEnCoursDeConsultation() {
-
 
314
 
-
 
315
	anneeEnCours = jQuery.trim($("#annee_en_cours").html());
-
 
316
 
-
 
317
	if(typeof(anneeEnCours)=='undefined'){
-
 
318
		dateCourante = new Date();
-
 
319
		anneeEnCours = dateCourante.getFullYear();
-
 
320
	}
-
 
321
 
-
 
322
	return anneeEnCours;
-
 
323
}
-
 
324
 
-
 
325
function getDateMinCalendrier() {
-
 
326
	anneeEnCours = getAnneeEnCoursDeConsultation();
-
 
327
	dateMin = '01/01/'+anneeEnCours;
-
 
328
 
-
 
329
	return dateMin;
-
 
330
}
-
 
331
 
-
 
332
function getDateMaxCalendrier() {
-
 
333
 
-
 
334
	anneeEnCours = getAnneeEnCoursDeConsultation();
-
 
335
 
-
 
336
	dateMax = '31/12/'+anneeEnCours;
-
 
337
 
-
 
338
	dateCourante = new Date();
-
 
339
 
-
 
340
	if(anneeEnCours == dateCourante.getFullYear()) {
-
 
341
		dateMax = dateCourante.getDate()+'/'+(dateCourante.getMonth()+ 1)+'/'+anneeEnCours;
-
 
342
	}
-
 
343
 
310
}
344
	return dateMax;
311
 
345
}
312
 
346
 
313
$('#saisie_liste_evenements').ready(function() {
347
$('#saisie_liste_evenements').ready(function() {
314
	initialiserLignesCliquables();
348
	initialiserLignesCliquables();
315
});
349
});
316
 
350
 
317
 
351
 
318
 
352
 
319
 
353
 
320
/** 
354
/**
321
	************************************************************************************************
355
	************************************************************************************************
322
	************************************************************************************************
356
	************************************************************************************************
323
	
357
 
324
	    Fonctions concernant la carte permettant de pointer d'afficher l'emplacement des stations
358
	    Fonctions concernant la carte permettant de pointer d'afficher l'emplacement des stations
325
	
359
 
326
	************************************************************************************************
360
	************************************************************************************************
327
	************************************************************************************************
361
	************************************************************************************************
328
**/  
362
**/
329
var map;
363
var map;
330
var marker;
364
var marker;
331
var liste_localite_en_cours;
365
var liste_localite_en_cours;
332
var indice_commune_en_cours;
366
var indice_commune_en_cours;
333
var liste_auto_completion_a_le_focus;
367
var liste_auto_completion_a_le_focus;
334
var timerRequeteAutocompletion;
368
var timerRequeteAutocompletion;
335
var timerAffichageAutocompletion;
369
var timerAffichageAutocompletion;
336
 
370
 
337
 
371
 
338
function cacherElementsRafraichissables() {
372
function cacherElementsRafraichissables() {
339
	$('.rafraichissable input').attr('disabled', 'disabled');
373
	$('.rafraichissable input').attr('disabled', 'disabled');
340
	$('.rafraichissable input[type="text"]').addClass("chargement");
374
	$('.rafraichissable input[type="text"]').addClass("chargement");
341
}
375
}
342
 
376
 
343
function montrerElementsRafraichissables() {
377
function montrerElementsRafraichissables() {
344
	$('.rafraichissable input').removeAttr('disabled');
378
	$('.rafraichissable input').removeAttr('disabled');
345
	$('.chargement').removeClass("chargement");
379
	$('.chargement').removeClass("chargement");
346
}
380
}
347
 
381
 
348
function ajouterAutoCompletionCommune() {
382
function ajouterAutoCompletionCommune() {
349
	
383
 
350
	$('input#station_commune').after('<div class="conteneur_suggestions"></div>');
384
	$('input#station_commune').after('<div class="conteneur_suggestions"></div>');
351
	$('input#station_commune').parent().addClass('autocompletion');
385
	$('input#station_commune').parent().addClass('autocompletion');
352
	$('input#station_commune').attr('autocomplete','off');
386
	$('input#station_commune').attr('autocomplete','off');
353
	$('.conteneur_suggestions').hide();
387
	$('.conteneur_suggestions').hide();
354
	rendreListeAutoCompletionInteractive('input#station_commune');
388
	rendreListeAutoCompletionInteractive('input#station_commune');
355
}
389
}
356
 
390
 
357
function ajouterListenerFormulaireSaisieLatLon() {
391
function ajouterListenerFormulaireSaisieLatLon() {
358
				
392
 
359
	$('input#localiser_lat_lon').click(function() {
393
	$('input#localiser_lat_lon').click(function() {
360
		verifierEtLocaliserCoordonnees();
394
		verifierEtLocaliserCoordonnees();
361
	});
395
	});
362
}
396
}
363
 
397
 
364
function carteEstEnSaisie() {
398
function carteEstEnSaisie() {
365
	return ($('#conteneur_form_liens_lat_lon').length > 0);
399
	return ($('#conteneur_form_liens_lat_lon').length > 0);
366
}
400
}
367
 
401
 
368
function verifierEtLocaliserCoordonnees() {
402
function verifierEtLocaliserCoordonnees() {
369
	
403
 
370
	lat ;
404
	lat ;
371
	lon;
405
	lon;
372
	
406
 
373
	if(carteEstEnSaisie()) {
407
	if(carteEstEnSaisie()) {
374
		lat = $('#station_lat').val();
408
		lat = $('#station_lat').val();
375
		lon = $('#station_lon').val();
409
		lon = $('#station_lon').val();
376
		
410
 
377
		obtenirInformationsPourCoordonnees(lat, lon);
411
		obtenirInformationsPourCoordonnees(lat, lon);
378
	} else {
412
	} else {
379
		var lat = jQuery.trim($('#station_lat').html());
413
		var lat = jQuery.trim($('#station_lat').html());
380
		var lon = jQuery.trim($('#station_lon').html());
414
		var lon = jQuery.trim($('#station_lon').html());
381
	}
415
	}
382
	
416
 
383
	if(jQuery.trim(lat) == '' || jQuery.trim(lon) == '') {
417
	if(jQuery.trim(lat) == '' || jQuery.trim(lon) == '') {
384
		return;
418
		return;
385
	}
419
	}
386
	
420
 
387
	if(!isNaN(lat) && lat.length > 0 && !isNaN(lon) && lon.length > 0) {
421
	if(!isNaN(lat) && lat.length > 0 && !isNaN(lon) && lon.length > 0) {
388
		
422
 
389
	} else {
423
	} else {
390
		window.alert("coordonnées invalides");
424
		window.alert("coordonnées invalides");
391
	}
425
	}
392
	
426
 
393
	var positionMarker = new google.maps.LatLng(lat, lon);
427
	var positionMarker = new google.maps.LatLng(lat, lon);
394
	
428
 
395
	marker.setPosition(positionMarker);
429
	marker.setPosition(positionMarker);
396
	map.setCenter(positionMarker);
430
	map.setCenter(positionMarker);
397
	map.setZoom(12);
431
	map.setZoom(12);
398
}
432
}
399
 
433
 
400
function obtenirInformationsPourCoordonnees(lat, lon) {
434
function obtenirInformationsPourCoordonnees(lat, lon) {
401
		
435
 
402
	lat = jQuery.trim(lat);
436
	lat = jQuery.trim(lat);
403
	lon = jQuery.trim(lon);	
437
	lon = jQuery.trim(lon);
404
	
438
 
405
	if(isNaN(lat) || lat.length <= 0 || isNaN(lon) || lon.length <= 0) {
439
	if(isNaN(lat) || lat.length <= 0 || isNaN(lon) || lon.length <= 0) {
406
		return;
440
		return;
407
	}
441
	}
408
	
442
 
409
	cacherElementsRafraichissables();
443
	cacherElementsRafraichissables();
410
 
444
 
411
	$.get(urlBaseJrest+'OdsCommune/informationsPourCoordonnees/?lat='+lat+'&lon='+lon, function(data) {	
445
	$.get(urlBaseJrest+'OdsCommune/informationsPourCoordonnees/?lat='+lat+'&lon='+lon, function(data) {
412
		
446
 
413
		infos_localites = jQuery.parseJSON(data);
447
		infos_localites = jQuery.parseJSON(data);
414
		$('#station_alt').val(infos_localites.alt);
448
		$('#station_alt').val(infos_localites.alt);
415
		
449
 
416
		if(infos_localites.commune != null && infos_localites.commune != '') {
450
		if(infos_localites.commune != null && infos_localites.commune != '') {
417
		  $('#station_commune').val(infos_localites.commune);
451
		  $('#station_commune').val(infos_localites.commune);
418
		  $('#station_code_insee').val(infos_localites.code_insee);
452
		  $('#station_code_insee').val(infos_localites.code_insee);
419
		}
453
		}
420
		
454
 
421
		montrerElementsRafraichissables();
455
		montrerElementsRafraichissables();
422
		
456
 
423
	});
457
	});
424
 
458
 
425
}
459
}
426
 
460
 
427
function obtenirInformationsPourCommune(nom_commune) {
461
function obtenirInformationsPourCommune(nom_commune) {
428
	
462
 
429
	if(jQuery.trim(nom_commune) == '') {
463
	if(jQuery.trim(nom_commune) == '') {
430
		$('.conteneur_suggestions').hide();
464
		$('.conteneur_suggestions').hide();
431
		return;
465
		return;
432
	}
466
	}
433
	
467
 
434
	$.get(urlBaseJrest+'OdsCommune/informationsPourCommune/?commune='+nom_commune, function(data) {	
468
	$.get(urlBaseJrest+'OdsCommune/informationsPourCommune/?commune='+nom_commune, function(data) {
435
		
469
 
436
		infos_localites = jQuery.parseJSON(data);
470
		infos_localites = jQuery.parseJSON(data);
437
		afficherListeAutoCompletion(infos_localites);		
471
		afficherListeAutoCompletion(infos_localites);
438
	});
472
	});
439
}
473
}
440
 
474
 
441
function afficherListeAutoCompletion(tableau_localites) {
475
function afficherListeAutoCompletion(tableau_localites) {
442
	
476
 
443
	liste_localite_en_cours = tableau_localites;
477
	liste_localite_en_cours = tableau_localites;
444
	
478
 
445
	html_liste_localite = '<ul class="liste_suggestions">';
479
	html_liste_localite = '<ul class="liste_suggestions">';
446
	
480
 
447
	for(i = 0; i< tableau_localites.length; i++) {
481
	for(i = 0; i< tableau_localites.length; i++) {
448
		html_liste_localite += '<li id="commune_'+i+'" class="element_auto_completion_commune">'+tableau_localites[i]['commune']+'  ('+tableau_localites[i]['dpt']+')</li>';
482
		html_liste_localite += '<li id="commune_'+i+'" class="element_auto_completion_commune">'+tableau_localites[i]['commune']+'  ('+tableau_localites[i]['dpt']+')</li>';
449
	}
483
	}
450
	
484
 
451
	html_liste_localite += '</ul>';
485
	html_liste_localite += '</ul>';
452
	
486
 
453
	$('.conteneur_suggestions').html(html_liste_localite);
487
	$('.conteneur_suggestions').html(html_liste_localite);
454
	
488
 
455
	$('.element_auto_completion_commune').hover(function() {
489
	$('.element_auto_completion_commune').hover(function() {
456
		indice = $(this).attr('id').split('_')[1];
490
		indice = $(this).attr('id').split('_')[1];
457
		mettreEnSurbrillanceCommune(indice);
491
		mettreEnSurbrillanceCommune(indice);
458
	});
492
	});
459
	
493
 
460
	$('.element_auto_completion_commune').click(function() {
494
	$('.element_auto_completion_commune').click(function() {
461
		indice = $(this).attr('id').split('_')[1];
495
		indice = $(this).attr('id').split('_')[1];
462
		selectionnerCommune(indice);
496
		selectionnerCommune(indice);
463
	});
497
	});
464
	
498
 
465
	if(tableau_localites.length > 0) {
499
	if(tableau_localites.length > 0) {
466
		$('.conteneur_suggestions').show();
500
		$('.conteneur_suggestions').show();
467
		
501
 
468
		mettreEnSurbrillanceCommune(0);
502
		mettreEnSurbrillanceCommune(0);
469
	}
503
	}
470
}
504
}
471
 
505
 
472
function mettreEnSurbrillanceCommune(indice) {
506
function mettreEnSurbrillanceCommune(indice) {
473
	
507
 
474
	if(indice_commune_en_cours != null) { 
508
	if(indice_commune_en_cours != null) {
475
		$('#commune_'+indice_commune_en_cours).removeClass('element_selectionne');
509
		$('#commune_'+indice_commune_en_cours).removeClass('element_selectionne');
476
	}
510
	}
477
	$('#commune_'+indice).addClass('element_selectionne');
511
	$('#commune_'+indice).addClass('element_selectionne');
478
	indice_commune_en_cours = indice;
512
	indice_commune_en_cours = indice;
479
	
513
 
480
	reprogrammerTimerPourCacherListeAutoCompletion();
514
	reprogrammerTimerPourCacherListeAutoCompletion();
481
}
515
}
482
 
516
 
483
function rendreListeAutoCompletionInteractive(selecteur) {
517
function rendreListeAutoCompletionInteractive(selecteur) {
484
	
518
 
485
	$(selecteur).keyup(function(event) {
519
	$(selecteur).keyup(function(event) {
486
		if(event.which == 8 || (event.which >= 48 && event.which <= 90)) { 
520
		if(event.which == 8 || (event.which >= 48 && event.which <= 90)) {
487
			
521
 
488
			reprogrammerTimerPourCacherListeAutoCompletion();
522
			reprogrammerTimerPourCacherListeAutoCompletion();
489
			reprogrammerTimerPourLancerRequeteCommune();
523
			reprogrammerTimerPourLancerRequeteCommune();
490
		}
524
		}
491
	});
525
	});
492
	
526
 
493
	$(selecteur).keydown(function(event) {
527
	$(selecteur).keydown(function(event) {
494
		
528
 
495
		reprogrammerTimerPourCacherListeAutoCompletion();
529
		reprogrammerTimerPourCacherListeAutoCompletion();
496
		
530
 
497
		// entree
531
		// entree
498
		if(event.which==13){
532
		if(event.which==13){
499
			selectionnerCommune(indice_commune_en_cours);
533
			selectionnerCommune(indice_commune_en_cours);
500
			event.preventDefault();
534
			event.preventDefault();
501
		}
535
		}
502
		
536
 
503
		// haut
537
		// haut
504
		if(event.which == 38){
538
		if(event.which == 38){
505
			if(indice_commune_en_cours > 0) { 
539
			if(indice_commune_en_cours > 0) {
506
				mettreEnSurbrillanceCommune(indice_commune_en_cours - 1);
540
				mettreEnSurbrillanceCommune(indice_commune_en_cours - 1);
507
			}
541
			}
508
		}
542
		}
509
		
543
 
510
		// bas
544
		// bas
511
		if(event.which == 40){
545
		if(event.which == 40){
512
			if(indice_commune_en_cours < liste_localite_en_cours.length - 1) { 
546
			if(indice_commune_en_cours < liste_localite_en_cours.length - 1) {
513
				mettreEnSurbrillanceCommune(indice_commune_en_cours + 1);
547
				mettreEnSurbrillanceCommune(indice_commune_en_cours + 1);
514
			}
548
			}
515
		}
549
		}
516
	});
550
	});
517
	
551
 
518
	$('.conteneur_suggestions').blur(function() {
552
	$('.conteneur_suggestions').blur(function() {
519
		$('.conteneur_suggestions').hide();
553
		$('.conteneur_suggestions').hide();
520
	});
554
	});
521
}
555
}
522
 
556
 
523
function reprogrammerTimerPourCacherListeAutoCompletion() {
557
function reprogrammerTimerPourCacherListeAutoCompletion() {
524
	
558
 
525
	if(timerAffichageAutocompletion != null) {
559
	if(timerAffichageAutocompletion != null) {
526
		window.clearTimeout(timerAffichageAutocompletion);
560
		window.clearTimeout(timerAffichageAutocompletion);
527
	}
561
	}
528
	
562
 
529
	timerAffichageAutocompletion = window.setTimeout(function() {
563
	timerAffichageAutocompletion = window.setTimeout(function() {
530
		$('.conteneur_suggestions').hide();
564
		$('.conteneur_suggestions').hide();
531
	}, 2000);
565
	}, 2000);
532
}
566
}
533
 
567
 
534
function reprogrammerTimerPourLancerRequeteCommune() {
568
function reprogrammerTimerPourLancerRequeteCommune() {
535
	
569
 
536
	if(timerRequeteAutocompletion != null) {
570
	if(timerRequeteAutocompletion != null) {
537
		window.clearTimeout(timerRequeteAutocompletion);
571
		window.clearTimeout(timerRequeteAutocompletion);
538
	}
572
	}
539
	
573
 
540
	timerRequeteAutocompletion = window.setTimeout(function() {
574
	timerRequeteAutocompletion = window.setTimeout(function() {
541
		obtenirInformationsPourCommune($('input#station_commune').val());
575
		obtenirInformationsPourCommune($('input#station_commune').val());
542
	}, 350);
576
	}, 350);
543
}
577
}
544
 
578
 
545
function selectionnerCommune(indice) {
579
function selectionnerCommune(indice) {
546
	
580
 
547
	infos_commune = liste_localite_en_cours[indice];
581
	infos_commune = liste_localite_en_cours[indice];
548
	
582
 
549
	$('input#station_commune').val(infos_commune['commune']);
583
	$('input#station_commune').val(infos_commune['commune']);
550
	$('input#station_lat').val(infos_commune['lat']);
584
	$('input#station_lat').val(infos_commune['lat']);
551
	$('input#station_lon').val(infos_commune['lon']);
585
	$('input#station_lon').val(infos_commune['lon']);
552
	$('input#station_code_insee').val(infos_commune['code_insee']);
586
	$('input#station_code_insee').val(infos_commune['code_insee']);
553
	
587
 
554
	verifierEtLocaliserCoordonnees();
588
	verifierEtLocaliserCoordonnees();
555
	
589
 
556
	$('.conteneur_suggestions').hide();
590
	$('.conteneur_suggestions').hide();
557
}
591
}
558
 
592
 
559
function mettreAJourValeursFormulaire(latlon) {
593
function mettreAJourValeursFormulaire(latlon) {
560
 
594
 
561
	latlon = latlon.toString().split(','); 
595
	latlon = latlon.toString().split(',');
562
	
596
 
563
	lat = latlon[0].replace('(', '');
597
	lat = latlon[0].replace('(', '');
564
	lon = latlon[1].replace(')', '');
598
	lon = latlon[1].replace(')', '');
565
	
599
 
566
	$('#station_lat').val(latlon[0].replace('(', ''));
600
	$('#station_lat').val(latlon[0].replace('(', ''));
567
	$('#station_lon').val(latlon[1].replace(')', ''));
601
	$('#station_lon').val(latlon[1].replace(')', ''));
568
	
602
 
569
	obtenirInformationsPourCoordonnees(lat, lon);
603
	obtenirInformationsPourCoordonnees(lat, lon);
570
}
604
}
571
 
605
 
572
function initialiserCarte() {
606
function initialiserCarte() {
573
 
607
 
574
	if($('#map_canvas').length == 0) {
608
	if($('#map_canvas').length == 0) {
575
		return;
609
		return;
576
	}
610
	}
577
 
611
 
578
	var latlng = new google.maps.LatLng(47.0504, 2.2347);
612
	var latlng = new google.maps.LatLng(47.0504, 2.2347);
579
	var myOptions = {
613
	var myOptions = {
580
		zoom: 6,
614
		zoom: 6,
581
		center: latlng,
615
		center: latlng,
582
		mapTypeId: google.maps.MapTypeId.HYBRID
616
		mapTypeId: google.maps.MapTypeId.HYBRID
583
	};
617
	};
584
 
618
 
585
	map = new google.maps.Map(document.getElementById("map_canvas"),
619
	map = new google.maps.Map(document.getElementById("map_canvas"),
586
    	myOptions);
620
    	myOptions);
587
	
621
 
588
	marker = new google.maps.Marker({
622
	marker = new google.maps.Marker({
589
	      position: latlng,
623
	      position: latlng,
590
	      title:""
624
	      title:""
591
	});
625
	});
592
	
626
 
593
	if (carteEstEnSaisie()) {
627
	if (carteEstEnSaisie()) {
594
	
628
 
595
			marker.setDraggable(true);
629
			marker.setDraggable(true);
596
			
630
 
597
			google.maps.event.addListener(marker, 'dragend', function(event) {	
631
			google.maps.event.addListener(marker, 'dragend', function(event) {
598
				mettreAJourValeursFormulaire(marker.getPosition());
632
				mettreAJourValeursFormulaire(marker.getPosition());
599
			});
633
			});
600
			$('#conteneur_form_liens_lat_lon').ready(function() {
634
			$('#conteneur_form_liens_lat_lon').ready(function() {
601
				verifierEtLocaliserCoordonnees();
635
				verifierEtLocaliserCoordonnees();
602
				ajouterListenerFormulaireSaisieLatLon();
636
				ajouterListenerFormulaireSaisieLatLon();
603
				ajouterAutoCompletionCommune();
637
				ajouterAutoCompletionCommune();
604
			});
638
			});
605
	} else {
639
	} else {
606
		marker.setDraggable(false);
640
		marker.setDraggable(false);
607
		$('#conteneur_liens_lat_lon').ready(function() {
641
		$('#conteneur_liens_lat_lon').ready(function() {
608
			verifierEtLocaliserCoordonnees();
642
			verifierEtLocaliserCoordonnees();
609
		});
643
		});
610
	}
644
	}
611
	
645
 
612
	marker.setClickable(true);
646
	marker.setClickable(true);
613
		
647
 
614
	// To add the marker to the map, call setMap();
648
	// To add the marker to the map, call setMap();
615
	marker.setMap(map); 
649
	marker.setMap(map);
616
}
650
}
617
 
651
 
618
$('#map_canvas').ready(function() {
652
$('#map_canvas').ready(function() {
619
	initialiserCarte();
653
	initialiserCarte();
620
});
654
});
621
 
655
 
622
/** 
656
/**
623
************************************************************************************************
657
************************************************************************************************
624
************************************************************************************************
658
************************************************************************************************
625
 
659
 
626
    Fonctions généralistes s'appliquant automatiquement à certaines classes css
660
    Fonctions généralistes s'appliquant automatiquement à certaines classes css
627
 
661
 
628
************************************************************************************************
662
************************************************************************************************
629
************************************************************************************************
663
************************************************************************************************
630
**/ 
664
**/
631
 
665
 
632
function initialiserLiensNouvelleFenetre() {
666
function initialiserLiensNouvelleFenetre() {
633
  
667
 
634
	$('a.lien_nouvelle_fenetre').each(function() {
668
	$('a.lien_nouvelle_fenetre').each(function() {
635
	  var titre = $(this).attr("title");
669
	  var titre = $(this).attr("title");
636
	  $(this).attr("title", titre+" (s'ouvre dans une nouvelle fenêtre)");
670
	  $(this).attr("title", titre+" (s'ouvre dans une nouvelle fenêtre)");
637
	});
671
	});
638
  
672
 
639
	$('a.lien_nouvelle_fenetre').click(function(event) {
673
	$('a.lien_nouvelle_fenetre').click(function(event) {
640
		event.preventDefault();
674
		event.preventDefault();
641
		window.open($(this).attr('href'));
675
		window.open($(this).attr('href'));
642
	});
676
	});
643
}
677
}
644
 
678
 
645
function initialiserLiensSuppression() {
679
function initialiserLiensSuppression() {
646
	$('.lien_suppression').click(function() {
680
	$('.lien_suppression').click(function() {
647
		return window.confirm('Êtes vous sur de vouloir supprimer ?');
681
		return window.confirm('Êtes vous sur de vouloir supprimer ?');
648
	});
682
	});
649
}
683
}
650
 
684
 
651
$(document).ready(function() {
685
$(document).ready(function() {
652
	initialiserLiensSuppression();
686
	initialiserLiensSuppression();
653
	initialiserLiensNouvelleFenetre();
687
	initialiserLiensNouvelleFenetre();
654
});
688
});
655
 
689
 
656
 
690
 
657
 
691
 
658
/** 
692
/**
659
************************************************************************************************
693
************************************************************************************************
660
************************************************************************************************
694
************************************************************************************************
661
 
695
 
662
    Fonctions de debug permattant d'afficher les objets javascript à la manière de print_r
696
    Fonctions de debug permattant d'afficher les objets javascript à la manière de print_r
663
 
697
 
664
************************************************************************************************
698
************************************************************************************************
665
************************************************************************************************
699
************************************************************************************************
666
**/ 
700
**/
667
 
701
 
668
function dump(arr,level) {
702
function dump(arr,level) {
669
	var dumped_text = "";
703
	var dumped_text = "";
670
	if(!level) level = 0;
704
	if(!level) level = 0;
671
 
705
 
672
	//The padding given at the beginning of the line.
706
	//The padding given at the beginning of the line.
673
	var level_padding = "";
707
	var level_padding = "";
674
	for(var j=0;j<level+1;j++) level_padding += "    ";
708
	for(var j=0;j<level+1;j++) level_padding += "    ";
675
 
709
 
676
	if(typeof(arr) == 'object') { //Array/Hashes/Objects
710
	if(typeof(arr) == 'object') { //Array/Hashes/Objects
677
	 for(var item in arr) {
711
	 for(var item in arr) {
678
	  var value = arr[item];
712
	  var value = arr[item];
679
	 
713
 
680
	  if(typeof(value) == 'object') { //If it is an array,
714
	  if(typeof(value) == 'object') { //If it is an array,
681
	   dumped_text += level_padding + "'" + item + "' ...\n";
715
	   dumped_text += level_padding + "'" + item + "' ...\n";
682
	   dumped_text += dump(value,level+1);
716
	   dumped_text += dump(value,level+1);
683
	  } else {
717
	  } else {
684
	   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
718
	   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
685
	  }
719
	  }
686
	 }
720
	 }
687
	} else { //Stings/Chars/Numbers etc.
721
	} else { //Stings/Chars/Numbers etc.
688
	 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
722
	 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
689
	}
723
	}
690
	return dumped_text;
724
	return dumped_text;
691
} 
725
}