Mark current time on the schedule

Add a grey background on cells matching the current time, to make
it clearer where we are in the day.

Change-Id: Id2d13ae59f63c7059bba8abdf762b25e6339720e
This commit is contained in:
Thierry Carrez 2020-09-14 14:27:59 +02:00
parent 673d5375cd
commit fc5a649df2
2 changed files with 15 additions and 2 deletions

View File

@ -112,7 +112,7 @@
<table class="table table-condensed">
<thead><tr><th></th>
{{#each times as |time|}}
<th>{{ displaytime time }}</th>
<th {{ activetime time }}>{{ displaytime time }}</th>
{{/each}}
</tr></thead>
{{#each @root.schedule as |sched room|}}
@ -121,7 +121,7 @@
<span class="glyphicon glyphicon-{{sched.cap_icon}}"
title="{{sched.cap_desc}}"></span>{{/if}}</td>
{{#each (lookup @root.slots day) as |time|}}
<td>{{ roomcode @root.urls @root.schedule room time.name 0 }}</td>
<td {{ activetime time }}">{{ roomcode @root.urls @root.schedule room time.name 0 }}</td>
{{/each}}
</tr>
{{/if}}

View File

@ -120,6 +120,19 @@ Handlebars.registerHelper('displaytime',
return new Handlebars.SafeString(content);
});
// Grey out cell if current time matches the slot hour
Handlebars.registerHelper('activetime',
function(time) {
if (time['realtime'] != undefined) {
var t = new Date(time['realtime']);
var now = new Date();
var diff = now.getTime() - t.getTime();
if (diff > 0 && diff < (1000*60*60)) {
return new Handlebars.SafeString('style="background-color: #eeeeee"');
}
}
return new Handlebars.SafeString('');
});
// What is the day today ?
// Return Monday until Tuesday 1 UTC