Small hotfix on convertRomanToArabic and contrary
This commit is contained in:
parent
7b66463c73
commit
3780269dd3
@ -8,7 +8,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row pb-5">
|
<div class="row pb-5">
|
||||||
<h1>Bienvenue sur <span class="important">FunctionProject</span> <i class="fas fa-file-code"></i></h1>
|
<h1>Bienvenue sur <span class="important">FunctionProject</span> <i class="fas fa-file-code"></i></h1>
|
||||||
<p class="pt-4 mx-auto"><a href="./views/function-list.php">Liste de Mini-programme</a> permettant de <b>savoir la météo</b>, générer un <b>nombre aléatoire</b>, etc.</p>
|
<p class="pt-4 mx-auto"><a href="/views/function-list.php">Liste de Mini-programme</a> permettant de <a href="/views/function-views/weatherRequest.php">savoir la météo</a>, générer un <a href="/views/function-views/randomNumber.php">nombre aléatoire</a>, etc.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-md-6 pb-4">
|
<div class="col-sm-12 col-md-6 pb-4">
|
||||||
|
@ -338,8 +338,12 @@ function convertArabicToRoman(nombre) {
|
|||||||
extraireChiffreRomain(correspondance[0], correspondance[1]);
|
extraireChiffreRomain(correspondance[0], correspondance[1]);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (chiffresRomains === '') {
|
||||||
|
return messageError;
|
||||||
|
} else {
|
||||||
return chiffresRomains;
|
return chiffresRomains;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convertis un nombre romain en nombre arabe
|
// Convertis un nombre romain en nombre arabe
|
||||||
function convertRomanToArabic(str) {
|
function convertRomanToArabic(str) {
|
||||||
|
@ -225,7 +225,12 @@ $(function () {
|
|||||||
}
|
}
|
||||||
else if (!isNaN(parseInt(numbersValue)) && convertNumberType === "Nombre Romain") {
|
else if (!isNaN(parseInt(numbersValue)) && convertNumberType === "Nombre Romain") {
|
||||||
let result = convertArabicToRoman(parseInt(numbersValue.replace(/\s/g,'')));
|
let result = convertArabicToRoman(parseInt(numbersValue.replace(/\s/g,'')));
|
||||||
$('.results').html(`<b>${formatNumberResult(numbersValue.replace(/\s/g,''))}</b> s'écrit <b>${result}</b> en chiffres romains.`);
|
let numbersValueFormat = formatNumberResult(numbersValue.replace(/\s/g,''));
|
||||||
|
if (numbersValueFormat === messageError || result === messageError) {
|
||||||
|
$('.results').html(messageError);
|
||||||
|
} else {
|
||||||
|
$('.results').html(`<b>${numbersValueFormat}</b> s'écrit <b>${result}</b> en chiffres romains.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (convertNumberType === "Nombre Arabe") {
|
else if (convertNumberType === "Nombre Arabe") {
|
||||||
if (!isNaN(parseInt(numbersValue))) {
|
if (!isNaN(parseInt(numbersValue))) {
|
||||||
@ -233,9 +238,13 @@ $(function () {
|
|||||||
} else {
|
} else {
|
||||||
numbersValue = numbersValue.toUpperCase();
|
numbersValue = numbersValue.toUpperCase();
|
||||||
let result = convertRomanToArabic(numbersValue);
|
let result = convertRomanToArabic(numbersValue);
|
||||||
|
if (result === 0) {
|
||||||
|
$('.results').html(messageError);
|
||||||
|
} else {
|
||||||
$('.results').html(`<b>${numbersValue}</b> s'écrit <b>${result}</b> en chiffres arabes.`);
|
$('.results').html(`<b>${numbersValue}</b> s'écrit <b>${result}</b> en chiffres arabes.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$('.results').html(messageError);
|
$('.results').html(messageError);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user