forked from dcbradley/building-access
-
Notifications
You must be signed in to change notification settings - Fork 0
/
occupancy_list.php
55 lines (49 loc) · 1.37 KB
/
occupancy_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
function showOccupancyList() {
for( $hour=0; $hour < 24; $hour++ ) {
if( $hour < 12 ) {
$hour12 = $hour;
$ampm = "am";
} else {
$hour12 = $hour-12;
if( $hour12==0 ) $hour12 = 12;
$ampm = "pm";
}
echo "<div class='row'>";
$vname = "slot_{$hour}_0";
echo "<div id='{$vname}' class='col-sm' style='display: none'><nobr>{$hour12} {$ampm}</nobr> <span id='{$vname}-summary' class='slot-summary'></span>";
echo "<div class='slotinfo'></div>";
echo "</div>";
echo "</div>\n";
}
# add some whitespace at the bottom to prevent show/hide of elements from jerking around the scroll position on the page
echo "<div style='padding-top: 50vh'/></div>\n";
?>
<script>
function fillOccupancyList(data) {
var slots = JSON.parse(data);
$.each(slots,function (k,v) {
var slot_e = document.getElementById(k);
if( !slot_e ) return;
if( v == "hide" ) {
$(slot_e).hide();
v = "";
} else {
$(slot_e).show();
}
if( k.indexOf("-summary") > -1 ) {
$(slot_e).html(v);
}
else {
$(slot_e).find('.slotinfo').html(v);
if( v ) {
$(slot_e).addClass("used_slot");
} else {
$(slot_e).removeClass("used_slot");
}
}
});
}
</script>
<?php
}