j'ai retiré des commentaires pas utiles
This commit is contained in:
103
index.html
103
index.html
@@ -1,15 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="assets/style.css" />
|
||||
<title>Calculateur d'épices</title>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- div contenant le titre -->
|
||||
<body>
|
||||
<div id="titre">
|
||||
<h1 id="grandTitre">Calcul des épices</h1>
|
||||
</div>
|
||||
@@ -70,19 +68,20 @@
|
||||
const propAil = getElementValue("Prop_ail");
|
||||
let qteSel;
|
||||
if (!document.getElementById("isCouenne" + ligne).checked) {
|
||||
qteSel = net * propSel
|
||||
qteSel = net * propSel;
|
||||
} else {
|
||||
qteSel = net * (propSel / 2)
|
||||
};
|
||||
document.getElementById("Sel (Kg)" + ligne).innerHTML = (
|
||||
qteSel
|
||||
).toFixed(3);
|
||||
qteSel = net * (propSel / 2);
|
||||
}
|
||||
document.getElementById("Sel (Kg)" + ligne).innerHTML =
|
||||
qteSel.toFixed(3);
|
||||
document.getElementById("Poivre (g)" + ligne).innerHTML = (
|
||||
(net * propPoivre) * 0.6
|
||||
).toFixed(3);
|
||||
document.getElementById("Poivre concassé (g)" + ligne).innerHTML = (
|
||||
(net * propPoivre) * 0.4
|
||||
net *
|
||||
propPoivre *
|
||||
0.6
|
||||
).toFixed(3);
|
||||
document.getElementById(
|
||||
"Poivre concassé (g)" + ligne,
|
||||
).innerHTML = (net * propPoivre * 0.4).toFixed(3);
|
||||
document.getElementById("Muscade (g)" + ligne).innerHTML = (
|
||||
net * propMuscade
|
||||
).toFixed(3);
|
||||
@@ -90,11 +89,16 @@
|
||||
net * propAil
|
||||
).toFixed(3);
|
||||
} else {
|
||||
["Net", "Sel (Kg)", "Poivre (g)", "Poivre concassé (g)", "Muscade (g)", "Ail (g)"].forEach(
|
||||
(colonne) => {
|
||||
[
|
||||
"Net",
|
||||
"Sel (Kg)",
|
||||
"Poivre (g)",
|
||||
"Poivre concassé (g)",
|
||||
"Muscade (g)",
|
||||
"Ail (g)",
|
||||
].forEach((colonne) => {
|
||||
document.getElementById(colonne + ligne).innerHTML = "";
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
calculerTotaux(); // Recalcul des totaux après chaque changement
|
||||
}
|
||||
@@ -117,20 +121,25 @@
|
||||
totalNet += getElementText("Net" + i);
|
||||
totalSel += getElementText("Sel (Kg)" + i);
|
||||
totalPoivre += getElementText("Poivre (g)" + i);
|
||||
totalPoivreConcasse += getElementText("Poivre concassé (g)" + i);
|
||||
totalPoivreConcasse += getElementText(
|
||||
"Poivre concassé (g)" + i,
|
||||
);
|
||||
totalMuscade += getElementText("Muscade (g)" + i);
|
||||
totalAil += getElementText("Ail (g)" + i);
|
||||
}
|
||||
|
||||
document.getElementById("Total_Net").innerHTML = totalNet.toFixed(3);
|
||||
document.getElementById("Total_Sel").innerHTML = totalSel.toFixed(3);
|
||||
document.getElementById("Total_Net").innerHTML =
|
||||
totalNet.toFixed(3);
|
||||
document.getElementById("Total_Sel").innerHTML =
|
||||
totalSel.toFixed(3);
|
||||
document.getElementById("Total_Poivre").innerHTML =
|
||||
totalPoivre.toFixed(3);
|
||||
document.getElementById("Total_Poivre_Concasse").innerHTML =
|
||||
totalPoivreConcasse.toFixed(3);
|
||||
document.getElementById("Total_Muscade").innerHTML =
|
||||
totalMuscade.toFixed(3);
|
||||
document.getElementById("Total_Ail").innerHTML = totalAil.toFixed(3);
|
||||
document.getElementById("Total_Ail").innerHTML =
|
||||
totalAil.toFixed(3);
|
||||
|
||||
// Calcul du total assaisonné et rendement
|
||||
calculerTotalAssaisonne();
|
||||
@@ -140,18 +149,26 @@
|
||||
const totalNet = getElementText("Total_Net");
|
||||
const totalSel = getElementText("Total_Sel");
|
||||
const totalPoivre = getElementText("Total_Poivre");
|
||||
const totalPoivreConcasse = getElementText("Total_Poivre_Concasse");
|
||||
const totalPoivreConcasse = getElementText(
|
||||
"Total_Poivre_Concasse",
|
||||
);
|
||||
const totalMuscade = getElementText("Total_Muscade");
|
||||
const totalAil = getElementText("Total_Ail");
|
||||
|
||||
const totalAssaisonne =
|
||||
totalNet + totalSel + totalPoivre / 1000 + totalPoivreConcasse / 1000 + totalMuscade / 1000 + totalAil / 1000;
|
||||
totalNet +
|
||||
totalSel +
|
||||
totalPoivre / 1000 +
|
||||
totalPoivreConcasse / 1000 +
|
||||
totalMuscade / 1000 +
|
||||
totalAil / 1000;
|
||||
document.getElementById("Total_Assaisonne").innerHTML =
|
||||
totalAssaisonne.toFixed(3);
|
||||
|
||||
const totalAchete = getElementValue("Total_Achete");
|
||||
if (totalAchete > 0) {
|
||||
const totalNet = document.getElementById("Total_Net").innerHTML;
|
||||
const totalNet =
|
||||
document.getElementById("Total_Net").innerHTML;
|
||||
const rendement = (totalNet / totalAchete) * 100;
|
||||
document.getElementById("Rendement").innerHTML =
|
||||
rendement.toFixed(3) + " %";
|
||||
@@ -164,15 +181,15 @@
|
||||
const formulaire = document.createElement("form");
|
||||
formulaire.setAttribute("class", "form-grid");
|
||||
|
||||
/*test*/
|
||||
// ---- Début Intégration LocalStorage ----
|
||||
const STORAGE_KEY = 'calculateurEpices';
|
||||
const STORAGE_KEY = "calculateurEpices";
|
||||
const MAX_AGE = 48 * 60 * 60 * 1000; // 72h
|
||||
|
||||
function sauvegarderFormulaire() {
|
||||
const data = { timestamp: Date.now(), values: {} };
|
||||
document.querySelectorAll('input').forEach(input => {
|
||||
data.values[input.id] = input.type === 'checkbox' ? input.checked : input.value;
|
||||
document.querySelectorAll("input").forEach((input) => {
|
||||
data.values[input.id] =
|
||||
input.type === "checkbox" ? input.checked : input.value;
|
||||
});
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
|
||||
}
|
||||
@@ -183,7 +200,8 @@
|
||||
for (const [id, value] of Object.entries(saved.values)) {
|
||||
const input = document.getElementById(id);
|
||||
if (input) {
|
||||
if (input.type === 'checkbox') input.checked = value;
|
||||
if (input.type === "checkbox")
|
||||
input.checked = value;
|
||||
else input.value = value;
|
||||
}
|
||||
}
|
||||
@@ -192,13 +210,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
restaurerFormulaire();
|
||||
recalculerToutesLignes();
|
||||
});
|
||||
|
||||
document.body.addEventListener('input', sauvegarderFormulaire);
|
||||
document.body.addEventListener('change', sauvegarderFormulaire);
|
||||
document.body.addEventListener("input", sauvegarderFormulaire);
|
||||
document.body.addEventListener("change", sauvegarderFormulaire);
|
||||
// Table des proportions et du poids de la planche
|
||||
const proportionTable = document.createElement("table");
|
||||
proportionTable.setAttribute("id", "TableauProportions");
|
||||
@@ -247,7 +265,7 @@
|
||||
{
|
||||
label: "Proportion d'ail (g)",
|
||||
id: "Prop_ail",
|
||||
defaultValue: 2
|
||||
defaultValue: 2,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -276,7 +294,7 @@
|
||||
});
|
||||
|
||||
const boutonDiv = document.createElement("div");
|
||||
boutonDiv.setAttribute("id", "button-wrapper")
|
||||
boutonDiv.setAttribute("id", "button-wrapper");
|
||||
boutonDiv.style.display = "inline-block";
|
||||
boutonDiv.style.verticalAlign = "top";
|
||||
boutonDiv.style.marginLeft = "20px"; // espace entre le tableau et le bouton
|
||||
@@ -286,7 +304,7 @@
|
||||
boutonAction.textContent = "Imprimer la page";
|
||||
boutonAction.type = "button";
|
||||
boutonAction.onclick = () => {
|
||||
window.print()
|
||||
window.print();
|
||||
alert("Page imprimée !");
|
||||
};
|
||||
|
||||
@@ -420,13 +438,15 @@
|
||||
|
||||
// Première ligne : titres
|
||||
const rendementHeaderRow = document.createElement("tr");
|
||||
["Total acheté", "Total assaisonné", "Rendement"].forEach(titre => {
|
||||
["Total acheté", "Total assaisonné", "Rendement"].forEach(
|
||||
(titre) => {
|
||||
const cell = document.createElement("td");
|
||||
cell.setAttribute("class", "tdRendement");
|
||||
const cellText = document.createTextNode(titre);
|
||||
cell.appendChild(cellText);
|
||||
rendementHeaderRow.appendChild(cell);
|
||||
});
|
||||
},
|
||||
);
|
||||
rendementBody.appendChild(rendementHeaderRow);
|
||||
|
||||
// Deuxième ligne : contenu
|
||||
@@ -469,6 +489,5 @@
|
||||
formulaire.appendChild(tabRendDiv);
|
||||
body.appendChild(formulaire);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user