Skip to content

Instantly share code, notes, and snippets.

@MarkyC
Last active December 11, 2015 03:48
Show Gist options
  • Select an option

  • Save MarkyC/4539940 to your computer and use it in GitHub Desktop.

Select an option

Save MarkyC/4539940 to your computer and use it in GitHub Desktop.
<?php
// create empty cells to populate table
// create 1 row for every half hour of the day (48 rows)
$time = mktime(0, 0, 0, 1, 1);
for ($i = 0; $i < 86400; $i += 1800) { // 1800 = half hour, 86400 = one day
echo "<tr ";
if ($i < 25200) {
// initially hide before 7am
echo "class=\"initiallyHiddenTop\" ";
} else if ($i > 79200) {
// initially hide after 10pm
echo "class=\"initiallyHiddenBottom\" ";
} else if ($i == 25200) {
// output show more header (at 7am)
echo "onClick=\"unHideTop()\"><th class=\"show-more\" id=\"show-more-top\" " .
"style=\"text-align:center\" colspan=\"8\">" .
"<i class=\"icon-double-angle-up\"></i> Show More " .
"<i class=\"icon-double-angle-up\"></i></th></tr>";
continue;
} else if ($i == 79200) {
// output show more header (at 10pm)
echo "onClick=\"unHideBottom()\"><th class=\"show-more\" id=\"show-more-bottom\" " .
"style=\"text-align:center\" colspan=\"8\">" .
"<i class=\"icon-double-angle-down\"></i> Show More " .
"<i class=\"icon-double-angle-down\"></i></th></tr>";
continue;
}
printf('><th style="text-align:right">%1$s</th>',
date('g:i a', $time + $i));
for ($j = 0; $j < 7; $j++) {
echo "<td class=\"empty-cell\" onMouseOver=\"showAddClass(this)\"></td>";
}
echo "</tr>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment