protion option
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
moerp 2024-04-04 12:30:18 +02:00
parent 3e6d743fd4
commit 8d853a8a43

View File

@ -111,11 +111,16 @@
document.getElementById('submit-button').disabled = !(food && weight);
}
function addProduct() {
const foodInput = document.getElementById('my_combobox');
const weightInput = document.getElementById('weight');
const food = foodInput.value;
const weight = weightInput.value;
let weight = parseFloat(weightInput.value);
const portions = Math.max(parseInt(portionsInput.value, 10), 1); // Stellt sicher, dass mindestens 1 Portion angegeben wird
// Teilen des Gewichts durch die Anzahl der Portionen und Aufrunden
weight = Math.ceil(weight / portions);
fetch(`/add_lm?food=${encodeURIComponent(food)}&weight=${encodeURIComponent(weight)}`)
@ -196,6 +201,9 @@ function updateTotalNutrition() {
<input type="number" id="weight" name="weight" placeholder="Gramm" oninput="updateButtonState()">
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
<input type="number" id="portions" name="portions" placeholder="Portionen" oninput="updateButtonState()" min="1" value="1">
</form>
<table id="nutrition-table">