Hotfix: Réorganisation fonctions principales
This commit is contained in:
14
scripts/execute-function/armstrongNumber_DOM.js
Normal file
14
scripts/execute-function/armstrongNumber_DOM.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { armstrongNumber } from '../functions/fonctions_principales/armstrongNumber_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#numberToTest").bind("keyup change", () => {
|
||||
let numbersValue = $('#numberToTest').val();
|
||||
numbersValue = parseInt(numbersValue.replace(/\s/g,''));
|
||||
if (!isNaN(numbersValue) && numbersValue >= 0) {
|
||||
$('.results').html(armstrongNumber(numbersValue));
|
||||
}
|
||||
else {
|
||||
$('.results').html(messageError);
|
||||
}
|
||||
});
|
||||
});
|
7
scripts/execute-function/calculateAge_DOM.js
Normal file
7
scripts/execute-function/calculateAge_DOM.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { calculateAge } from '../functions/fonctions_principales/calculateAge_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#birthDateValue").bind("keyup change", () => {
|
||||
$('.results').html(calculateAge($('#birthDateValue').val()));
|
||||
});
|
||||
});
|
0
scripts/execute-function/convertCurrency_DOM.js
Normal file
0
scripts/execute-function/convertCurrency_DOM.js
Normal file
17
scripts/execute-function/convertDistance_DOM.js
Normal file
17
scripts/execute-function/convertDistance_DOM.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { convertDistance } from '../functions/fonctions_principales/convertDistance_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#convertDistanceForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
let firstValue = $('#firstValue').val();
|
||||
const unitFirstValue = $("#firstValueUnit option:selected").text();
|
||||
const secondValue = $("#secondValue option:selected").text();
|
||||
if(isEmptyValue(firstValue) || isEmptyValue(secondValue)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else {
|
||||
firstValue = parseFloat(firstValue.replace(/\s/g,''));
|
||||
$('.results').html(convertDistance(firstValue, unitFirstValue, secondValue));
|
||||
}
|
||||
});
|
||||
});
|
24
scripts/execute-function/convertEncoding_DOM.js
Normal file
24
scripts/execute-function/convertEncoding_DOM.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { decimalToBinary, binaryToDecimal, decimalToHexadecimal, hexadecimalToDecimal, binaryToHexadecimal, hexadecimalToBinary, textToNumberUnicode, numberUnicodeToText, textToBinary, binaryToText, textToHexadecimal, hexadecimalToText } from '../functions/fonctions_principales/convertEncoding_Functions.js';
|
||||
|
||||
$(function () {
|
||||
$("#convertEncodingForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const value = $('#value').val();
|
||||
const option = $("#option option:selected").val();
|
||||
if(isEmptyValue(value)) {
|
||||
$('.results').html(messageError);
|
||||
}
|
||||
else {
|
||||
// Objet qui recense toutes les fonctions de convertEncoding
|
||||
const convertEncoding = { decimalToBinary, binaryToDecimal, decimalToHexadecimal, hexadecimalToDecimal, binaryToHexadecimal, hexadecimalToBinary, textToNumberUnicode, numberUnicodeToText, textToBinary, binaryToText, textToHexadecimal, hexadecimalToText };
|
||||
try {
|
||||
function executionFunction(option, value) {
|
||||
return convertEncoding[option](value);
|
||||
}
|
||||
$('.results').html(executionFunction(option, value));
|
||||
} catch (error) {
|
||||
$('.results').html(messageError);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
37
scripts/execute-function/convertRomanArabicNumbers_DOM.js
Normal file
37
scripts/execute-function/convertRomanArabicNumbers_DOM.js
Normal file
@ -0,0 +1,37 @@
|
||||
import { convertArabicToRoman, convertRomanToArabic } from '../functions/fonctions_principales/convertRomanArabicNumbers_Functions.js';
|
||||
|
||||
$(function () {
|
||||
$("#convertRomanArabicNumbersForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
let numbersValue = $('#numbersArabic').val();
|
||||
numbersValue = numbersValue.replace(/\s/g,'');
|
||||
const convertNumberType = $("#convertNumberType option:selected").text();
|
||||
if(isEmptyValue(numbersValue)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else if (!isNaN(Number(numbersValue))) {
|
||||
if (convertNumberType === "Nombre Romain") {
|
||||
const result = convertArabicToRoman(parseInt(numbersValue));
|
||||
let numbersValueFormat = formatNumberResult(numbersValue);
|
||||
if (result === messageError || isFloat(numbersValue)) {
|
||||
$('.results').html(messageError);
|
||||
} else {
|
||||
$('.results').html(`<b>${numbersValueFormat}</b> s'écrit <b>${result}</b> en chiffres romains.`);
|
||||
}
|
||||
} else {
|
||||
$('.results').html(`<b>${numbersValue}</b> est déjà en chiffres arabes.`);
|
||||
}
|
||||
}
|
||||
else if (convertNumberType === "Nombre Arabe") {
|
||||
const result = convertRomanToArabic(numbersValue.toUpperCase());
|
||||
if (result === 0) {
|
||||
$('.results').html(messageError);
|
||||
} else {
|
||||
$('.results').html(`<b>${numbersValue}</b> s'écrit <b>${formatNumberResult(result)}</b> en chiffres arabes.`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('.results').html(messageError);
|
||||
}
|
||||
});
|
||||
});
|
16
scripts/execute-function/convertTemperature_DOM.js
Normal file
16
scripts/execute-function/convertTemperature_DOM.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { convertTemperature } from '../functions/fonctions_principales/convertTemperature_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#convertTemperatureForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const temperatureValue = $('#temperatureValue').val();
|
||||
const degree = parseFloat(temperatureValue.slice(0, temperatureValue.length - 2));
|
||||
const unit = temperatureValue.slice(temperatureValue.length - 2);
|
||||
if(isEmptyValue(temperatureValue)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else {
|
||||
$('.results').html(convertTemperature(degree, unit));
|
||||
}
|
||||
});
|
||||
});
|
20
scripts/execute-function/filterStudents_DOM.js
Normal file
20
scripts/execute-function/filterStudents_DOM.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { filterStudents } from '../functions/fonctions_principales/filterStudents_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#filterStudentsForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const nameEntered = $('#nameEntered').val();
|
||||
let filteredLetter = $("#filteredLetter").val();
|
||||
if(isEmptyValue(nameEntered) || isEmptyValue(filteredLetter)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else if(filteredLetter.length === 1) {
|
||||
const students = nameEntered.split(', ');
|
||||
filteredLetter = capitalize(filteredLetter);
|
||||
$('.results').html(filterStudents(filteredLetter, students));
|
||||
}
|
||||
else {
|
||||
$('.results').html(messageError);
|
||||
}
|
||||
});
|
||||
});
|
21
scripts/execute-function/heapAlgorithm_DOM.js
Normal file
21
scripts/execute-function/heapAlgorithm_DOM.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { heapAlgorithm } from '../functions/fonctions_principales/heapAlgorithm_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#heapAlgorithmForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const value = $('#value').val();
|
||||
if(isEmptyValue(value)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else {
|
||||
const start = new Date();
|
||||
const stringPermutationsResult = heapAlgorithm(value);
|
||||
let result = "";
|
||||
for (let element in stringPermutationsResult) {
|
||||
result = result + stringPermutationsResult[element] + "<br>";
|
||||
}
|
||||
const end = new Date();
|
||||
$('.results').html(`Temps d'éxecution du script : ${end - start} ms. <br>Il y a ${formatNumberResult(stringPermutationsResult.length)} possibilités d'anagramme pour le mot "${value}" qui contient ${value.length} caractères, la liste : <br><br> ${result}`);
|
||||
}
|
||||
});
|
||||
});
|
20
scripts/execute-function/randomNumber_DOM.js
Normal file
20
scripts/execute-function/randomNumber_DOM.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { randomNumber } from '../functions/fonctions_principales/randomNumber_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#randomNumberForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const minEntered = $('#minValue').val();
|
||||
const maxEntered = $('#maxValue').val();
|
||||
if(isEmptyValue(minEntered) || isEmptyValue(maxEntered)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else {
|
||||
const result = randomNumber(minEntered, maxEntered);
|
||||
if(result === messageError) {
|
||||
$('.results').html(messageError);
|
||||
} else {
|
||||
$('.results').html("Nombre aléatoire compris entre " + minEntered + " inclus et " + maxEntered + " inclus : " + formatNumberResult(result));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
17
scripts/execute-function/randomQuote_DOM.js
Normal file
17
scripts/execute-function/randomQuote_DOM.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { randomQuote } from '../functions/fonctions_principales/randomQuote_Function.js';
|
||||
|
||||
$(function () {
|
||||
function showQuote() {
|
||||
const randomQuoteChosen = randomQuote();
|
||||
const quote = randomQuoteChosen.quote;
|
||||
const source = randomQuoteChosen.source;
|
||||
$('.resultsRandomQuote').html(`<p id="citation">" ${quote} "</p> <p id="auteur"> - ${source} </p>`);
|
||||
$('#twitterLink').attr('href', `https://twitter.com/intent/tweet?text="${quote}" - ${source}&via=Divlo_FR&hashtags=citation,FunctionProject&url=https://function.divlo.fr/views/function-views/randomQuote.php`);
|
||||
}
|
||||
|
||||
$("#submitRandomQuote").click(() => {
|
||||
showQuote();
|
||||
});
|
||||
// Affichage d'une citation au chargement de la page
|
||||
showQuote();
|
||||
});
|
16
scripts/execute-function/weatherRequest_DOM.js
Normal file
16
scripts/execute-function/weatherRequest_DOM.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { weatherRequest } from '../functions/fonctions_principales/weatherRequest_Function.js';
|
||||
|
||||
$(function () {
|
||||
$("#weatherForm").submit((event) => {
|
||||
event.preventDefault();
|
||||
const city = $('#cityName').val();
|
||||
const cityName = city.split(' ').join('+');
|
||||
const data = `city=${cityName}`;
|
||||
if(isEmptyValue(cityName)) {
|
||||
$('.results').html(emptyMessageError);
|
||||
}
|
||||
else {
|
||||
weatherRequest(data);
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user