rateDate for convertCurrency
This commit is contained in:
parent
ce67cfbe44
commit
f78e3a5dfc
@ -175,33 +175,48 @@ function convertCurrency(value, currency, url) {
|
|||||||
switch(currency) {
|
switch(currency) {
|
||||||
case '£':
|
case '£':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.GBP) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.GBP) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '$ Américain':
|
case '$ Américain':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.USD) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.USD) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '$ Canadien':
|
case '$ Canadien':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.CAD) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.CAD) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '$ Australien':
|
case '$ Australien':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.AUD) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.AUD) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '$ Mexicain':
|
case '$ Mexicain':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.MXN) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.MXN) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case 'Fr':
|
case 'Fr':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.CHF) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.CHF) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '₽':
|
case '₽':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.RUB) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.RUB) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case 'R$':
|
case 'R$':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.BRL) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.BRL) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '¥':
|
case '¥':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.JPY) * value)).toFixed(2) + ' ' + currency);
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.JPY) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
break;
|
break;
|
||||||
case '€':
|
case '€':
|
||||||
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(jsonFixer.rates.EUR) * value)).toFixed(2) + ' ' + currency);
|
let rateEUR = jsonFixer.rates.EUR;
|
||||||
|
if (isNaN(rateEUR)) {
|
||||||
|
$('.results').html(formatNumberResult(value) + ' €');
|
||||||
|
} else {
|
||||||
|
$('.results').html(formatNumberResult(value) + ' ' + jsonFixer.base + ' = ' + ((parseFloat(rateEUR) * value)).toFixed(2) + ' ' + currency);
|
||||||
|
$('.rateDate').html("Dernier rafraîchissement du taux d'échange : " + jsonFixer.date);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$('.results').html(formatNumberResult(value) + ' €');
|
$('.results').html(formatNumberResult(value) + ' €');
|
||||||
|
@ -177,7 +177,6 @@ $(function () {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// let url = 'https://api.exchangeratesapi.io/latest';
|
|
||||||
let url = 'https://api.exchangeratesapi.io/latest?base=' + currencyOfTheValue;
|
let url = 'https://api.exchangeratesapi.io/latest?base=' + currencyOfTheValue;
|
||||||
value = parseFloat(value);
|
value = parseFloat(value);
|
||||||
convertCurrency(value, currencyAfter, url);
|
convertCurrency(value, currencyAfter, url);
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br> <br>
|
<br> <br>
|
||||||
<p class="results text-center"></p>
|
<p class="results text-center"></p>
|
||||||
|
<p class="rateDate text-center"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user