This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/scripts/execute-function/convertTemperature_DOM.js

16 lines
642 B
JavaScript
Raw Normal View History

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));
}
});
});