mirror of
https://github.com/gauvainboiche/ketapk.git
synced 2026-09-02 11:13:11 +02:00
refacto: Adding i18n support with FR and EN as base
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { CalculatorEngine } from '../../pkCore.js';
|
||||
import { CalculatorEngine } from '/pkCore.js';
|
||||
|
||||
export function initCalculatorUI() {
|
||||
const modal = document.getElementById('modalCalc');
|
||||
@@ -7,7 +7,6 @@ export function initCalculatorUI() {
|
||||
|
||||
if (!modal || !btnOpen || !btnClose) return;
|
||||
|
||||
// 1. Ouverture de la modale & synchronisation avec le formulaire principal
|
||||
btnOpen.addEventListener('click', () => {
|
||||
const mainWeight = document.getElementById('inputWeight')?.value || 70;
|
||||
const mainConc = document.getElementById('inputConc')?.value || 5;
|
||||
@@ -18,19 +17,16 @@ export function initCalculatorUI() {
|
||||
modal.classList.remove('hidden');
|
||||
});
|
||||
|
||||
// 2. Fermeture via le bouton X
|
||||
btnClose.addEventListener('click', () => {
|
||||
modal.classList.add('hidden');
|
||||
});
|
||||
|
||||
// 3. Fermeture au clic sur le fond sombre
|
||||
modal.addEventListener('click', (e) => {
|
||||
if (e.target === modal) {
|
||||
modal.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
// 4. Logique de conversion en temps réel
|
||||
const calcWeightInput = document.getElementById('calcWeight');
|
||||
const mgInput = document.getElementById('calcMg');
|
||||
const mgKgInput = document.getElementById('calcMgKg');
|
||||
@@ -39,25 +35,21 @@ export function initCalculatorUI() {
|
||||
|
||||
const getWeight = () => parseFloat(calcWeightInput.value) || 70;
|
||||
|
||||
// Bolus : mg -> mg/kg
|
||||
mgInput.addEventListener('input', () => {
|
||||
const mg = parseFloat(mgInput.value);
|
||||
mgKgInput.value = isNaN(mg) ? '' : (mg / getWeight()).toFixed(2);
|
||||
});
|
||||
|
||||
// Bolus : mg/kg -> mg
|
||||
mgKgInput.addEventListener('input', () => {
|
||||
const mgKg = parseFloat(mgKgInput.value);
|
||||
mgInput.value = isNaN(mgKg) ? '' : (mgKg * getWeight()).toFixed(1);
|
||||
});
|
||||
|
||||
// Perfusion : mg/kg/h -> µg/kg/min
|
||||
mgKgHInput.addEventListener('input', () => {
|
||||
const mgKgH = parseFloat(mgKgHInput.value);
|
||||
ugKgMinInput.value = isNaN(mgKgH) ? '' : CalculatorEngine.mgKgHToMicrogKgMin(mgKgH).toFixed(1);
|
||||
});
|
||||
|
||||
// Perfusion : µg/kg/min -> mg/kg/h
|
||||
ugKgMinInput.addEventListener('input', () => {
|
||||
const ug = parseFloat(ugKgMinInput.value);
|
||||
mgKgHInput.value = isNaN(ug) ? '' : CalculatorEngine.microgKgMinToMgKgH(ug).toFixed(2);
|
||||
|
||||
Reference in New Issue
Block a user