From 6f78363db8a8604453ee892763e5f6513c88d1d3 Mon Sep 17 00:00:00 2001 From: Divlo Date: Fri, 13 Sep 2019 22:44:37 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20devise=20=C3=A0=20convertir=20-=20?= =?UTF-8?q?convertCurrency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/fonctions.js | 30 ++++++++++++++++++++---- views/function-views/convertCurrency.php | 11 +++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/scripts/fonctions.js b/scripts/fonctions.js index e7f4f10..c05c1cf 100644 --- a/scripts/fonctions.js +++ b/scripts/fonctions.js @@ -184,12 +184,33 @@ 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) + ' €'); break; @@ -203,6 +224,7 @@ function convertCurrency(urlFixerIO, currency, euroValue) { }); } + ///////////////////////////////////////////////////////////////// /* Fonctions Annexes */ diff --git a/views/function-views/convertCurrency.php b/views/function-views/convertCurrency.php index 5235094..d2fc04d 100644 --- a/views/function-views/convertCurrency.php +++ b/views/function-views/convertCurrency.php @@ -16,8 +16,15 @@