code reduction

This commit is contained in:
HB9HIL
2024-05-09 20:20:54 +02:00
parent ab8a08b246
commit 0b0eccb835

View File

@@ -4,68 +4,59 @@
<p>This data is from <a target="_blank" href="https://www.contestcalendar.com/">https://www.contestcalendar.com/</a></p>
<?php
function generateTableRows($contests, $custom_date_format) {
foreach ($contests as $contest) {
echo '<tr>';
echo "<td>{$contest['title']}</td>";
echo "<td>{$contest['start']->format($custom_date_format)}</td>";
echo "<td>{$contest['start']->format('H:i')}</td>";
echo "<td>{$contest['end']->format($custom_date_format.' H:i')}</td>";
echo "<td><a class='btn btn-secondary btn-sm' href='{$contest['link']}' target='_blank'>Show Details</a></td>";
echo '</tr>';
}
}
?>
<div class="row">
<div class="col">
<h4 class="mb-3">Today</h4>
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
<thead>
function generateTableRows($contests, $custom_date_format) { ?>
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
<thead>
<tr>
<th>Contest</th>
<th>Start</th>
<th>End</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<?php foreach ($contests as $contest) { ?>
<tr>
<th>Contest</th>
<th>Date</th>
<th>Start</th>
<th>End</th>
<th>Link</th>
<td><b><?php echo $contest['title']; ?></b></td>
<td><?php echo $contest['start']->format('d M - H:i'); ?></td>
<td><?php echo $contest['end']->format('d M - H:i'); ?></td>
<td><a class='btn btn-secondary btn-sm' href='<?php echo $contest['link']; ?>' target='_blank'>Show Details</a></td>
</tr>
</thead>
<tbody>
<?php } ?>
</tbody>
</table>
<?php } ?>
<div class="row mb-3">
<div class="col">
<div class="card">
<div class="card-header">
<h4>Today</h4>
</div>
<div class="card-body">
<?php generateTableRows($contestsToday, $custom_date_format); ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<h4 class="mb-3">Weekend</h4>
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
<thead>
<tr>
<th>Contest</th>
<th>Date</th>
<th>Start</th>
<th>End</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<div class="card">
<div class="card-header">
<h4>Weekend</h4>
</div>
<div class="card-body">
<?php generateTableRows($contestsNextWeekend, $custom_date_format); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="border-1">
<div class="card">
<div class="card-header">
<h4>Next Week</h4>
</div>
<div class="card-body">
<?php generateTableRows($contestsNextWeek, $custom_date_format); ?>
</div>
</div>
</div>
<h4 class="mb-3">Next Week</h4>
<table style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed">
<thead>
<tr>
<th>Contest</th>
<th>Date</th>
<th>Start</th>
<th>End</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<?php generateTableRows($contestsNextWeek, $custom_date_format); ?>
</tbody>
</table>
</div>