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"; echo "</div>\n\n";
// results table // results table
echo "<div class=\"results\">\n"; echo "<div class=\"mb-5\">\n";
if (!empty($components['records'])) { if (!empty($components['records'])) {
echo "\t<table>\n"; echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<tr>\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers // table headers
foreach (array_keys($components['records'][0]) as $header) { 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 //table rows
foreach ($components['records'] as $row) { foreach ($components['records'] as $row) {
echo "\t\t<tr>\n"; echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then // sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) { foreach ($row as $key => $column) {
if ($key === 'component ID') { 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') { } 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 { } 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"; echo "\t</table>\n";
} else { } else {

View File

@ -103,22 +103,27 @@ if (isset($participant_id)) {
echo "</div>\n\n"; echo "</div>\n\n";
// results table // results table
echo "<div class=\"results\">\n"; echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) { if (!empty($conferences['records'])) {
echo "\t<table>\n"; echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<tr>\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers // table headers
foreach (array_keys($conferences['records'][0]) as $header) { 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 //table rows
foreach ($conferences['records'] as $row) { foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n"; echo "\t\t\t<tr>\n";
$stats_id = false; $stats_id = false;
$participant_ip = false; $participant_ip = false;
if ($row['event'] === 'stats_id') $stats_id = true; if ($row['event'] === 'stats_id') $stats_id = true;
@ -126,22 +131,23 @@ if (isset($participant_id)) {
// sometimes $column is empty, we make it '' then // sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) { foreach ($row as $key => $column) {
if ($key === 'participant ID' && $column === $participant_id) { 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') { } 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') { } 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') { } 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') { } 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 { } 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"; echo "\t</table>\n";
} else { } else {
@ -201,39 +207,45 @@ if (isset($participant_id)) {
echo "</div>\n\n"; echo "</div>\n\n";
// results table // results table
echo "<div class=\"results\">\n"; echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) { if (!empty($conferences['records'])) {
echo "\t<table>\n"; echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<tr>\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers // table headers
foreach (array_keys($conferences['records'][0]) as $header) { 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 //table rows
foreach ($conferences['records'] as $row) { foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n"; echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then // sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) { foreach ($row as $key => $column) {
if ($key === 'parameter' && $column === $participant_name) { 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') { } 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') { } 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') { } 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 { } 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"; echo "\t</table>\n";
} else { } else {
@ -293,39 +305,45 @@ if (isset($participant_id)) {
echo "</div>\n\n"; echo "</div>\n\n";
// results table // results table
echo "<div class=\"results\">\n"; echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) { if (!empty($conferences['records'])) {
echo "\t<table>\n"; echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<tr>\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers // table headers
foreach (array_keys($conferences['records'][0]) as $header) { 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 //table rows
foreach ($conferences['records'] as $row) { foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n"; echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then // sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) { foreach ($row as $key => $column) {
if ($key === 'parameter' && $column === $participant_ip) { 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') { } 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') { } 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') { } 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 { } 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"; echo "\t</table>\n";
} else { } else {
@ -379,35 +397,41 @@ if (isset($participant_id)) {
echo "</div>\n\n"; echo "</div>\n\n";
// results table // results table
echo "<div class=\"results\">\n"; echo "<div class=\"mb-5\">\n";
if (!empty($participants['records'])) { if (!empty($participants['records'])) {
echo "\t<table>\n"; echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<tr>\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers // table headers
foreach (array_keys($participants['records'][0]) as $header) { 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 //table rows
foreach ($participants['records'] as $row) { foreach ($participants['records'] as $row) {
echo "\t\t<tr>\n"; echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then // sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) { foreach ($row as $key => $column) {
if ($key === 'participant ID') { 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') { } 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 { } 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"; echo "\t</table>\n";
} else { } else {

View File

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

File diff suppressed because one or more lines are too long