Commit fac52cfe authored by Simon Welsh's avatar Simon Welsh

List of available days now uses calendar tables instead of a list

git-svn-id: svn+ssh://lsgn/var/logbot-www@33 5f99df0c-6b0a-442a-b40a-040688e84a9d
parent 9e63698f
......@@ -181,3 +181,53 @@ function linkify($string) {
return '<a href="' . $url . '" rel="nofollow" target="_blank">' . "$input</a>$right";
}, $string);
}
// $start is day of week to start on, $count is number of days
function calendar($start, $count, $links, $thisMonth = false) {
$html = '<table class="cal" cellspacing=0>';
$html .= '<thead><tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></thead>';
$html .= '<tbody><tr>';
$i = 0;
$start = $start % 7;
while($i < $start) {
$evenodd = $i % 2 ? 'odd' : 'even';
$html .= "<td class='$evenodd'></td>";
++$i;
}
if($thisMonth) {
$bold = date('j');
} else {
$bold = 0;
}
$day = 1;
while($day <= $count) {
$evenodd = $i % 2 ? 'odd' : 'even';
if(isset($links[$day])) {
if($bold == $day) {
$content = "<a href='index.php?date={$links[$day][1]}'><b>$day</b></a>";
} else {
$content = "<a href='index.php?date={$links[$day][1]}'>$day</a>";
}
} else {
if($bold == $day) {
$content = "<b>$day</b>";
} else {
$content = $day;
}
}
$html .= "<td class='$evenodd'>$content</td>";
if($i % 7 == 6 && $day < $count) {
$html .= '</tr><tr>';
}
++$day;
++$i;
}
while($i % 7) {
$evenodd = $i % 2 ? 'odd' : 'even';
$html .= "<td class='$evenodd'></td>";
++$i;
}
$html .= '</tr></tbody></table>';
return $html;
}
......@@ -21,7 +21,7 @@ body {
width: 100%;
}
form, p, h1, h2, h3, h4 {
form, p, h1, h2, h3 {
padding: 0 10px;
}
......@@ -52,7 +52,29 @@ table td {
max-height: 100%;
}
:target {
table.cal {
border-collapse: collapse;
}
table.cal td {
text-align: right;
color: #777;
border: 1px solid #666;
}
table.cal a {
text-decoration: none;
}
table.cal td.odd {
background-color: #ccc;
}
table.cal th {
}
.logs :target {
background: gold;
}
......@@ -64,6 +86,17 @@ h1 a, h2 a, h3 a, h4 a {
color: black;
}
div.month {
float: left;
width: 250px;
height: 170px;
margin-left: 10px;
}
.clear {
clear: both;
}
</style>
</head>
......
......@@ -50,6 +50,8 @@ NoLog:
$body .= '</p>';
}
$thisMonth = mktime(0, 0, 0, date('n'), 1, date('Y'));
foreach($dates as $year => $months) {
$body .= "<h3><a name='$year'>$year</a></h3><div class='year'>";
if(count($months) > 1) {
......@@ -60,13 +62,13 @@ NoLog:
$body .= '</p>';
}
foreach($months as $month => $days) {
$body .= "<h4><a name='{$year}_$month'>$month</a></h4><div class='month'><ul>";
foreach($days as $day) {
$body .= "<li><a href='index.php?date=$day[1]'>$day[0] $month $year</a></li>";
}
$body .= '</ul></div>';
$body .= "<div class='month'><h4><a name='{$year}_$month'>$month</a></h4>";
$stamp = strtotime($days[array_keys($days)[0]][1]);
$stamp = mktime(0, 0, 0, date('n', $stamp), 1, date('Y', $stamp));
$body .= calendar(date('w', $stamp), date('t', $stamp), $days, $stamp == $thisMonth);
$body .= '</div>';
}
$body .= '</div>';
$body .= '<div class="clear"><!-- --></div></div>';
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment