2019-08-16 12:05:56 +02:00
|
|
|
$(function () {
|
|
|
|
|
|
|
|
// Fichiers qui contient les variables
|
|
|
|
$.getScript("/scripts/variables.js", function() {
|
|
|
|
|
|
|
|
// Fichiers qui contient les fonctions
|
|
|
|
$.getScript("/scripts/fonctions.js", function() {
|
|
|
|
|
|
|
|
/* ÉXECUTION DES FONCTONS */
|
|
|
|
|
2019-08-28 13:41:26 +02:00
|
|
|
// $("#submitWeatherRequest") se fait exécuter dans weatherRequest.php
|
|
|
|
|
|
|
|
$("#submitRandomNumber").click(function()
|
2019-08-16 12:05:56 +02:00
|
|
|
{
|
|
|
|
let minEntered = $('#minValue').val();
|
|
|
|
let maxEntered = $('#maxValue').val();
|
|
|
|
|
|
|
|
if(isEmptyValue(minEntered) || isEmptyValue(maxEntered))
|
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
$('.results').html(emptyMessageError);
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let result = randomNumber(minEntered, maxEntered);
|
|
|
|
if(result === messageError)
|
|
|
|
{
|
|
|
|
$('.results').html(messageError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('.results').html("Nombre aléatoire compris entre " + minEntered + " inclus et " + maxEntered + " inclus : " + result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-28 13:41:26 +02:00
|
|
|
$("#submitCalculateAge").click(function()
|
2019-08-16 12:05:56 +02:00
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
let birthDateEntered = $('#birthDateValue').val();
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
if(isEmptyValue(birthDateEntered))
|
2019-08-16 12:05:56 +02:00
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
$('.results').html(emptyMessageError);
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
let result = calculateAge(birthDateEntered);
|
2019-08-16 12:05:56 +02:00
|
|
|
if(result === messageError)
|
|
|
|
{
|
|
|
|
$('.results').html(messageError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('.results').html(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-28 13:41:26 +02:00
|
|
|
$("#submitConvertTemperature").click(function()
|
2019-08-16 12:05:56 +02:00
|
|
|
{
|
|
|
|
let temperatureValue = $('#temperatureValue').val();
|
|
|
|
let degree = parseFloat(temperatureValue.slice(0, temperatureValue.length - 2));
|
|
|
|
let unit = temperatureValue.slice(temperatureValue.length - 2);
|
|
|
|
|
|
|
|
if(isEmptyValue(temperatureValue))
|
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
$('.results').html(emptyMessageError);
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let result = convertTemperature(degree, unit);
|
|
|
|
if(result === messageError)
|
|
|
|
{
|
|
|
|
$('.results').html(messageError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('.results').html(degree + " " + unit + " = " + result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-28 13:41:26 +02:00
|
|
|
$("#submitConvertDistance").click(function()
|
2019-08-16 12:05:56 +02:00
|
|
|
{
|
|
|
|
let firstValueEntered = $('#firstValue').val();
|
2019-08-16 12:28:46 +02:00
|
|
|
let secondValueEntered = $("#secondValue option:selected").text();
|
2019-08-16 12:05:56 +02:00
|
|
|
|
|
|
|
if(isEmptyValue(firstValueEntered) || isEmptyValue(secondValueEntered))
|
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
$('.results').html(emptyMessageError);
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let firstValue = parseFloat(firstValueEntered.slice(0, firstValueEntered.length - 2));;
|
|
|
|
let unitFirstValue = firstValueEntered.slice(firstValueEntered.length - 2);
|
|
|
|
|
|
|
|
let result = convertDistance(firstValue, unitFirstValue, secondValueEntered);
|
|
|
|
if(result === messageError)
|
|
|
|
{
|
|
|
|
$('.results').html(messageError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('.results').html(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
/* Permet d'afficher l'heure en temps réel sur le footer */
|
2019-08-17 12:32:35 +02:00
|
|
|
window.onload = realDateTime('realDateTime');
|
|
|
|
|
2019-08-23 20:23:57 +02:00
|
|
|
/* Window Scroll Top Button */
|
2019-08-28 13:41:26 +02:00
|
|
|
var $btnScrollTop = $('.scroll-top-arrow');
|
2019-08-23 20:23:57 +02:00
|
|
|
$(window).scroll(function () {
|
|
|
|
if ($(this).scrollTop() > 100) {
|
|
|
|
$btnScrollTop.fadeIn();
|
|
|
|
} else {
|
|
|
|
$btnScrollTop.fadeOut();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$btnScrollTop.on('click', function () {
|
|
|
|
$('html, body').animate({scrollTop: 0}, 800);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-08-16 12:05:56 +02:00
|
|
|
// Fin de l'import des fonctions
|
|
|
|
});
|
|
|
|
// Fin de l'import des variables
|
|
|
|
});
|
|
|
|
})
|