From b29e7396e952128a6feb4ad0e1d830fe3af43e64 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 4 Oct 2019 18:18:23 +0200 Subject: Add times to movie boxes. --- public/js/app.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 821b0c1..9608aaa 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -67,6 +67,10 @@ window.addEventListener("load", function() { return [ f.format(hour), f.format(min) ].join(':') } + function time_f(t) { + _sec_to_time(_time_to_sec(t)) + } + function break_text(c, text, x, y, width) { let len = c.measureText(text).width if (len < width) { @@ -134,8 +138,10 @@ window.addEventListener("load", function() { c.strokeStyle = '#cfc' for (let s of screenings) { - let ystart = Math.ceil((_time_to_sec(s.start_time) - start_time) / 30) + margin; - let height = Math.ceil((_time_to_sec(_end_time(s)) - start_time ) / 30) + margin - ystart; + let stt = _time_to_sec(s.start_time) + let ett = _time_to_sec(_end_time(s)) + let ystart = Math.ceil((stt - start_time) / 30) + margin; + let height = Math.ceil((ett - start_time ) / 30) + margin - ystart; let ri = s.room.id - 1 let xstart = xmargin + ri * 150 @@ -143,9 +149,12 @@ window.addEventListener("load", function() { c.fillRect(xstart, ystart, 100, height) c.strokeRect(xstart, ystart, 100, height) - c.font = '12px sans-serif' c.fillStyle = '#000' - break_text(c, s.film.title, xstart + 5, ystart + 15, 90) + c.font = '10px sans-serif' + c.fillText(_sec_to_time(stt) + " - " + _sec_to_time(ett), xstart + 5, ystart + 10) + + c.font = '12px sans-serif' + break_text(c, s.film.title, xstart + 5, ystart + 25, 90) } } -- cgit v1.2.3