Ajout de devise à convertir - convertCurrency

This commit is contained in:
Divlo 2019-09-13 22:44:37 +02:00
parent c5c167a806
commit 6f78363db8
2 changed files with 35 additions and 6 deletions

View File

@ -184,11 +184,32 @@ function convertCurrency(urlFixerIO, currency, euroValue) {
dataType : "jsonp",
success: function (jsonFixer) {
switch(currency) {
case '$':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + (formatNumberResult(parseFloat(jsonFixer.rates.USD) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '£':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + (formatNumberResult(parseFloat(jsonFixer.rates.GBP) * euroValue)).toFixed(2) + ' ' + currency);
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.GBP) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '$ Américain':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.USD) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '$ Canadien':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.CAD) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '$ Australien':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.AUD) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '$ Mexicain':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.MXN) * euroValue)).toFixed(2) + ' ' + currency);
break;
case 'Fr':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.CHF) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '₽':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.RUB) * euroValue)).toFixed(2) + ' ' + currency);
break;
case 'R$':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.BRL) * euroValue)).toFixed(2) + ' ' + currency);
break;
case '¥':
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.JPY) * euroValue)).toFixed(2) + ' ' + currency);
break;
default:
$('.results').html(formatNumberResult(euroValue) + ' €');
@ -203,6 +224,7 @@ function convertCurrency(urlFixerIO, currency, euroValue) {
});
}
/////////////////////////////////////////////////////////////////
/* Fonctions Annexes */

View File

@ -16,8 +16,15 @@
<br> <br>
<label for="euroToCurrency">Choisissez la devise que voulez avoir après conversion :</label> <br>
<select id="euroToCurrency">
<option value="$">$ - USD - Dollar Américain</option>
<option value="£">£ - GBP - Livre sterling</option>
<option value="£">Livre sterling (£) - GBP</option>
<option value="$ Américain">Dollar Américain ($) - USD</option>
<option value="$ Canadien">Dollar Canadien ($) - CAD</option>
<option value="$ Australien">Dollar Australien ($) - AUD</option>
<option value="$ Mexicain">Peso Mexicain ($) - MXN</option>
<option value="Fr">Franc Suisse (Fr) - CHF</option>
<option value="">Rouble Russe () - RUB</option>
<option value="R$">Réal brésilien (R$) - BRL</option>
<option value="¥">Yen (¥) - JPY</option>
</select>
<br>
<div class="form-row text-center">