New file |
0,0 → 1,1417 |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// PARAMÊTRES et CONSTANTES |
// Mettre à true pour afficher les messages de débogage |
var DEBUG = false; |
/** |
* Indication de certaines variables ajoutée par php |
* var communeImageUrl ; |
* var pointImageUrl ; |
* var groupeImageUrlTpl ; |
*/ |
var pointsOrigine = null; |
var boundsOrigine = null; |
var markerClusterer = null; |
var map = null; |
var infoBulle = new google.maps.InfoWindow(); |
var stations = null; |
var pointClique = null; |
var carteCentre = new google.maps.LatLng(25, 10); |
var carteOptions = { |
zoom: 3, |
center:carteCentre, |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', |
google.maps.MapTypeId.ROADMAP, |
google.maps.MapTypeId.HYBRID, |
google.maps.MapTypeId.SATELLITE, |
google.maps.MapTypeId.TERRAIN] |
}, |
zoomControlOptions: { |
style: google.maps.ZoomControlStyle.LARGE, |
position: google.maps.ControlPosition.LEFT_CENTER |
}, |
panControl: false |
}; |
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 ctaLayer = null; |
var pagineur = {'limite':300, '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(); |
var mgr = null; |
var marqueursCache = new Array(); |
var zonesCache = new Array(); |
var requeteChargementPoints; |
var urlVars = null; |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INITIALISATION DU CODE |
|
//Déclenchement d'actions quand JQuery et le document HTML sont OK |
$(document).ready(function() { |
initialiserWidget(); |
}); |
|
function initialiserWidget() { |
urlVars = getUrlVars(); |
dimensionnerCarte(); |
definirTailleOverlay(); |
initialiserCarte(); |
attribuerListenersOverlay(); |
centrerTitreEtStats(); |
initialiserAffichagePanneauLateral(); |
initialiserGestionnaireMarqueurs() |
initialiserInfoBulle(); |
initialiserFormulaireContact(); |
chargerLimitesCommunales(); |
attribuerListenerCarte(); |
} |
|
function getUrlVars() |
{ |
var vars = [], hash; |
if(window.location.href.indexOf('?') != -1) { |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); |
for(var i = 0; i < hashes.length; i++) |
{ |
hash = hashes[i].split('='); |
vars.push(hash[0]); |
vars[hash[0]] = hash[1]; |
} |
} |
return vars; |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// AFFICHAGE GÉNÉRAL |
|
function afficherTitreCarteEtStats() { |
if (stations != null && taxonsCarte.length > 0) { |
var obsNbre = stations.stats.observations; |
var obsNbreFormate = obsNbre; |
if(obsNbre != 0) { |
obsNbreFormate = stations.stats.observations.formaterNombre(); |
} |
var plteNbre = taxonsCarte.length; |
var plteNbreFormate = plteNbre; |
if(plteNbre != 0) { |
plteNbreFormate = taxonsCarte.length.formaterNombre(); |
} |
var communeNbre = stations.stats.communes; |
var communeNbreFormate = communeNbre; |
if(communeNbre != 0) { |
communeNbreFormate = stations.stats.communes.formaterNombre(); |
} |
var stationNbre = stations.stats.stations; |
var stationNbreFormate = stationNbre; |
if(stationNbre != 0) { |
stationNbreFormate = stations.stats.stations.formaterNombre(); |
} |
|
var stats = obsNbreFormate+' observation'; |
stats += (obsNbre > 1) ? 's' : '' ; |
|
if(photos != null && photos == 1) { |
stats += ' avec photos '; |
} |
|
stats += ' sur '+(stationNbre+ communeNbre)+' station'; |
stats += (stationNbre > 1) ? 's' : '' ; |
|
if (nt == '*') { |
stats += ' parmi '+plteNbreFormate+' plante'; |
stats += (plteNbre > 1) ? 's' : '' ; |
} else { |
if($('.taxon-actif .taxon').text() != '') { |
var element = $('.taxon-actif .taxon').clone(); |
element.children().remove(); |
var taxon = element.text(); |
stats += ' pour '+taxon; |
} else { |
if (taxonsCarte[0]) { |
var taxon = taxonsCarte[0]; |
stats += ' pour '+taxon.nom; |
} |
} |
} |
|
if(utilisateur != '*') { |
stats += ' pour l\'utilisateur '+utilisateur+' '; |
} |
|
$('#zone-stats').show(); |
} else { |
stats = "Aucune observation pour ces critères ou pour cette zone"; |
} |
|
$('#zone-stats > h1').text(stats); |
centrerTitreEtStats(); |
} |
|
function attribuerListenersOverlay() { |
|
$(window).resize(function() { |
dimensionnerCarte(); |
definirTailleOverlay(); |
centrerTitreEtStats(); |
programmerRafraichissementCarte(); |
google.maps.event.trigger($('#carte'), 'resize'); |
}); |
|
$('#lien_plein_ecran a').click(function(event) { |
window.open(window.location.href); |
event.preventDefault(); |
}); |
|
$('#lien-voir-cc a').click(function(event) { |
ouvrirPopUp(this, 'Avertissement', event); |
event.preventDefault(); |
}); |
} |
|
var tailleMaxFiltreUtilisateur; |
function definirTailleOverlay() { |
var largeurViewPort = $(window).width(); |
var taille = '1.6'; |
var tailleMaxLogo = 60; |
var tailleMaxIcones = 10; |
var padding_icones = 8; |
var tailleFiltre = 80; |
tailleMaxFiltreUtilisateur = 350; |
$('#raz-filtre-utilisateur').css('display', 'block'); |
if (largeurViewPort <= 450) { |
taille = '1'; |
tailleMaxIcones = 10; |
tailleFiltre = 65; |
padding_icones = 2; |
var tailleMaxLogo = 50; |
$('#raz-filtre-utilisateur').css('display', 'inline'); |
} else if (largeurViewPort <= 500) { |
taille = '1.2'; |
tailleMaxIcones = 10; |
tailleFiltre = 65; |
padding_icones = 2; |
var tailleMaxLogo = 50; |
tailleMaxFiltreUtilisateur = 200; |
$('#raz-filtre-utilisateur').css('display', 'inline'); |
} else if (largeurViewPort > 500 && largeurViewPort <= 800) { |
taille = '1.4'; |
tailleMaxIcones = 15; |
padding_icones = 6; |
tailleFiltre = 65; |
var tailleMaxLogo = 55; |
tailleMaxFiltreUtilisateur = 250; |
} else if (largeurViewPort > 800) { |
taille = '1.6'; |
tailleMaxIcones = 20; |
padding_icones = 8; |
tailleFiltre = 80; |
tailleMaxFiltreUtilisateur = 350; |
} |
|
// Aménagement de la taille de police selon l'écran |
$("#carte-titre").css('font-size', taille+'em'); |
|
$("#zone-stats h1").css('font-size', Math.round((taille*0.75*100))/100+'em'); |
$("#zone-stats").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px"); |
$('#zone-stats').height(tailleMaxIcones*1.5); |
|
$("#zone-titre h1").css('font-size', (taille)+'em'); |
$("#zone-titre").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px"); |
$('#zone-titre').height(tailleMaxIcones*2); |
|
$('.icone').height(tailleMaxIcones); |
$('#lien_plein_ecran').css("padding", padding_icones+"px "+padding_icones+"px "+Math.ceil(padding_icones/2)+"px"); |
|
$('#lien-voir-cc').css("font-size", taille+"em"); |
$('#lien-voir-cc').css("padding", padding_icones+"px"); |
|
$("#panneau-lateral").css('font-size', (taille*0.9)+'em'); |
$("#pl-contenu").css('font-size', (taille/2)+'em'); |
|
$("#panneau-lateral").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px"); |
$('#pl-ouverture').height(((padding_icones*2)+$('#panneau-lateral').height())+"px"); |
$("#panneau-lateral").width(tailleFiltre); |
|
$('#lien-affichage-filtre-utilisateur').width(tailleFiltre); |
$('#lien-affichage-filtre-utilisateur').height(tailleFiltre*0.35); |
$('#lien-affichage-filtre-utilisateur').css('font-size', (taille*0.9)+'em'); |
$('#conteneur-filtre-utilisateur').css('max-width',tailleMaxFiltreUtilisateur); |
|
dimensionnerLogo(tailleMaxLogo); |
dimensionnerImage(largeurViewPort); |
redimensionnerControleTypeCarte(largeurViewPort); |
} |
|
function dimensionnerLogo(tailleMaxLogo) { |
// Dimensionnement du logo |
hauteurLogo = $('.image-logo').height(); |
// Redimensionnement du logo s'il est trop grand |
// on perd en qualité mais ça vaut mieux que de casser l'affichage |
if(hauteurLogo > tailleMaxLogo) { |
hauteurLogo = tailleMaxLogo; |
$('.image-logo').css("top", "5px"); |
$('.image-logo').height(tailleMaxLogo); |
} |
|
if(hauteurLogo == 0) { |
$('.image-logo').load(function(event) { |
definirTailleOverlay(); |
}); |
return; |
} |
|
largeurLogo = $('#logo img').width(); |
} |
|
function dimensionnerImage(largeurViewPort) { |
// Dimensionnement de l'image |
if(largeurViewPort > 500) { |
largeurLogo = 155; |
} else { |
largeurLogo = 70; |
} |
|
$('#image-utilisateur img').width(largeurLogo); |
} |
|
function redimensionnerControleTypeCarte(largeurViewPort) { |
if (largeurViewPort <= 500) { |
carteOptions.mapTypeControlOptions.style = google.maps.MapTypeControlStyle.DROPDOWN_MENU; |
} else { |
carteOptions.mapTypeControlOptions.style = google.maps.MapTypeControlStyle.DEFAULT; |
} |
|
if(map != null) { |
map.setOptions(carteOptions); |
} |
} |
|
function centrerTitreEtStats() { |
centrerTitre(); |
centrerStats(); |
} |
|
function centrerTitre() { |
var largeurViewPort = $(window).width(); |
var largeurTitre = $('#zone-titre').width(); |
var marge = (largeurViewPort - largeurTitre)/2; |
$('#zone-titre').css("margin-left",marge); |
var tailleRestante = largeurViewPort - (marge + largeurTitre); |
if(tailleRestante <= 170) { |
$('#zone-titre').css("top", "25px"); |
} else { |
$('#zone-titre').css("top", "5px"); |
} |
} |
|
function centrerStats() { |
var largeurViewPort = $(window).width(); |
var largeurStats = $('#zone-stats').width(); |
var marge = ((largeurViewPort - largeurStats)/2); |
$('#zone-stats').css("margin-left",marge); |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// CARTE |
|
function dimensionnerCarte() { |
var largeurViewPort = $(window).width(); |
var hauteurViewPort = $(window).height(); |
$('#carte').height(hauteurViewPort); |
$('#carte').width(largeurViewPort); |
} |
|
function initialiserCarte() { |
map = new google.maps.Map(document.getElementById('carte'), carteOptions); |
// Ajout de la couche OSM à la carte |
map.mapTypes.set('OSM', osmMapType); |
} |
|
function initialiserGestionnaireMarqueurs() { |
mgr = new MarkerManager(map); |
} |
|
function chargerLimitesCommunales() { |
if (urlsLimitesCommunales != null) { |
for (urlId in urlsLimitesCommunales) { |
var url = urlsLimitesCommunales[urlId]; |
ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true}); |
ctaLayer.setMap(map); |
} |
} |
} |
|
var listener = null; |
var timer = null; |
function attribuerListenerCarte() { |
listener = google.maps.event.addListener(map, 'bounds_changed', function(){ |
programmerRafraichissementCarte(); |
}); |
listener = google.maps.event.addListener(map, 'zoom_changed', function(){ |
programmerRafraichissementCarte(); |
}); |
} |
function programmerRafraichissementCarte() { |
if(timer != null) { |
window.clearTimeout(timer); |
} |
if(requeteChargementPoints != null) { |
requeteChargementPoints.abort(); |
} |
timer = window.setTimeout(function() { |
if(map.getBounds() != undefined) { |
var zoom = map.getZoom(); |
var lngNE = map.getBounds().getNorthEast().lng(); |
var lngSW = map.getBounds().getSouthWest().lng() |
if(map.getBounds().getNorthEast().lng() < map.getBounds().getSouthWest().lng()) { |
lngNE = 176; |
lngSW = -156; |
} |
var NELatLng = (map.getBounds().getNorthEast().lat())+'|'+(lngNE); |
var SWLatLng = (map.getBounds().getSouthWest().lat())+'|'+(lngSW); |
chargerMarqueurs(zoom, NELatLng, SWLatLng); |
} else { |
programmerRafraichissementCarte(); |
} |
}, 400); |
} |
|
var marqueurs = new Array(); |
function chargerMarqueurs(zoom, NELatLng, SWLatLng) { |
cacherMessageAucuneObs() |
var url = stationsUrl+ |
'&zoom='+zoom+ |
'&ne='+NELatLng+ |
'&sw='+SWLatLng; |
|
if(infoBulleOuverte) { |
return; |
} |
|
if(requeteChargementPoints != null) { |
requeteChargementPoints.abort(); |
cacherMessageChargementPoints(); |
} |
|
afficherMessageChargementPoints(); |
requeteChargementPoints = $.getJSON(url, function(data) { |
rafraichirMarqueurs(data); |
cacherMessageChargementPoints(); |
}); |
} |
|
function centrerDansLaPage(selecteur) { |
var largeurViewport = $(window).width(); |
var hauteurViewport = $(window).height(); |
selecteur.css('display','block'); |
var left = (largeurViewport/2) - (selecteur.width())/2; |
var top = (hauteurViewport/2) - (selecteur.height())/2 |
selecteur.css('left',left); |
selecteur.css('top',top); |
} |
|
function afficherMessageChargementPoints() { |
centrerDansLaPage($('#zone-chargement-point')); |
$('#zone-chargement-point').css('display','block'); |
} |
|
function cacherMessageChargementPoints() { |
$('#zone-chargement-point').css('display','none'); |
} |
|
function afficherMessageAucuneObs() { |
centrerDansLaPage($('#message-aucune-obs')); |
$('#message-aucune-obs').show(); |
} |
|
function cacherMessageAucuneObs() { |
centrerDansLaPage($('#message-aucune-obs')); |
$('#message-aucune-obs').hide(); |
} |
|
premierChargement = true; |
function doitCentrerCarte() { |
return premierChargement && urlVars != null && urlVars.length > 0; |
} |
|
function rafraichirMarqueurs(data) { |
|
$.each(marqueurs, function(index, marqueur) { |
marqueur.setMap(null); |
}); |
|
marqueurs = new Array(); |
stations = null; |
|
if(data.points.length > 0) { |
marqueurs = new Array(); |
|
stations = data; |
|
$.each(stations.points, function (index, station) { |
if(station != null) { |
var nouveauMarqueur = creerMarqueur(station); |
marqueurs.push(nouveauMarqueur); |
} |
}); |
|
if(doitCentrerCarte()) { |
premierChargement = false; |
var bounds = new google.maps.LatLngBounds(); |
var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax); |
var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin); |
bounds.extend(latMax); |
bounds.extend(latMin); |
rendrePointsVisibles(bounds); |
} |
} |
|
afficherTitreCarteEtStats(); |
} |
|
function creerMarqueur(station) { |
var titre = ''; |
if(station.nbreMarqueur) { |
titre = station.nbreMarqueur+' points renseignés'; |
} else { |
if(station.nom) { |
titre = station.nom; |
} |
} |
|
var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']); |
var latLng = new google.maps.LatLng(station['lat'], station['lng']); |
var marqueur = new google.maps.Marker({ |
position: latLng, |
icon: icone, |
title: ''+titre, |
map: map, |
stationInfos: station |
}); |
attribuerListenerClick(marqueur, station['id']); |
marqueur.setMap(map); |
return marqueur; |
} |
|
function rendrePointsVisibles(bounds) { |
map.setCenter(bounds.getCenter()); |
map.fitBounds(bounds); |
} |
|
function attribuerImageMarqueur(id, nbreMarqueur) { |
var marqueurImage = null; |
if (etreMarqueurCommune(id)) { |
marqueurImage = new google.maps.MarkerImage(communeImageUrl, new google.maps.Size(24, 32)); |
} else if (etreMarqueurStation(id)) { |
marqueurImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(16, 16)); |
} else if (etreMarqueurGroupe(id)) { |
var type = 0; |
var largeur = 0; |
var hauteur = 0; |
if (nbreMarqueur != null) { |
if (nbreMarqueur >= 2 && nbreMarqueur < 100 ) { |
type = '1'; |
largeur = 53; |
hauteur = 52; |
} else if (nbreMarqueur >= 100 && nbreMarqueur < 1000 ) { |
type = '2'; |
largeur = 56; |
hauteur = 55; |
} else if (nbreMarqueur >= 1000 && nbreMarqueur < 10000 ) { |
type = '3'; |
largeur = 66; |
hauteur = 65; |
} else if (nbreMarqueur >= 10000 && nbreMarqueur < 20000 ) { |
type = '4'; |
largeur = 78; |
hauteur = 77; |
} else if (nbreMarqueur >= 20000) { |
type = '5'; |
largeur = 66; |
hauteur = 65; |
} |
} |
groupeImageUrl = groupeImageUrlTpl.replace(/\{type\}/, type); |
groupeImageUrl = groupeImageUrl.replace(/\{nbre\}/, nbreMarqueur); |
marqueurImage = new google.maps.MarkerImage(groupeImageUrl, new google.maps.Size(largeur, hauteur)); |
} |
return marqueurImage |
} |
|
function attribuerListenerClick(marqueur, id) { |
if (etreMarqueurCommune(id) || etreMarqueurStation(id)) { |
google.maps.event.addListener(marqueur, 'click', surClickMarqueur); |
} else if (etreMarqueurGroupe(id)) { |
google.maps.event.addListener(marqueur, 'click', surClickGroupe); |
} |
} |
|
var pointCentreAvantAffichageInfoBulle = null; |
function surClickMarqueur(event) { |
pointCentreAvantAffichageInfoBulle = map.getCenter(); |
|
if(infoBulleOuverte) { |
infoBulle.close(); |
} |
|
pointClique = this; |
infoBulle.open(map, this); |
actualiserPagineur(); |
|
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(); |
} |
|
function surClickGroupe() { |
map.setCenter(this.getPosition()); |
var nouveauZoom = map.getZoom() + 2; |
map.setZoom(nouveauZoom); |
mgr.clearMarkers(); |
} |
|
function etreMarqueurGroupe(id) { |
var groupe = false; |
var motif = /^GROUPE/; |
if (motif.test(id)) { |
groupe = true; |
} |
return groupe; |
} |
|
function etreMarqueurCommune(id) { |
var commune = false; |
var motif = /^COMMUNE:/; |
if (motif.test(id)) { |
commune = true; |
} |
return commune; |
} |
|
function etreMarqueurStation(id) { |
var station = false; |
var motif = /^STATION:/; |
if (motif.test(id)) { |
station = true; |
} |
return station; |
} |
|
function deplacerCarteSurPointClique() { |
map.panTo(pointClique.position); |
} |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INFO BULLE |
var infoBulleOuverte = false; |
function initialiserInfoBulle() { |
google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle); |
google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle); |
google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle); |
attribuerListenerLienSaisie(); |
} |
|
function attribuerListenerLienSaisie() { |
$('.lien-widget-saisie').live('click', function(event) { |
event.preventDefault(); |
window.open($(this).attr('href'), '_blank'); |
return false; |
}); |
} |
|
function surFermetureInfoBulle() { |
infoBulleOuverte = false; |
map.panTo(pointCentreAvantAffichageInfoBulle); |
programmerRafraichissementCarte(); |
} |
|
function centrerInfoBulle() { |
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); |
} |
|
function afficherInfoBulle() { |
var obsHtml = $("#tpl-obs").html(); |
var largeur = definirLargeurInfoBulle(); |
var taillePolice = definirTaillePoliceInfoBulle(); |
obsHtml = obsHtml.replace(/\{largeur\}/, largeur); |
obsHtml = mettreAJourUrlSaisie(obsHtml); |
infoBulle.setContent(obsHtml); |
$('#observations').css('font-size',taillePolice+'em'); |
chargerObs(0, 0); |
infoBulleOuverte = true; |
} |
|
//TODO utiliser cette fonction lors des remplacements de |
//paramètres url sur changement de filtre |
function parserFiltre(filtre) { |
var nvpair = {}; |
var qs = filtre.replace('?', ''); |
var pairs = qs.split('&'); |
$.each(pairs, function(i, v){ |
var pair = v.split('='); |
nvpair[pair[0]] = pair[1]; |
}); |
return nvpair; |
} |
|
function mettreAJourUrlSaisie(obsHtml) { |
var filtreTableau = parserFiltre(filtreCommun); |
var filtresGardes = new Array(); |
filtre = ''; |
for(i in filtreTableau) { |
if(filtreTableau[i] != undefined && filtreTableau[i] != '' && decodeURIComponent(filtreTableau[i]) != '*') { |
console.log(i+" "+filtreTableau[i]); |
filtresGardes.push(i+'='+filtreTableau[i]); |
} |
} |
if(filtresGardes.length > 0) { |
filtre = '?'+filtresGardes.join('&'); |
} |
obsHtml = obsHtml.replace(/\{parametres-lien-saisie\}/, filtre); |
return obsHtml; |
} |
|
function definirLargeurInfoBulle() { |
var largeurViewPort = $(window).width(); |
var largeurInfoBulle = null; |
if (largeurViewPort < 400) { |
largeurInfoBulle = 300; |
} else if (largeurViewPort < 800) { |
largeurInfoBulle = 400; |
} else if (largeurViewPort >= 800 && largeurViewPort < 1200) { |
largeurInfoBulle = 500; |
} else if (largeurViewPort >= 1200) { |
largeurInfoBulle = 600; |
} |
return largeurInfoBulle; |
} |
|
function definirTaillePoliceInfoBulle() { |
var largeurViewPort = $(window).width(); |
var taillePolice = null; |
if (largeurViewPort < 400) { |
taillePolice = 0.8; |
} else if (largeurViewPort < 800) { |
taillePolice = 1; |
} |
return taillePolice; |
} |
|
function afficherMessageChargement(element) { |
if ($('#chargement').get() == '') { |
$('#tpl-chargement').tmpl().appendTo(element); |
} |
} |
|
function afficherMessageChargementTitreInfoBulle() { |
$("#obs-station-titre").text("Chargement des observations"); |
} |
|
function supprimerMessageChargement() { |
$('#chargement').remove(); |
} |
|
function chargerObs(depart, total) { |
if (depart == 0 || depart < total) { |
var limite = 300; |
if (depart == 0) { |
viderTableauObs(); |
} |
|
var urlObs = observationsUrl+'&start={start}&limit='+limite; |
urlObs = urlObs.replace(/\{stationId\}/g, encodeURIComponent(pointClique.stationInfos.id)); |
if (pointClique.stationInfos.type_emplacement == 'communes') { |
urlObs = urlObs.replace(/commune=%2A/g, formaterParametreCommunePourRequete(pointClique.stationInfos.nom)); |
} |
urlObs = urlObs.replace(/\{nt\}/g, nt); |
urlObs = urlObs.replace(/\{start\}/g, depart); |
|
$.getJSON(urlObs, function(observations){ |
surRetourChargementObs(observations, depart, total); |
chargerObs(depart+limite, observations.total); |
}); |
} |
} |
|
function formaterParametreCommunePourRequete(nomCommune) { |
var chaineRequete = ""; |
if(nomCommune.indexOf("(", 0) !== false) { |
var infosCommune = nomCommune.split("("); |
var commune = infosCommune[0]; |
chaineRequete = 'commune='+encodeURIComponent($.trim(commune)); |
} else { |
chaineRequete = 'commune='+encodeURIComponent($.trim(nomCommune)); |
} |
return chaineRequete; |
} |
|
function viderTableauObs() { |
obsStation = new Array(); |
surClicPagePagination(0, null); |
} |
|
function surRetourChargementObs(observations, depart, total) { |
obsStation = obsStation.concat(observations.observations); |
if (depart == 0) { |
actualiserInfosStation(observations); |
creerTitreInfoBulle(); |
surClicPagePagination(0, null); |
} |
|
afficherPagination(); |
actualiserPagineur(); |
selectionnerOnglet("#obs-vue-"+pagineur.format); |
} |
|
function actualiserInfosStation(infos) { |
pointClique.stationInfos.commune = infos.commune; |
pointClique.stationInfos.obsNbre = infos.total; |
} |
|
function creerTitreInfoBulle() { |
$("#obs-total").text(station.obsNbre); |
$("#obs-commune").text(station.commune); |
var titre = ''; |
titre += pointClique.stationInfos.obsNbre+' observation'; |
titre += (pointClique.stationInfos.obsNbre > 1) ? 's': '' ; |
titre += ' pour '; |
if (etreMarqueurCommune(pointClique.stationInfos.id)) { |
nomStation = 'la commune : '; |
} else { |
nomStation = 'la station : '; |
} |
titre += pointClique.stationInfos.nom; |
$("#obs-station-titre").text(titre); |
} |
|
function actualiserPagineur() { |
pagineur.stationId = pointClique.stationInfos.id; |
pagineur.total = pointClique.stationInfos.obsNbre; |
// Si on est en mode photo on reste en mode liste quelque soit le |
// nombre de résultats |
if (pagineur.total > 4 && photos != 1) { |
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 |
ajouterFormulaireContact("a.contact"); |
if (pagineur.format == 'liste') { |
ajouterGaleriePhoto("a.cel-img"); |
} |
} |
|
function initialiserContenuInfoBulle() { |
afficherMessageChargement('#observations'); |
cacherContenuOnglets(); |
afficherOnglets(); |
ajouterTableauTriable("#obs-tableau"); |
afficherTextStationId(); |
corrigerLargeurInfoWindow(); |
} |
|
function cacherContenuOnglets() { |
$("#obs-vue-tableau").css("display", "none"); |
$("#obs-vue-liste").css("display", "none"); |
} |
|
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(); |
} |
}); |
if (pointClique.stationInfos.nbre > 4) { |
$tabs.tabs('select', "#obs-vue-tableau"); |
} else { |
$tabs.tabs('select', "#obs-vue-liste"); |
} |
|
} |
|
function selectionnerOnglet(onglet) { |
$(onglet).css('display', 'block'); |
$('#obs').tabs('select', onglet); |
} |
|
function afficherTextStationId() { |
$('#obs-station-id').text(pointClique.stationInfos.id); |
} |
|
function corrigerLargeurInfoWindow() { |
$("#info-bulle").width($("#info-bulle").width() - 17); |
} |
|
function surClicAffichageTableau(event) { |
pagineur.format = 'tableau'; |
mettreAJourObservations(); |
mettreAJourTableauTriable("#obs-tableau"); |
} |
|
function surClicAffichageListe(event) { |
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 ajouterFormulaireContact(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')); |
// si la classe ne contient pas d'id contributeur |
// alors il faut stocker le numéro d'observation |
var id = RegExp.$1; |
if(id == "") { |
$("#fc_type_envoi").attr('value', 'non-inscrit'); |
var motif = / obs-([0-9]+)$/; |
motif.exec($(element).attr('class')); |
var id = RegExp.$1; |
} else { |
$("#fc_type_envoi").attr('value', 'inscrit'); |
} |
|
$("#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 = jQuery.trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text()); |
var date = jQuery.trim($(".cel-obs-"+idObs+" .date:eq(0)").text()); |
var lieu = jQuery.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 typeEnvoi = $("#fc_type_envoi").attr('value'); |
if(typeEnvoi == "non-inscrit") { |
// l'envoi au non inscrits passe par le service intermédiaire du cel |
// qui va récupérer le courriel associé à l'obs indiquée |
var urlMessage = "http://www.tela-botanica.org/service:cel:celMessage/obs/"+destinataireId; |
} else { |
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 carto "+ |
"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 carto'+ |
"&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 |
var nbTaxons = 0; |
function initialiserAffichagePanneauLateral() { |
if (nt == '*') { |
$('#pl-ouverture').bind('click', afficherPanneauLateral); |
$('#pl-fermeture').bind('click', cacherPanneauLateral); |
} else { |
$('#panneau-lateral').width(0); |
$('#carte').width('100%'); |
} |
attribuerListenersFiltreUtilisateur(); |
chargerTaxons(0, 0); |
} |
|
function attribuerListenersFiltreUtilisateur() { |
|
$('#valider-filtre-utilisateur').click(function() { |
var utilisateur = $('#filtre-utilisateur').val(); |
filtrerParUtilisateur(utilisateur); |
$('#raz-filtre-utilisateur').show(); |
}); |
|
$('#filtre-utilisateur').keypress(function(e) { |
if(e.which == 13) { |
var utilisateur = $('#filtre-utilisateur').val(); |
filtrerParUtilisateur(utilisateur); |
$('#raz-filtre-utilisateur').show(); |
} |
}); |
|
$('#raz-filtre-utilisateur').click(function() { |
$('#filtre-utilisateur').val(''); |
filtrerParUtilisateur('*'); |
afficherCacherFiltreUtilisateur(); |
$('#raz-filtre-utilisateur').hide(); |
}); |
|
$('#lien-affichage-filtre-utilisateur').click(function() { |
afficherCacherFiltreUtilisateur(); |
}); |
|
$('#raz-filtre-utilisateur').hide(); |
$('#formulaire-filtre-utilisateur').hide(); |
} |
|
function afficherCacherFiltreUtilisateur() { |
$('#formulaire-filtre-utilisateur').slideToggle(); |
$('#conteneur-filtre-utilisateur').toggleClass('ferme'); |
if(!$('#conteneur-filtre-utilisateur').hasClass('ferme')) { |
$('#conteneur-filtre-utilisateur').width(tailleMaxFiltreUtilisateur); |
} else { |
$('#conteneur-filtre-utilisateur').width('auto'); |
} |
} |
|
function filtrerParUtilisateur(utilisateurFiltre) { |
if(utilisateurFiltre == '') { |
utilisateurFiltre = '*'; |
} |
utilisateur = utilisateurFiltre; |
var pattern = /utilisateur=[^&]*/i; |
var utilisateurCourant = pattern.exec(stationsUrl); |
stationsUrl = stationsUrl.replace(utilisateurCourant, "utilisateur="+utilisateurFiltre); |
taxonsUrl = taxonsUrl.replace(utilisateurCourant, "utilisateur="+utilisateurFiltre); |
observationsUrl = observationsUrl.replace(utilisateurCourant, "utilisateur="+utilisateurFiltre); |
filtreCommun = filtreCommun.replace(utilisateurCourant, "utilisateur="+utilisateurFiltre); |
$("#taxons").html(''); |
chargerTaxons(0,0); |
programmerRafraichissementCarte(); |
} |
|
function chargerTaxons(depart, total) { |
if (depart == 0 || depart < total) { |
if(depart == 0) { |
nbTaxons = 0; |
taxonsCarte = new Array(); |
} |
|
var limite = 2000; |
//console.log("Chargement des taxons de "+depart+" à "+(depart+limite)); |
var urlTax = taxonsUrl+'&start={start}&limit='+limite; |
urlTax = urlTax.replace(/\{start\}/g, depart); |
//console.log(urlTax); |
$.getJSON(urlTax, function(infos) { |
nbTaxons += infos.taxons.length; |
$(".plantes-nbre").text(nbTaxons); |
$("#tpl-taxons-liste").tmpl({'taxons':infos.taxons}).appendTo("#taxons"); |
taxonsCarte = taxonsCarte.concat(infos.taxons); |
//console.log("Nbre taxons :"+taxonsCarte.length); |
chargerTaxons(depart+limite, infos.total); |
}); |
} else { |
if (nt == '*') { |
afficherTaxons(); |
} |
afficherTitreCarteEtStats(); |
} |
} |
|
function afficherTaxons() { |
$('.taxon').live('click', filtrerParTaxon); |
$('.raz-filtre-taxons').live('click', viderFiltreTaxon); |
} |
|
var largeurPanneauLateralFerme = null; |
function afficherPanneauLateral() { |
// fixer la hauteur |
$('#panneau-lateral').height($(window).height() - $('#panneau-lateral').offset().top); |
largeurPanneauLateralFerme = $('#panneau-lateral').width(); |
$('#panneau-lateral').width(300); |
$('#pl-contenu').css('display', 'block'); |
$('#pl-ouverture').css('display', 'none'); |
$('#pl-fermeture').css('display', 'block'); |
// correction pour la taille de la liste des taxons |
$('#pl-corps').height($(window).height() - $('#pl-corps').offset().top); |
|
google.maps.event.trigger(map, 'resize'); |
}; |
|
function cacherPanneauLateral() { |
$('#panneau-lateral').height(25+"px"); |
$('#panneau-lateral').width(largeurPanneauLateralFerme+"px"); |
$('#pl-contenu').css('display', 'none'); |
$('#pl-ouverture').css('display', 'block'); |
$('#pl-fermeture').css('display', 'none'); |
|
google.maps.event.trigger(map, 'resize'); |
}; |
|
function viderFiltreTaxon() { |
$('.taxon-actif .taxon').click(); |
} |
|
function filtrerParTaxon() { |
var ntAFiltrer = $('.nt', this).text(); |
infoBulle.close(); |
var zoom = map.getZoom(); |
var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng(); |
var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng(); |
|
$('.raz-filtre-taxons').removeClass('taxon-actif'); |
$('#taxon-'+nt).removeClass('taxon-actif'); |
|
if (nt == ntAFiltrer) { |
nt = '*'; |
stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+nt); |
chargerMarqueurs(zoom, NELatLng, SWLatLng); |
} else { |
stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer); |
url = stationsUrl; |
url += '&zoom='+zoom+ |
'&ne='+NELatLng+ |
'&sw='+SWLatLng; |
requeteChargementPoints = $.getJSON(url, function (stationsFiltrees) { |
stations = stationsFiltrees; |
nt = ntAFiltrer; |
$('#taxon-'+nt).addClass('taxon-actif'); |
rafraichirMarqueurs(stations); |
}); |
} |
}; |
|
/*+--------------------------------------------------------------------------------------------------------+*/ |
// FONCTIONS UTILITAIRES |
|
function ouvrirPopUp(element, nomPopUp, event) { |
var options = |
'width=650,'+ |
'height=600,'+ |
'scrollbars=yes,'+ |
'directories=no,'+ |
'location=no,'+ |
'menubar=no,'+ |
'status=no,'+ |
'toolbar=no'; |
var popUp = window.open(element.href, nomPopUp, options); |
if (window.focus) { |
popUp.focus(); |
} |
return arreter(event); |
}; |
|
function ouvrirNouvelleFenetre(element, event) { |
window.open(element.href); |
return arreter(event); |
} |
|
function arreter(event) { |
if (event.stopPropagation) { |
event.stopPropagation(); |
} else if (window.event) { |
window.event.cancelBubble = true; |
} |
if (event.preventDefault) { |
event.preventDefault(); |
} |
event.returnValue = false; |
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); |
} |