X-Git-Url: https://plomlompom.com/repos/template?a=blobdiff_plain;f=calories.py;h=23234b2e0924718dfbca7edb3f725ac3e79039c5;hb=0e3baa007880c4c6c27899df85f9ff21626f7c36;hp=dc40d5ff9e58cfaabf14ca2c43c6841e42dbd0c4;hpb=a546cea97f153d5f6def4e46309dcb76038d7891;p=misc
diff --git a/calories.py b/calories.py
index dc40d5f..23234b2 100644
--- a/calories.py
+++ b/calories.py
@@ -29,7 +29,7 @@ td, th {
|
- |
+ |
|
@@ -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
@@ -287,12 +287,13 @@ class MyServer(BaseHTTPRequestHandler):
" | "\
"" % (k, v.title, v.cals, v.sugar_g, v.standard_g, v.comments, k)
consumptions = ""
+ db.consumptions = sorted(db.consumptions, key=lambda x: db.eatables[x.eatable_key].title)
for c in db.consumptions:
r = db.calc_consumption(c)
consumptions += "
"\
""\
" | "\
- " | "\
+ " | "\
" | "\
"%.1f | "\
"%.1f | "\