From 856b30cf3d1b6d2ab5fc12ff33d7a1aede77f65c Mon Sep 17 00:00:00 2001 From: Mathias Rav Date: Fri, 7 Jun 2019 11:14:46 +0200 Subject: [PATCH] Kasse i KASS: Show absolute time instead of total time since start --- stopwatch/static/stopwatch/stopwatch.es6 | 10 +++++++++- stopwatch/templates/stopwatch/timetrialstopwatch.html | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/stopwatch/static/stopwatch/stopwatch.es6 b/stopwatch/static/stopwatch/stopwatch.es6 index d6d3d83..ccfc42f 100644 --- a/stopwatch/static/stopwatch/stopwatch.es6 +++ b/stopwatch/static/stopwatch/stopwatch.es6 @@ -58,10 +58,18 @@ function update_time() { function lap_element(index, duration, total, difference) { const o = document.createElement('div'); o.className = 'lap'; + let lapTotal = format_timestamp(total, 2); + if (is_kasse_i_kass) { + const time = new Date; + time.setTime(total + start_time); + const timeStr = time + ""; + const match = /(\d+:\d+:\d+)/.exec(timeStr); + lapTotal = match && match[1]; + } let h = ( '
Øl ' + index + '
' + '
' + format_timestamp(duration, 2) + '
' + - '
' + format_timestamp(total, 2) + '
' + '
' + lapTotal + '
' ); if (difference !== null) { const c = (difference <= 0) ? "negdiff" : "posdiff"; diff --git a/stopwatch/templates/stopwatch/timetrialstopwatch.html b/stopwatch/templates/stopwatch/timetrialstopwatch.html index 25f18a7..76c35b3 100644 --- a/stopwatch/templates/stopwatch/timetrialstopwatch.html +++ b/stopwatch/templates/stopwatch/timetrialstopwatch.html @@ -13,6 +13,7 @@ } return null; } +var is_kasse_i_kass = {{ object.is_kasse_i_kass|yesno:"true,false" }}; {% if do_post %} var post_pk = {{ object.pk }}; {% else %}