home · contact · privacy
To calorie counter, float Consumption.unit_count.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 8 Oct 2023 20:08:08 +0000 (22:08 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 8 Oct 2023 20:08:08 +0000 (22:08 +0200)
calories.py

index 5ab57044eb3bd7333f7764ab62938d071473e72b..23234b2e0924718dfbca7edb3f725ac3e79039c5 100644 (file)
@@ -29,7 +29,7 @@ td, th {
 <tr>
 <input type="hidden" name="keep_visible" value="0">
 <td><select name="eatable_key">{eatables_selection}</select></td>
-<td><input class="unit_count" name="unit_count" type="number" step="1" min="0" value="0" /></td>
+<td><input class="unit_count" name="unit_count" type="number" step="0.1" min="0" value="0" /></td>
 <td></td>
 </tr>
 </table>
@@ -62,7 +62,7 @@ for (let i = 0; i < unit_count_inputs.length; i++) {
     button.innerHTML = '+1';
     button.onclick = function(event) {
         event.preventDefault();
-        input.value = parseInt(input.value) + 1;
+        input.value = parseFloat(input.value) + 1.0;
     };
     input.insertAdjacentElement('afterend', button);
 }
@@ -253,7 +253,7 @@ class MyServer(BaseHTTPRequestHandler):
                 if c.unit_count > 0:
                     db.eatables[c.eatable_key].popularity += 1
             db.consumptions = []
-            default_slots = 7
+            default_slots = 10 
             for k, v in sorted(db.eatables.items(), key=lambda item: -item[1].popularity):
                 db.add_consumption(Consumption(k, 0))
                 default_slots -= 1
@@ -293,7 +293,7 @@ class MyServer(BaseHTTPRequestHandler):
             consumptions += "<tr />"\
                     "<input type=\"hidden\" name=\"keep_visible\" value=\"1\">"\
                     "<td><select name=\"eatable_key\">%s</select></td>"\
-                    "<td><input class=\"unit_count\" name=\"unit_count\" type=\"number\" min=\"0\" value=\"%d\" /></td>"\
+                    "<td><input class=\"unit_count\" name=\"unit_count\" type=\"number\" min=\"0\" step=\"0.1\" value=\"%.1f\" /></td>"\
                     "<td></td>"\
                     "<td>%.1f</td>"\
                     "<td>%.1f</td>"\