Fix PHP warnings and change from xhtml to html

This commit is contained in:
2025-09-17 15:29:36 +02:00
parent fc93e5097b
commit 31177bc3fc
3 changed files with 28 additions and 18 deletions

View File

@@ -5,16 +5,18 @@ global $COMBINED_ACCESS;
$info = explode('/', $_SERVER['PATH_INFO']);
$client = null;
foreach ($CLIENT_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
if (sizeof($info) > 1) {
foreach ($CLIENT_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
}
}
}
foreach ($COMBINED_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
foreach ($COMBINED_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
}
}
}
if ($client === null) {
@@ -27,7 +29,7 @@ if ($client === null) {
exit();
}
if ($client['api']) {
if (isset($client['api'])) {
$data = "window.ELWIG_API = \"$client[api]\";";
} else {
$data = "window.CLIENTS = {";
@@ -41,18 +43,17 @@ if ($client['api']) {
$data .= "};";
}
header('Content-Type: application/xhtml+xml; charset=UTF-8');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="de">
header('Content-Type: text/html; charset=UTF-8'); ?>
<html lang="de">
<head>
<meta charset="UTF-8"/>
<title><?php echo $client['name']; ?> - Elwig</title>
<link rel="icon" href="/favicon.ico" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256"/>
<link rel="stylesheet" href="/res/style.css"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<script>window.CLIENT = "<?php echo $info[1]; ?>"; <?php echo $data; ?></script>
<script src="/res/access.js" type="application/javascript"/>
<script src="<?php echo $client['api'] ? "/res/access-single.js" : "/res/access-multiple.js"; ?>" type="application/javascript"/>
<script>window.CLIENT = "<?php echo $info[1] ?? ""; ?>"; <?php echo $data; ?></script>
<script src="/res/access.js" type="application/javascript"></script>
<script src="<?php echo isset($client['api']) ? "/res/access-single.js" : "/res/access-multiple.js"; ?>" type="application/javascript"></script>
</head>
<body class="header-footer">
<header>
@@ -83,7 +84,7 @@ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
</div>
</nav>
</header>
<main id="access"/>
<main id="access"></main>
<footer>
<a href="https://elwig.at/"><img src="/res/elwig.png" alt="Elwig"/></a>
<p>

View File

@@ -51,6 +51,7 @@ async function init() {
async function updateOverview(client) {
const [schedules] = await Promise.all([getDeliverySchedules(client, [`year=${getCurrentLastSeason()}`])]);
let todayElement = null;
const rows = [];
const days = groupBy(schedules['data'], 'date');
const now = new Date();
@@ -58,8 +59,10 @@ async function updateOverview(client) {
const date = new Date(dateString);
const row = document.createElement('div');
row.className = 'day';
if (now.getFullYear() === date.getFullYear() && now.getMonth() === date.getMonth() && now.getDate() === date.getDate())
if (now.getFullYear() === date.getFullYear() && now.getMonth() === date.getMonth() && now.getDate() === date.getDate()) {
row.classList.add('today');
todayElement = row;
}
row.innerHTML = `<div><span style="font-size: 0.75em; display: block">${fmtDateWeekday(date)}</span>${fmtDate(date)}</div>`;
const container = document.createElement('div');
container.className = 'schedule-container';
@@ -94,7 +97,9 @@ async function updateOverview(client) {
}
const main = document.getElementsByTagName('main')[0];
const numChildren = main.childElementCount;
main.replaceChildren(main.firstElementChild, ...rows);
if (todayElement && numChildren <= 1) todayElement.scrollIntoView({block: "center"});
}
function render() {

View File

@@ -138,6 +138,10 @@ footer a {
footer > *:not(:first-child) {
width: 300px;
}
body.header-footer {
min-height: calc(100vh + 21em);
padding-bottom: 21em;
}
}
p a,