From 4b495557cdd6666d7c8ab29a06cc2b46794767ed Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 25 Jun 2021 21:15:54 +0200 Subject: [PATCH] Tracker: sort numbers and fractions numerically --- WebHostLib/static/assets/tracker.js | 28 ++++++++++++++++++++++++---- WebHostLib/templates/tracker.html | 6 +++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/WebHostLib/static/assets/tracker.js b/WebHostLib/static/assets/tracker.js index 9fa57310..c4b59958 100644 --- a/WebHostLib/static/assets/tracker.js +++ b/WebHostLib/static/assets/tracker.js @@ -23,20 +23,40 @@ window.addEventListener('load', () => { render: function (data, type, row) { if (type === "sort" || type === 'type') { if (data === "None") - return -1 + return -1; return parseInt(data); } if (data === "None") - return data + return data; - var hours = Math.floor(data / 3600); - var minutes = Math.floor((data - (hours * 3600)) / 60); + let hours = Math.floor(data / 3600); + let minutes = Math.floor((data - (hours * 3600)) / 60); if (minutes < 10) {minutes = "0"+minutes;} return hours+':'+minutes; } }, + { + targets: 'number', + render: function (data, type, row) { + if (type === "sort" || type === 'type') { + return parseFloat(data); + } + return data; + } + }, + { + targets: 'fraction', + render: function (data, type, row) { + let splitted = data.split("/", 1); + let current = splitted[0] + if (type === "sort" || type === 'type') { + return parseInt(current); + } + return data; + } + }, ], // DO NOT use the scrollX or scrollY options. They cause DataTables to split the thead from diff --git a/WebHostLib/templates/tracker.html b/WebHostLib/templates/tracker.html index 1b710ae8..40faddfc 100644 --- a/WebHostLib/templates/tracker.html +++ b/WebHostLib/templates/tracker.html @@ -102,16 +102,16 @@ {% for area in ordered_areas %} - + Checks {% if area in key_locations %} - + Small Key {% endif %} {% if area in big_key_locations %} - + Big Key {%- endif -%}