66,7 → 66,6 |
url: urlAnnuaire, |
type: 'GET', |
success: function(data, textStatus, jqXHR) { |
console.log('SUCCESS:'+textStatus); |
if (data != undefined && data[courriel] != undefined) { |
var infos = data[courriel]; |
$('#id_utilisateur').val(infos.id); |
80,11 → 79,9 |
} |
}, |
error: function(jqXHR, textStatus, errorThrown) { |
console.log('ERREUR :'+textStatus); |
surErreurCompletionCourriel(); |
}, |
complete: function(jqXHR, textStatus) { |
console.log('COMPLETE :'+textStatus); |
$('#zone-prenom-nom').removeClass('hidden'); |
$('#zone-courriel-confirmation').removeClass('hidden'); |
} |
127,12 → 124,17 |
// GOOGLE MAP |
|
var map, |
marker, |
latLng, |
geocoder; |
geocoder, |
markerDeb, |
latLngDeb, |
markerFin, |
latLngFin, |
ligneRue, |
premierDeplacement = true; |
|
$(document).ready(function() { |
initialiserGoogleMap(); |
afficherEtapeGeolocalisation(1); |
|
// Autocompletion du champ adresse |
$('#carte-recherche').on('focus', function() { |
172,23 → 174,22 |
select: function(event, ui) { |
var latLng = new google.maps.LatLng(ui.item.latitude, ui.item.longitude); |
deplacerMarker(latLng); |
map.setZoom(16); |
} |
}); |
|
$('#geolocaliser').on('click', geolocaliser); |
|
//google.maps.event.addListener(marker, 'dragend', surDeplacementMarker); |
google.maps.event.addListener(markerDeb, 'dragend', surDeplacementMarkerDeb); |
|
//google.maps.event.addListener(map, 'click', surClickDansCarte); |
google.maps.event.addListener(map, 'click', surClickDansCarte); |
}); |
|
function initialiserGoogleMap(){ |
// Carte |
var latLng = new google.maps.LatLng(46.30871, 2.54395),// Centre de la France |
zoomDefaut = 5; |
options = { |
zoom: zoomDefaut, |
center: latLng, |
latLngDeb = new google.maps.LatLng(46.30871, 2.54395);// Centre de la France |
var options = { |
zoom: 5, |
center: latLngDeb, |
mapTypeId: google.maps.MapTypeId.HYBRID, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', |
217,50 → 218,53 |
// Création du Geocoder |
geocoder = new google.maps.Geocoder(); |
|
// Marqueur google draggable |
marker = new google.maps.Marker({ |
// Marqueur de début de Rue |
markerDeb = new google.maps.Marker({ |
map: map, |
draggable: true, |
title: 'Ma station', |
icon: GOOGLE_MAP_MARQUEUR_URL, |
position: latLng |
title: 'Début de la portion de rue étudiée', |
icon: GOOGLE_MAP_MARQUEUR_DEBUT_URL, |
position: latLngDeb |
}); |
initialiserMarkerDeb(latLngDeb); |
|
initialiserMarker(latLng); |
|
// Tentative de geocalisation |
|
if (navigator.geolocation) { |
navigator.geolocation.getCurrentPosition(function(position) { |
var latitude = position.coords.latitude, |
longitude = position.coords.longitude; |
latLng = new google.maps.LatLng(latitude, longitude); |
|
deplacerMarker(latLng); |
}); |
} |
tenterGeolocalisation(); |
} |
|
function surDeplacementMarker() { |
trouverCommune(marker.getPosition()); |
mettreAJourMarkerPosition(marker.getPosition()); |
function afficherErreurGoogleMap(status) { |
if (DEBUG) { |
$('#dialogue-google-map .contenu').empty().append( |
'<pre class="msg-erreur">'+ |
"Le service de Géocodage de Google Map a échoué à cause de l'erreur : "+status+ |
'</pre>'); |
afficherPanneau('#dialogue-google-map'); |
} |
} |
|
function surClickDansCarte(event) { |
deplacerMarker(event.latLng); |
} |
|
function geolocaliser(event) { |
var latitude = $('#latitude').val(), |
longitude = $('#longitude').val(); |
latLng = new google.maps.LatLng(latitude, longitude); |
deplacerMarker(latLng); |
afficherEtapeGeolocalisation(2); |
map.setZoom(16); |
arreter(event); |
} |
|
function initialiserMarker(latLng) { |
if (marker != undefined) { |
marker.setPosition(latLng); |
function surDeplacementMarkerDeb() { |
trouverCommune(markerDeb.getPosition()); |
mettreAJourMarkerPosition(markerDeb.getPosition()); |
deplacerMarker(markerDeb.getPosition()); |
} |
|
function surClickDansCarte(event) { |
deplacerMarker(event.latLng); |
} |
|
function initialiserMarkerDeb(latLng) { |
if (markerDeb != undefined) { |
markerDeb.setPosition(latLng); |
map.setCenter(latLng); |
mettreAJourMarkerPosition(latLng); |
trouverCommune(latLng); |
267,15 → 271,82 |
} |
} |
|
function tenterGeolocalisation() { |
if (navigator.geolocation) { |
navigator.geolocation.getCurrentPosition(function(position) { |
var latitude = position.coords.latitude, |
longitude = position.coords.longitude; |
latLngDeb = new google.maps.LatLng(latitude, longitude); |
latLngFin = latLngDeb; |
// si l'utilisateur géolocalise sa ville alors le premier déplacement doit être réinitialisé |
premierDeplacement = true; |
deplacerMarker(latLngDeb); |
map.setZoom(16); |
}); |
} |
} |
|
function deplacerMarker(latLng) { |
if (marker != undefined) { |
marker.setPosition(latLng); |
map.setCenter(latLng); |
mettreAJourMarkerPosition(latLng); |
trouverCommune(latLng); |
if (markerDeb != undefined) { |
latLngDeb = latLng; |
markerDeb.setPosition(latLngDeb); |
map.setCenter(latLngDeb); |
trouverCommune(latLngDeb); |
|
if (!premierDeplacement) { |
if (markerFin != undefined) { |
markerFin.setMap(null); |
} |
|
latLngFin = new google.maps.LatLng(latLngDeb.lat(), latLngDeb.lng() + 0.0010); |
markerFin = new google.maps.Marker({ |
map: map, |
draggable: true, |
title: 'Fin de la portion de rue étudiée', |
icon: GOOGLE_MAP_MARQUEUR_FIN_URL, |
position: latLngFin |
}); |
google.maps.event.addListener(markerFin, 'dragend', function() { |
dessinerLigneRue(markerDeb.getPosition(), markerFin.getPosition()); |
latLngDeb = markerDeb.getPosition(); |
latLngFin = markerFin.getPosition(); |
latLngCentre = new google.maps.LatLng((latLngFin.lat() + latLngDeb.lat())/2, (latLngFin.lng() + latLngDeb.lng())/2); |
mettreAJourMarkerPosition(latLngCentre); |
afficherEtapeGeolocalisation(4); |
}); |
|
dessinerLigneRue(latLngDeb, latLngFin); |
|
latLngCentre = new google.maps.LatLng((latLngFin.lat() + latLngDeb.lat())/2, (latLngFin.lng() + latLngDeb.lng())/2); |
mettreAJourMarkerPosition(latLngCentre); |
afficherEtapeGeolocalisation(3); |
} else { |
mettreAJourMarkerPosition(latLngDeb); |
} |
premierDeplacement = false; |
} |
} |
|
function dessinerLigneRue(pointDebut, pointFin) { |
if (ligneRue != undefined) { |
ligneRue.setMap(null); |
} |
|
ligneRue = new google.maps.Polyline({ |
path: [pointDebut, pointFin], |
strokeColor: "#FF0000", |
strokeOpacity: 1.0, |
strokeWeight: 2 |
}); |
|
ligneRue.setMap(map); |
} |
|
function afficherEtapeGeolocalisation(numEtape) { |
$('.liste_indication_geolocalisation').children().hide(); |
$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show(); |
} |
|
function mettreAJourMarkerPosition(latLng) { |
var lat = latLng.lat().toFixed(5), |
lng = latLng.lng().toFixed(5); |
370,7 → 441,6 |
|
var url = getUrlAutocompletionNomsSci(); |
$.getJSON(url, function(data) { |
console.log(data); |
var suggestions = traiterRetourNomsSci(data); |
add(suggestions); |
}); |
474,8 → 544,24 |
//+----------------------------------------------------------------------------------------------------------+ |
//UPLOAD PHOTO : Traitement de l'image |
$(document).ready(function() { |
$('body').on('click', '.effacer-miniature', function(event) { |
supprimerMiniature($(this)); |
$('#fichier').on('click change', function(event) { |
if ($(this).val().length > 0) { |
arreter(event); |
var options = { |
success: afficherMiniature, // post-submit callback |
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type) |
resetForm: true // reset the form after successful submit |
}; |
$('#miniature').append( |
'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+CHARGEMENT_IMAGE_URL+'"/>'); |
$('#ajouter-obs').attr('disabled', 'disabled'); |
if (verifierFormat($(this).val())) { |
$('#form-upload').ajaxSubmit(options); |
} else { |
window.alert("Le format de fichier n'est pas supporté, les formats acceptés sont "+ $('#fichier').attr('accept')); |
} |
return false; |
} |
}); |
|
$('#photo-placeholder').click(function(event) { |
482,29 → 568,13 |
$('#fichier').click(); |
}); |
|
$('#fichier').bind('change', function (e) { |
arreter(e); |
var options = { |
success: afficherMiniature, // post-submit callback |
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type) |
resetForm: true // reset the form after successful submit |
}; |
$('#miniature').append( |
'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+CHARGEMENT_IMAGE_URL+'"/>'); |
$('#ajouter-obs').attr('disabled', 'disabled'); |
if (verifierFormat($('#fichier').val())) { |
$('#form-upload').ajaxSubmit(options); |
} else { |
window.alert("Le format de fichier n'est pas supporté, les formats acceptés sont "+ $('#fichier').attr('accept')); |
} |
return false; |
$('body').on('click', '.effacer-miniature', function(event) { |
supprimerMiniature($(this)); |
}); |
|
$('.effacer-miniature').on('click', function() { |
$(this).parent().remove(); |
}); |
}); |
|
|
|
function verifierFormat(nom) { |
var parts = nom.split('.'); |
extension = parts[parts.length - 1]; |
514,7 → 584,7 |
function afficherMiniature(reponse) { |
if (DEBUG) { |
var debogage = $('debogage', reponse).text(); |
console.log('Débogage upload : ' + debogage); |
//console.log('Débogage upload : ' + debogage); |
} |
var message = $('message', reponse).text(); |
if (message != '') { |
522,7 → 592,7 |
} else { |
$('#miniatures').append(creerWidgetMiniature(reponse)); |
} |
$('#ajouter-obs').removeAttr('disabled'); |
$('#ajouter-obs').removeAttr('disabled'); |
} |
|
function creerWidgetMiniature(reponse) { |
600,7 → 670,6 |
$('input#hauteur-plante').on('blur', function() { |
// if there's a bad value |
var valeur = $(this).val(); |
console.log(valeur); |
if (! valeur.match(/^[0-9]+$/)) { |
// replace it with nothing |
var nouvelleValeur = valeur.replace(/[^0-9]/g, ''); |
694,7 → 763,7 |
showButtonPanel: true, |
onSelect: function(date) { |
$(this).valid(); |
} |
} |
}); |
$(selector + ' + img.ui-datepicker-trigger').appendTo(selector + '-icone.add-on'); |
} |
780,12 → 849,12 |
required: true} |
}, |
errorPlacement: function(error, element) { |
if (element.attr('name') == 'date') { |
element.parent('.input-prepend').after(error); |
} else { |
error.insertAfter(element); |
} |
} |
if (element.attr('name') == 'date') { |
element.parent('.input-prepend').after(error); |
} else { |
error.insertAfter(element); |
} |
} |
}); |
$('#form-obs').validate({ |
rules: { |
801,12 → 870,12 |
required: true} |
}, |
errorPlacement: function(error, element) { |
if (element.attr('name') == 'milieux[]') { |
error.insertAfter('#milieux-controls'); |
} else { |
error.insertAfter(element); |
} |
} |
if (element.attr('name') == 'milieux[]') { |
error.insertAfter('#milieux-controls'); |
} else { |
error.insertAfter(element); |
} |
} |
}); |
} |
|
814,8 → 883,12 |
var observateur = $('#form-observateur').valid(), |
station = $('#form-site').valid(), |
date = $('#form-date').valid(), |
obs = $('#form-obs').valid(); |
return (observateur == true && station == true && obs == true && date == true) ? true : false; |
obs = $('#form-obs').valid(), |
debRue = (latLngDeb == undefined) ? false : true, |
finRue = (latLngFin == undefined) ? false : true; |
var ok = (observateur && station && obs && date && debRue && finRue) ? true : false; |
//console.log(observateur+'-'+station+'-'+obs+'-'+date+'-'+debRue+'-'+finRue); |
return ok; |
} |
|
|
861,9 → 934,14 |
afficherObs(); |
stockerObsData(); |
supprimerMiniatures(); |
$('#taxon').val('').data('numNomSel', undefined).removeClass('ns-retenu'); |
} else { |
afficherPanneau('#dialogue-form-invalide'); |
var debRue = (latLngDeb == undefined) ? false : true, |
finRue = (latLngFin == undefined) ? false : true; |
if (debRue == false || finRue == false) { |
afficherPanneau('#dialogue-form-invalide-rue'); |
} else { |
afficherPanneau('#dialogue-form-invalide'); |
} |
} |
} |
|
982,7 → 1060,6 |
var miniatureAffichee = miniatureSelectionne; |
|
var indicateurActif = element.parent().find('.defilement-indicateurs .active'); |
console.log(indicateurActif) |
indicateurActif.removeClass('active'); |
|
if (element.hasClass('defilement-control-zone') && element.hasClass('gauche')) { |
1106,7 → 1183,7 |
// Ajout des champs étendus de l'obs |
'obs_etendue': getObsChpEtendus() |
}); |
console.log($('#liste-obs').data('obsId'+obsNbre)); |
//console.log($('#liste-obs').data('obsId'+obsNbre)); |
} |
|
function getObsChpEtendus() { |
1115,6 → 1192,19 |
if (perceptionTechnicien != undefined) { |
champs.push(perceptionTechnicien); |
} |
if (latLngDeb != undefined) { |
var latitudeDebutRue = {cle: 'latitudeDebutRue', label: 'Latitude du début de la rue', valeur: latLngDeb.lat().toFixed(5)}; |
champs.push(latitudeDebutRue); |
var longitudeDebutRue = {cle: 'longitudeDebutRue', label: 'Longitude du début de la rue', valeur: latLngDeb.lng().toFixed(5)}; |
champs.push(longitudeDebutRue); |
} |
if (latLngFin != undefined) { |
var latitudeFinRue = {cle: 'latitudeFinRue', label: 'Latitude de fin de la rue', valeur: latLngFin.lat().toFixed(5)}; |
champs.push(latitudeFinRue); |
var longitudeFinRue = {cle: 'longitudeFinRue', label: 'Longitude de fin de la rue', valeur: latLngFin.lng().toFixed(5)}; |
champs.push(longitudeFinRue); |
} |
|
$('.obs-chp-etendu').each(function() { |
var valeur = $(this).val(), |
cle = $(this).attr('name'), |
1145,7 → 1235,6 |
|
function transmettreObs() { |
var observations = $('#liste-obs').data(); |
console.log(observations); |
|
if (observations == undefined || jQuery.isEmptyObject(observations)) { |
afficherPanneau('#dialogue-zero-obs'); |