Fix PHP warnings and change from xhtml to html
This commit is contained in:
@@ -5,6 +5,7 @@ global $COMBINED_ACCESS;
|
|||||||
|
|
||||||
$info = explode('/', $_SERVER['PATH_INFO']);
|
$info = explode('/', $_SERVER['PATH_INFO']);
|
||||||
$client = null;
|
$client = null;
|
||||||
|
if (sizeof($info) > 1) {
|
||||||
foreach ($CLIENT_ACCESS as $name => $data) {
|
foreach ($CLIENT_ACCESS as $name => $data) {
|
||||||
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
|
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
|
||||||
$client = $data;
|
$client = $data;
|
||||||
@@ -17,6 +18,7 @@ foreach ($COMBINED_ACCESS as $name => $data) {
|
|||||||
$client['id'] = $name;
|
$client['id'] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($client === null) {
|
if ($client === null) {
|
||||||
header('Status: 200');
|
header('Status: 200');
|
||||||
header('Content-Length: 0');
|
header('Content-Length: 0');
|
||||||
@@ -27,7 +29,7 @@ if ($client === null) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($client['api']) {
|
if (isset($client['api'])) {
|
||||||
$data = "window.ELWIG_API = \"$client[api]\";";
|
$data = "window.ELWIG_API = \"$client[api]\";";
|
||||||
} else {
|
} else {
|
||||||
$data = "window.CLIENTS = {";
|
$data = "window.CLIENTS = {";
|
||||||
@@ -41,18 +43,17 @@ if ($client['api']) {
|
|||||||
$data .= "};";
|
$data .= "};";
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/xhtml+xml; charset=UTF-8');
|
header('Content-Type: text/html; charset=UTF-8'); ?>
|
||||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
|
<html lang="de">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="de">
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<title><?php echo $client['name']; ?> - Elwig</title>
|
<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="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"/>
|
<link rel="stylesheet" href="/res/style.css"/>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
||||||
<script>window.CLIENT = "<?php echo $info[1]; ?>"; <?php echo $data; ?></script>
|
<script>window.CLIENT = "<?php echo $info[1] ?? ""; ?>"; <?php echo $data; ?></script>
|
||||||
<script src="/res/access.js" type="application/javascript"/>
|
<script src="/res/access.js" type="application/javascript"></script>
|
||||||
<script src="<?php echo $client['api'] ? "/res/access-single.js" : "/res/access-multiple.js"; ?>" type="application/javascript"/>
|
<script src="<?php echo isset($client['api']) ? "/res/access-single.js" : "/res/access-multiple.js"; ?>" type="application/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="header-footer">
|
<body class="header-footer">
|
||||||
<header>
|
<header>
|
||||||
@@ -83,7 +84,7 @@ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main id="access"/>
|
<main id="access"></main>
|
||||||
<footer>
|
<footer>
|
||||||
<a href="https://elwig.at/"><img src="/res/elwig.png" alt="Elwig"/></a>
|
<a href="https://elwig.at/"><img src="/res/elwig.png" alt="Elwig"/></a>
|
||||||
<p>
|
<p>
|
||||||
|
@@ -51,6 +51,7 @@ async function init() {
|
|||||||
|
|
||||||
async function updateOverview(client) {
|
async function updateOverview(client) {
|
||||||
const [schedules] = await Promise.all([getDeliverySchedules(client, [`year=${getCurrentLastSeason()}`])]);
|
const [schedules] = await Promise.all([getDeliverySchedules(client, [`year=${getCurrentLastSeason()}`])]);
|
||||||
|
let todayElement = null;
|
||||||
const rows = [];
|
const rows = [];
|
||||||
const days = groupBy(schedules['data'], 'date');
|
const days = groupBy(schedules['data'], 'date');
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -58,8 +59,10 @@ async function updateOverview(client) {
|
|||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
const row = document.createElement('div');
|
const row = document.createElement('div');
|
||||||
row.className = 'day';
|
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');
|
row.classList.add('today');
|
||||||
|
todayElement = row;
|
||||||
|
}
|
||||||
row.innerHTML = `<div><span style="font-size: 0.75em; display: block">${fmtDateWeekday(date)}</span>${fmtDate(date)}</div>`;
|
row.innerHTML = `<div><span style="font-size: 0.75em; display: block">${fmtDateWeekday(date)}</span>${fmtDate(date)}</div>`;
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
container.className = 'schedule-container';
|
container.className = 'schedule-container';
|
||||||
@@ -94,7 +97,9 @@ async function updateOverview(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const main = document.getElementsByTagName('main')[0];
|
const main = document.getElementsByTagName('main')[0];
|
||||||
|
const numChildren = main.childElementCount;
|
||||||
main.replaceChildren(main.firstElementChild, ...rows);
|
main.replaceChildren(main.firstElementChild, ...rows);
|
||||||
|
if (todayElement && numChildren <= 1) todayElement.scrollIntoView({block: "center"});
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
|
@@ -138,6 +138,10 @@ footer a {
|
|||||||
footer > *:not(:first-child) {
|
footer > *:not(:first-child) {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
body.header-footer {
|
||||||
|
min-height: calc(100vh + 21em);
|
||||||
|
padding-bottom: 21em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p a,
|
p a,
|
||||||
|
Reference in New Issue
Block a user