diff --git a/index.html b/index.html index 3bf2c04..7b93b19 100644 --- a/index.html +++ b/index.html @@ -3,15 +3,33 @@ Doses + +

Doses converter

- - - - - - + +

+ + +

+ +

+ + + +

+ +

+ + + +

+ diff --git a/main.js b/main.js index e69de29..51fe2a2 100644 --- a/main.js +++ b/main.js @@ -0,0 +1,38 @@ +const computeVolumeButton = document.getElementById("compute-volume"); +computeVolumeButton.addEventListener("click", () => { + const dose = getDoseValue(); + const proof = getProofValue(); + const volume = (dose * 100) / 0.8 / proof; + setVolumeValue(volume.toFixed(2)); +}); +const computeDoseButton = document.getElementById("compute-dose"); +computeDoseButton.addEventListener("click", () => { + const volume = getVolumeValue(); + const proof = getProofValue(); + const dose = (volume / 100) * 0.8 * proof; + setDoseValue(dose.toFixed(2)); +}); + +const proofInput = document.getElementById("proof"); +const volumeInput = document.getElementById("volume"); +const doseInput = document.getElementById("dose"); + +function getProofValue() { + return parseFloat(proofInput.value); +} + +function getVolumeValue() { + return parseFloat(volumeInput.value); +} + +function setVolumeValue(value) { + volumeInput.value = value; +} + +function getDoseValue() { + return parseFloat(doseInput.value); +} + +function setDoseValue(value) { + doseInput.value = value; +}