43,6 → 43,57 |
} |
|
//+----------------------------------------------------------------------------------------------------------+ |
// PRÉCHARGEMENT DU FORMULAIRE |
$(document).ready(function() { |
if (OBS_ID != '') { |
chargerInfoObs(); |
} |
}); |
|
function chargerInfoObs() { |
var urlObs = SERVICE_OBS_URL + '/' + OBS_ID; |
$.ajax({ |
url: urlObs, |
type: 'GET', |
success: function(data, textStatus, jqXHR) { |
if (data != undefined) { |
prechargerForm(data); |
} else { |
surErreurChargementInfosObs(); |
} |
}, |
error: function(jqXHR, textStatus, errorThrown) { |
surErreurChargementInfosObs(); |
} |
}); |
} |
|
function prechargerForm(infos) { |
$('input[name="station"]').val(infos.station); |
|
var dateParts = infos.dateObservation.split('-'); |
var dateObs = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]); |
var dateObsStr = ('0' + dateObs.getDate()).slice(-2) + '/' + |
('0' + (dateObs.getMonth()+1)).slice(-2) + '/' + |
dateObs.getFullYear(); |
$('input[name="date"]').val(dateObsStr); |
|
$.each(infos.extension, function(index, value) { |
if ($('[name="' + index + '"]').hasClass('slider')) { |
console.log('select[name="' + index + '"] option[value="' + value.valeur + '"]'); |
$('select[name="' + index + '"] option[value="' + value.valeur + '"]') |
.attr('selected', 'selected'); |
var selectedIndexOptions = $('select[name="' + index + '"]').prop('selectedIndex') + 1; |
console.log(selectedIndexOptions); |
$('[name="' + index + '"]').parent().find('.horizontal-slider').slider('value', selectedIndexOptions); |
} else { |
$('[name="' + index + '"]').val(value.valeur); |
} |
}); |
} |
|
|
//+----------------------------------------------------------------------------------------------------------+ |
//FORM IDENTITE : gestion de l'observateur |
|
$(document).ready(function() { |
73,7 → 124,7 |
$('#nom').val(infos.nom); |
$('#courriel_confirmation').val(courriel); |
$('#prenom, #nom, #courriel_confirmation').attr('disabled', 'disabled'); |
$('#date').focus(); |
$('#structure').focus(); |
} else { |
surErreurCompletionCourriel(); |
} |