Cleaning up HTML

main
Yasen Pramatarov 2024-07-25 12:15:53 +03:00
parent 462e7a45b8
commit 6400854316
4 changed files with 109 additions and 78 deletions

View File

@ -103,35 +103,41 @@ try {
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($components['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($components['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope=\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($components['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'component ID') {
echo "\t\t\t<td><a href=\"$app_root?page=components&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=components&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'component') {
echo "\t\t\t<td><a href=\"$app_root?page=components&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=components&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {

View File

@ -103,22 +103,27 @@ if (isset($participant_id)) {
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope=\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
$stats_id = false;
$participant_ip = false;
if ($row['event'] === 'stats_id') $stats_id = true;
@ -126,22 +131,23 @@ if (isset($participant_id)) {
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'participant ID' && $column === $participant_id) {
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
echo "\t\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
} elseif ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'conference name') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($stats_id && $key === 'parameter') {
echo "\t\t\t<td><a href=\"$app_root?page=participants&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=participants&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($participant_ip && $key === 'parameter') {
echo "\t\t\t<td><a href=\"$app_root?page=participants&ip=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=participants&ip=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {
@ -201,39 +207,45 @@ if (isset($participant_id)) {
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope-\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'parameter' && $column === $participant_name) {
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
echo "\t\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
} elseif ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'conference name') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'participant ID') {
echo "\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {
@ -293,39 +305,45 @@ if (isset($participant_id)) {
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope=\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'parameter' && $column === $participant_ip) {
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
echo "\t\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
} elseif ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'conference name') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'participant ID') {
echo "\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {
@ -379,35 +397,41 @@ if (isset($participant_id)) {
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($participants['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($participants['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($participants['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'participant ID') {
echo "\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=participants&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {

View File

@ -78,28 +78,28 @@
color: white;
}
.results {
margin-bottom: 50px;
}
//.results {
// margin-bottom: 50px;
//}
.results table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
.results table, th, td {
border: 1px solid #ddd;
}
.results th, td {
padding: 8px;
text-align: left;
}
.results th {
background-color: #f2f2f2;
}
.results p {
text-align: center;
}
//.results table {
// width: 100%;
// border-collapse: collapse;
// margin: 20px 0;
//}
//.results table, th, td {
// border: 1px solid #ddd;
//}
//.results th, td {
// padding: 8px;
// text-align: left;
//}
//.results th {
// background-color: #f2f2f2;
//}
//.results p {
// text-align: center;
//}
.results-header {

File diff suppressed because one or more lines are too long