New file |
0,0 → 1,736 |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// PARAMÊTRES et CONSTANTES |
// Mettre à true pour afficher les messages de débogage |
var DEBUG = false; |
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png'; |
var pointsOrigine = null; |
var boundsOrigine = null; |
var markerClusterer = null; |
var map = null; |
var infoBulle = new google.maps.InfoWindow(); |
var pointClique = null; |
var carteCentre = new google.maps.LatLng(46.4, 3.10); |
var carteOptions = { |
zoom: 6, |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', |
google.maps.MapTypeId.ROADMAP, |
google.maps.MapTypeId.HYBRID, |
google.maps.MapTypeId.SATELLITE, |
google.maps.MapTypeId.TERRAIN] |
} |
}; |
var ctaLayer = null; |
var osmMapType = new google.maps.ImageMapType({ |
getTileUrl: function(coord, zoom) { |
return "http://tile.openstreetmap.org/" + |
zoom + "/" + coord.x + "/" + coord.y + ".png"; |
}, |
tileSize: new google.maps.Size(256, 256), |
isPng: true, |
alt: "OpenStreetMap", |
name: "OSM", |
maxZoom: 19 |
}); |
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'}; |
var station = {'commune':'', 'obsNbre':0}; |
var obsStation = new Array(); |
var obsPage = new Array(); |
var taxonsCarte = new Array(); |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INITIALISATION DU CODE |
|
//Déclenchement d'actions quand JQuery et le document HTML sont OK |
$(document).ready(function() { |
initialiserWidget(); |
}); |
|
function initialiserWidget() { |
afficherStats(); |
definirTailleTitre(); |
initialiserAffichageCarte(); |
initialiserAffichagePanneauLateral(); |
|
initialiserCarte(); |
initialiserInfoBulle(); |
initialiserFormulaireContact(); |
chargerLimitesCommunales(); |
rafraichirCarte(); |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// AFFICHAGE GÉNÉRAL |
|
function afficherStats() { |
// Ajout du nombre de communes où des observations ont eu lieu |
$('#commune-nbre').text(stations.stats.communes.formaterNombre()); |
// Ajout du nombre d'observations |
$('#obs-nbre').text(stations.stats.observations.formaterNombre()); |
} |
|
function definirTailleTitre() { |
var largeurViewPort = $(window).width(); |
var taille = null; |
if (largeurViewPort < 400) { |
taille = '0.8'; |
} else if (largeurViewPort >= 400 && largeurViewPort < 800) { |
taille = '1.0'; |
} else if (largeurViewPort >= 800) { |
taille = '1.6'; |
} |
$("#carte-titre").css('font-size', taille+'em'); |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// CARTE |
|
function initialiserAffichageCarte() { |
$('#carte').height($(window).height() - 35); |
$('#carte').width($(window).width() - 24); |
|
if (nt != '*') { |
$('#carte').css('left', 0); |
} |
} |
|
function initialiserCarte() { |
map = new google.maps.Map(document.getElementById('carte'), carteOptions); |
// Ajout de la couche OSM à la carte |
map.mapTypes.set('OSM', osmMapType); |
} |
|
|
function chargerLimitesCommunales() { |
if (urlsLimitesCommunales != null) { |
for (urlId in urlsLimitesCommunales) { |
var url = urlsLimitesCommunales[urlId]; |
ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true}); |
ctaLayer.setMap(map); |
} |
} |
} |
|
function rafraichirCarte() { |
var points = []; |
var bounds = new google.maps.LatLngBounds(); |
for (var i = 0; i < stations.stats.communes; ++i) { |
var maLatLng = new google.maps.LatLng(stations.points[i].latitude, stations.points[i].longitude); |
var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32)); |
var point = new google.maps.Marker({ |
position: maLatLng, |
map: map, |
icon: pointImage, |
stationId: stations.points[i].id |
}); |
|
bounds.extend(maLatLng); |
|
google.maps.event.addListener(point, 'click', function() { |
pointClique = this; |
infoBulle.open(map, this); |
|
var limites = map.getBounds(); |
var centre = limites.getCenter(); |
var nordEst = limites.getNorthEast(); |
var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng()); |
map.panTo(centreSudLatLng); |
|
afficherInfoBulle(); |
chargerObs(0, 0); |
}); |
|
points.push(point); |
} |
|
if (pointsOrigine == null && boundsOrigine == null) { |
pointsOrigine = points; |
boundsOrigine = bounds; |
} |
|
executerMarkerClusterer(points, bounds); |
} |
|
function deplacerCartePointClique() { |
map.panTo(pointClique.position); |
} |
|
function executerMarkerClusterer(points, bounds) { |
if (markerClusterer) { |
markerClusterer.clearMarkers(); |
} |
markerClusterer = new MarkerClusterer(map, points); |
map.fitBounds(bounds); |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INFO BULLE |
|
function initialiserInfoBulle() { |
google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle); |
google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique); |
} |
|
function afficherInfoBulle() { |
var obsHtml = $("#tpl-obs").html(); |
var largeur = definirLargeurInfoBulle(); |
obsHtml = obsHtml.replace(/\{largeur\}/, largeur); |
infoBulle.setContent(obsHtml); |
} |
|
function definirLargeurInfoBulle() { |
var largeurViewPort = $(window).width(); |
var lageurInfoBulle = null; |
if (largeurViewPort < 800) { |
largeurInfoBulle = 400; |
} else if (largeurViewPort >= 800 && largeurViewPort < 1200) { |
largeurInfoBulle = 500; |
} else if (largeurViewPort >= 1200) { |
largeurInfoBulle = 600; |
} |
return largeurInfoBulle; |
} |
|
function afficherMessageChargement(element) { |
if ($('#chargement').get() == '') { |
$('#tpl-chargement').tmpl().appendTo(element); |
} |
} |
|
function supprimerMessageChargement() { |
$('#chargement').remove(); |
} |
|
function chargerObs(depart, total) { |
if (depart == 0 || depart < total) { |
var limite = 300; |
if (depart == 0) { |
obsStation = new Array(); |
} |
//console.log("Chargement de "+depart+" à "+(depart+limite)); |
var urlObs = observationsUrl+'&start={start}&limit='+limite; |
urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId); |
urlObs = urlObs.replace(/\{nt\}/g, nt); |
urlObs = urlObs.replace(/\{start\}/g, depart); |
|
$.getJSON(urlObs, function(observations){ |
obsStation = obsStation.concat(observations.observations); |
if (depart == 0) { |
actualiserInfosStation(observations); |
actualiserPagineur(); |
creerTitreInfoBulle(); |
} |
//console.log("Chargement ok"); |
chargerObs(depart+limite, station.obsNbre); |
}); |
} else { |
if (pagineur.limite < total) { |
afficherPagination(); |
} else { |
surClicPagePagination(0, null); |
selectionnerOnglet("#obs-vue-"+pagineur.format); |
} |
} |
} |
|
function actualiserInfosStation(infos) { |
station.commune = infos.commune; |
station.obsNbre = infos.total; |
} |
|
function actualiserPagineur() { |
pagineur.stationId = pointClique.stationId; |
pagineur.total = station.obsNbre; |
//console.log("Total pagineur: "+pagineur.total); |
if (pagineur.total > 4) { |
pagineur.format = 'tableau'; |
} else { |
pagineur.format = 'liste'; |
} |
} |
|
function afficherPagination(observations) { |
$(".navigation").pagination(pagineur.total, { |
items_per_page:pagineur.limite, |
callback:surClicPagePagination, |
next_text:'Suivant', |
prev_text:'Précédent', |
prev_show_always:false, |
num_edge_entries:1, |
num_display_entries:4, |
load_first_page:true |
}); |
} |
|
function surClicPagePagination(pageIndex, paginationConteneur) { |
var index = pageIndex * pagineur.limite; |
var indexMax = index + pagineur.limite; |
pagineur.depart = index; |
obsPage = new Array(); |
for(index; index < indexMax; index++) { |
obsPage.push(obsStation[index]); |
} |
|
supprimerMessageChargement(); |
mettreAJourObservations(); |
return false; |
} |
|
function mettreAJourObservations() { |
$("#obs-"+pagineur.format+"-lignes").empty(); |
$("#obs-vue-"+pagineur.format).css('display', 'block'); |
$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart); |
$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes"); |
|
// Actualisation de Fancybox |
ajouterFomulaireContact("a.contact"); |
if (pagineur.format == 'liste') { |
ajouterGaleriePhoto("a.cel-img"); |
} |
} |
|
function creerTitreInfoBulle() { |
$("#obs-total").text(station.obsNbre); |
$("#obs-commune").text(station.commune); |
} |
|
function initialiserContenuInfoBulle() { |
afficherOnglets(); |
afficherMessageChargement('#observations'); |
ajouterTableauTriable("#obs-tableau"); |
afficherTextStationId(); |
corrigerLargeurInfoWindow(); |
} |
|
function afficherOnglets() { |
var $tabs = $('#obs').tabs(); |
$('#obs').bind('tabsselect', function(event, ui) { |
if (ui.panel.id == 'obs-vue-tableau') { |
surClicAffichageTableau(); |
} else if (ui.panel.id == 'obs-vue-liste') { |
surClicAffichageListe(); |
} |
}); |
$tabs.tabs('select', "#obs-vue-"+pagineur.format); |
} |
|
function selectionnerOnglet(onglet) { |
$('#obs').tabs('select', onglet); |
} |
|
function afficherTextStationId() { |
$('#obs-station-id').text(pointClique.stationId); |
} |
|
function corrigerLargeurInfoWindow() { |
$("#info-bulle").width($("#info-bulle").width() - 17); |
} |
|
function surClicAffichageTableau(event) { |
//console.log('tableau'); |
pagineur.format = 'tableau'; |
mettreAJourObservations(); |
mettreAJourTableauTriable("#obs-tableau"); |
} |
|
function surClicAffichageListe(event) { |
//console.log('liste'); |
pagineur.format = 'liste'; |
mettreAJourObservations(); |
ajouterGaleriePhoto("a.cel-img"); |
} |
|
function ajouterTableauTriable(element) { |
// add parser through the tablesorter addParser method |
$.tablesorter.addParser({ |
// Définition d'un id unique pour ce parsseur |
id: 'date_cel', |
is: function(s) { |
// doit retourner false si le parsseur n'est pas autodétecté |
return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s); |
}, |
format: function(date) { |
// Transformation date jj/mm/aaaa en aaaa/mm/jj |
date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1"); |
// Remplace la date par un nombre de millisecondes pour trier numériquement |
return $.tablesorter.formatFloat(new Date(date).getTime()); |
}, |
// set type, either numeric or text |
type: 'numeric' |
}); |
$(element).tablesorter({ |
headers: { |
1: { |
sorter:'date_cel' |
} |
} |
}); |
} |
|
function mettreAJourTableauTriable(element) { |
$(element).trigger('update'); |
} |
|
function ajouterGaleriePhoto(element) { |
$(element).fancybox({ |
transitionIn:'elastic', |
transitionOut:'elastic', |
speedIn :600, |
speedOut:200, |
overlayShow:true, |
titleShow:true, |
titlePosition:'inside', |
titleFormat:function (titre, currentArray, currentIndex, currentOpts) { |
var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/; |
motif.exec(titre); |
var id = RegExp.$1; |
var info = $('#cel-info-'+id).clone().html(); |
var tpl = |
'<div class="cel-legende">'+ |
'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+ |
(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+ |
'<\/div>'; |
return tpl; |
} |
}).live('click', function(e) { |
if (e.stopPropagation) { |
e.stopPropagation(); |
} |
return false; |
}); |
} |
|
function ajouterFomulaireContact(element) { |
$(element).fancybox({ |
transitionIn:'elastic', |
transitionOut:'elastic', |
speedIn :600, |
speedOut:200, |
scrolling: 'no', |
titleShow: false, |
onStart: function(selectedArray, selectedIndex, selectedOpts) { |
var element = selectedArray[selectedIndex]; |
|
var motif = / contributeur-([0-9]+)$/; |
motif.exec($(element).attr('class')); |
var id = RegExp.$1; |
//console.log('Destinataire id : '+id); |
$("#fc_destinataire_id").attr('value', id); |
|
var motif = / obs-([0-9]+) /; |
motif.exec($(element).attr('class')); |
var id = RegExp.$1; |
//console.log('Obs id : '+id); |
chargerInfoObsPourMessage(id); |
}, |
onCleanup: function() { |
//console.log('Avant fermeture fancybox'); |
$("#fc_destinataire_id").attr('value', ''); |
$("#fc_sujet").attr('value', ''); |
$("#fc_message").text(''); |
}, |
onClosed: function(e) { |
//console.log('Fermeture fancybox'); |
if (e.stopPropagation) { |
e.stopPropagation(); |
} |
return false; |
} |
}); |
} |
|
function chargerInfoObsPourMessage(idObs) { |
var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text()); |
var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text()); |
var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text()); |
var sujet = "Observation #"+idObs+" de "+nomSci; |
var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".'; |
$("#fc_sujet").attr('value', sujet); |
$("#fc_message").text(message); |
} |
|
function initialiserFormulaireContact() { |
//console.log('Initialisation du form contact'); |
$("#form-contact").validate({ |
rules: { |
fc_sujet : "required", |
fc_message : "required", |
fc_utilisateur_courriel : { |
required : true, |
email : true} |
} |
}); |
$("#form-contact").bind("submit", envoyerCourriel); |
$("#fc_annuler").bind("click", function() {$.fancybox.close();}); |
|
} |
|
function envoyerCourriel() { |
//console.log('Formulaire soumis'); |
if ($("#form-contact").valid()) { |
//console.log('Formulaire valide'); |
//$.fancybox.showActivity(); |
var destinataireId = $("#fc_destinataire_id").attr('value'); |
var urlMessage = "http://www.tela-botanica.org/service:annuaire:Utilisateur/"+destinataireId+"/message" |
var erreurMsg = ""; |
var donnees = new Array(); |
$.each($(this).serializeArray(), function (index, champ) { |
var cle = champ.name; |
cle = cle.replace(/^fc_/, ''); |
|
if (cle == 'sujet') { |
champ.value += " - Carnet en ligne - Tela Botanica"; |
} |
if (cle == 'message') { |
champ.value += "\n--\n"+ |
"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+ |
"du Carnet en Ligne du réseau Tela Botanica.\n"+ |
"http://www.tela-botanica.org/widget:cel:carto"; |
} |
|
donnees[index] = {'name':cle,'value':champ.value}; |
}); |
$.ajax({ |
type : "POST", |
cache : false, |
url : urlMessage, |
data : donnees, |
beforeSend : function() { |
$(".msg").remove(); |
}, |
success : function(data) { |
$("#fc-zone-dialogue").append('<pre class="msg info">'+data.message+'</pre>'); |
}, |
error : function(jqXHR, textStatus, errorThrown) { |
erreurMsg += "Erreur Ajax :\ntype : "+textStatus+' '+errorThrown+"\n"; |
reponse = jQuery.parseJSON(jqXHR.responseText); |
if (reponse != null) { |
$.each(reponse, function (cle, valeur) { |
erreurMsg += valeur + "\n"; |
}); |
} |
}, |
complete : function(jqXHR, textStatus) { |
var debugMsg = ''; |
if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') { |
debugInfos = jQuery.parseJSON(jqXHR.getResponseHeader("X-DebugJrest-Data")); |
if (debugInfos != null) { |
$.each(debugInfos, function (cle, valeur) { |
debugMsg += valeur + "\n"; |
}); |
} |
} |
if (erreurMsg != '') { |
$("#fc-zone-dialogue").append('<p class="msg">'+ |
'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+ |
'Vous pouvez signaler le disfonctionnement à <a href="'+ |
'mailto:cel@tela-botanica.org'+'?'+ |
'subject=Disfonctionnement du widget de Cartographie'+ |
"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+ |
'">cel@tela-botanica.org</a>.'+ |
'</p>'); |
} |
if (DEBUG) { |
console.log('Débogage : '+debugMsg); |
} |
//console.log('Débogage : '+debugMsg); |
//console.log('Erreur : '+erreurMsg); |
} |
}); |
} |
return false; |
} |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// PANNEAU LATÉRAL |
|
function initialiserAffichagePanneauLateral() { |
$('#panneau-lateral').height($(window).height() - 35); |
|
if (nt == '*') { |
$('#pl-ouverture').bind('click', afficherPanneauLateral); |
$('#pl-fermeture').bind('click', cacherPanneauLateral); |
} |
chargerTaxons(0, 0); |
} |
|
function chargerTaxons(depart, total) { |
if (depart == 0 || depart < total) { |
var limite = 7000; |
//console.log("Chargement des taxons de "+depart+" à "+(depart+limite)); |
var urlTax = taxonsUrl+'&start={start}&limit='+limite; |
urlTax = urlTax.replace(/\{start\}/g, depart); |
$.getJSON(urlTax, function(infos) { |
taxonsCarte = taxonsCarte.concat(infos.taxons); |
//console.log("Nbre taxons :"+taxonsCarte.length); |
chargerTaxons(depart+limite, infos.total); |
}); |
} else { |
if (nt == '*') { |
afficherTaxons(); |
} else { |
afficherNomPlante(); |
} |
} |
} |
|
function afficherTaxons() { |
// Ajout du nombre de plantes au titre |
$('.plantes-nbre').text(taxonsCarte.length.formaterNombre()); |
|
$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps"); |
$('.taxon').live('click', filtrerParTaxon); |
} |
|
function afficherNomPlante() { |
if (nt != '*') { |
var taxon = taxonsCarte[0]; |
$('.plante-titre').text('pour '+taxon.nom); |
} |
} |
|
function afficherPanneauLateral() { |
$('#panneau-lateral').width(300); |
$('#pl-contenu').css('display', 'block'); |
$('#pl-ouverture').css('display', 'none'); |
$('#pl-fermeture').css('display', 'block'); |
$('#carte').css('left', '300px'); |
|
google.maps.event.trigger(map, 'resize'); |
}; |
|
function cacherPanneauLateral() { |
$('#panneau-lateral').width(24); |
$('#pl-contenu').css('display', 'none'); |
$('#pl-ouverture').css('display', 'block'); |
$('#pl-fermeture').css('display', 'none'); |
$('#carte').css('left', '24px'); |
|
google.maps.event.trigger(map, 'resize'); |
}; |
|
function ouvrirPopUp(url, nom) { |
window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no'); |
}; |
|
function filtrerParTaxon() { |
var ntAFiltrer = $('.nt', this).text(); |
infoBulle.close(); |
$('#taxon-'+nt).removeClass('taxon-actif'); |
if (nt == ntAFiltrer) { |
nt = '*'; |
executerMarkerClusterer(pointsOrigine, boundsOrigine); |
} else { |
var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+ |
'&formatRetour=jsonP'+ |
'&callback=?'; |
$.getJSON(url, function (stationsFiltrees) { |
stations = stationsFiltrees; |
nt = ntAFiltrer; |
$('#taxon-'+nt).addClass('taxon-actif'); |
rafraichirCarte(); |
}); |
} |
}; |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// FONCTIONS UTILITAIRES |
|
function arreter(event) { |
if (event.stopPropagation) { |
event.stopPropagation(); |
} else if (window.event) { |
window.event.cancelBubble = true; |
} |
return false; |
} |
|
/** |
* +-------------------------------------+ |
* Number.prototype.formaterNombre |
* +-------------------------------------+ |
* Params (facultatifs): |
* - Int decimales: nombre de decimales (exemple: 2) |
* - String signe: le signe precedent les decimales (exemple: "," ou ".") |
* - String separateurMilliers: comme son nom l'indique |
* Returns: |
* - String chaine formatee |
* @author ::mastahbenus:: |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant |
* @souce http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx |
*/ |
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) { |
var _sNombre = String(this), i, _sRetour = "", _sDecimales = ""; |
|
function is_int(nbre) { |
nbre = nbre.replace(',', '.'); |
return !(parseFloat(nbre)-parseInt(nbre) > 0); |
} |
|
if (decimales == undefined) { |
if (is_int(_sNombre)) { |
decimales = 0; |
} else { |
decimales = 2; |
} |
} |
if (signe == undefined) { |
if (is_int(_sNombre)) { |
signe = ''; |
} else { |
signe = '.'; |
} |
} |
if (separateurMilliers == undefined) { |
separateurMilliers = ' '; |
} |
|
function separeMilliers (sNombre) { |
var sRetour = ""; |
while (sNombre.length % 3 != 0) { |
sNombre = "0"+sNombre; |
} |
for (i = 0; i < sNombre.length; i += 3) { |
if (i == sNombre.length-1) separateurMilliers = ''; |
sRetour += sNombre.substr(i, 3) + separateurMilliers; |
} |
while (sRetour.substr(0, 1) == "0") { |
sRetour = sRetour.substr(1); |
} |
return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers)); |
} |
|
if (_sNombre.indexOf('.') == -1) { |
for (i = 0; i < decimales; i++) { |
_sDecimales += "0"; |
} |
_sRetour = separeMilliers(_sNombre) + signe + _sDecimales; |
} else { |
var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1)); |
if (sDecimalesTmp.length > decimales) { |
var nDecimalesManquantes = sDecimalesTmp.length - decimales; |
var nDiv = 1; |
for (i = 0; i < nDecimalesManquantes; i++) { |
nDiv *= 10; |
} |
_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv); |
} |
_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales; |
} |
return _sRetour; |
} |
|
function debug(objet) { |
var msg = ''; |
if (objet != null) { |
$.each(objet, function (cle, valeur) { |
msg += cle+":"+valeur + "\n"; |
}); |
} else { |
msg = "La variable vaut null."; |
} |
console.log(msg); |
} |
|
function trim (chaine) { |
return chaine.replace(/^\s+/g, '').replace(/\s+$/g, ''); |
} |