diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-11-20 19:47:08 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-11-21 12:48:15 +0100 |
commit | a1fe768c6d40c7c885db1c9843c61527cbe583e3 (patch) | |
tree | c397e7d6796049607d6348c538621d1e8809a847 /views/stats.pug | |
parent | d1318d147297161691f5048e1f2cb4e516159144 (diff) | |
download | server-a1fe768c6d40c7c885db1c9843c61527cbe583e3.tar.gz |
Rewrite view templates to use Pug engine.
Diffstat (limited to 'views/stats.pug')
-rw-r--r-- | views/stats.pug | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/views/stats.pug b/views/stats.pug new file mode 100644 index 0000000..7634048 --- /dev/null +++ b/views/stats.pug @@ -0,0 +1,45 @@ +//- vim:ts=4:sw=4: +doctype html +html + head + include head + title Game Statistics + style. + table { table-layout: fixed; min-width: auto; } + td:nth-child(1) { width: 240px; } + td { width: 100px; } + tr.blank { height: 2rem; border: none; } + body + include header + article + h1 Game Statistics + table + - + function total(t,s) { + return stats + .filter(entry => entry.title_id === t && entry.scenario === s) + .reduce((acc, entry) => acc + entry.count, 0); + } + function result(t,s,r) { + let info = stats.find(entry => entry.title_id === t && entry.scenario === s && entry.result === r); + return info ? info.count : 0; + } + each title_name, title_id in title_name_map + unless title_name_map[title_id].hidden + - let scenarios = title_rule_map[title_id].scenarios; + - let roles = title_role_map[title_id].concat(["Draw"]); + tr + th= title_name_map[title_id].title_name + each role in roles + th= role + each scenario in scenarios + - let t = total(title_id, scenario); + tr + td #{scenario} (#{t}) + each role in roles + if t > 0 + -let r = result(title_id, scenario, role); + td= Math.round(r * 100 / t) + "%" + else + td - + tr.blank |