most of the initial structure and content

This commit is contained in:
kleines Filmröllchen 2024-11-18 16:10:28 +01:00
parent a486b7bbb7
commit d7b50372a8
Signed by: filmroellchen
SSH key fingerprint: SHA256:NarU6J/XgCfEae4rbei0YIdN2pYaYDccarK6R53dnc8
11 changed files with 517 additions and 83 deletions

View file

@ -1,65 +1,85 @@
/*
Include calendar | Chaostreff Backnang | @paddy
Modernization by @kleinesfilmroellchen
*/
export default function hackcal(e, p = 1) {
// var cal_uri = "https://chaostreff-backnang.de/hackcal/?period=" + p;
var cal_uri = "/hackcal";
var uri_regex =
/(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/\-_\.\:]*(\?\S+)?)?)?)/gi;
if (!document.getElementById("dbkcalendar")) return;
fetch(cal_uri)
const calendar = document.getElementById("calendar").content.cloneNode(true);
const calendarDate = document.getElementById("calendar-date");
const calendarEntry = document.getElementById("calendar-entry");
const calendarParent = document.getElementById("dbkcalendar");
const body = calendar.querySelector("tbody");
// const cal_uri = "https://chaostreff-backnang.de/hackcal/?period=" + p;
const calUri = "/hackcal";
fetch(calUri)
.then((res) => res.json())
.then((data) => {
var items = [];
const items = [];
Object.keys(data).forEach(function (date) {
var day = new Date(date);
items.push(
"<tr class='' data-date='" +
date +
"'><span>" +
day.toLocaleDateString(true, {
weekday: "short",
day: "numeric",
month: "long",
year: "numeric",
}) +
"</span></tr>"
);
const day = new Date(date);
const dateItem = calendarDate.content.cloneNode(true);
const timeElement = dateItem.querySelector("time");
timeElement.innerText = day.toLocaleDateString(true, {
weekday: "short",
day: "numeric",
month: "long",
year: "numeric",
});
timeElement.dateTime = date;
body.appendChild(dateItem);
Object.keys(data[date]).forEach(function (uid) {
var event = data[date][uid];
var location = event.location
? event.location
.replace(/\n/g, "<br>")
.replace(uri_regex, "<a href='$1' target='_blank'>$1</a>")
: "";
var description = event.description
? event.description
.replace(/\n/g, "<br>")
.replace(uri_regex, (url) => {
event.summary = `<a href='${url}' target='_blank'>${event.summary}</a>`;
return "";
})
: "";
var categories = event.categories
? "<i>" + event.categories.replace(",", "</i> <i>") + "</i>"
: "";
items.push(
"<tr data-uid='" +
uid +
"'><span>" +
event.datestr +
"</span><span><b>" +
event.summary +
"</b> | " +
location +
"<br/>" +
description +
categories +
"</span></tr>"
);
const event = data[date][uid];
const entryItem = calendarEntry.content.cloneNode(true);
entryItem.querySelector(".calendar-entry").dataset.uid = uid;
entryItem.querySelector(".time").innerText = event.datestr;
// use description as link on summary if it's a valid URL
const summaryItem = entryItem.querySelector(".summary");
try {
const descriptionUri = new URL(event.description);
const descriptionLink = document.createElement("a");
descriptionLink.href = descriptionUri;
descriptionLink.target = "_blank";
descriptionLink.innerText = event.summary;
summaryItem.appendChild(descriptionLink);
} catch (e) {
summaryItem.innerText = event.summary;
entryItem.querySelector(".description").innerText =
event.description;
}
// self-link location if it's a valid URL
const locationItem = entryItem.querySelector(".location");
try {
const locationUri = new URL(event.location);
const locationLink = document.createElement("a");
locationLink.href = locationUri;
locationLink.target = "_blank";
locationLink.innerText = event.location;
locationItem.appendChild(locationLink);
} catch (e) {
locationItem.innerText = event.location;
}
const categoriesParent = entryItem.querySelector(".categories");
for (const category of event.categories.split(",")) {
const categoryItem = document.createElement("em");
categoryItem.innerText = category;
categoriesParent.appendChild(categoryItem);
}
body.appendChild(entryItem);
});
});
document.querySelector("#dbkcalendar").innerHTML = items.join("");
calendarParent.innerHTML = "";
calendarParent.appendChild(calendar);
});
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
static/img/unknown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

@ -1,3 +1,5 @@
/* general page styling */
:root {
--main-bg-color: #020404;
--main-text-color: #efe3e3;
@ -42,13 +44,31 @@ code {
img {
display: block;
&.small {
max-height: 10em;
width: auto;
}
}
h1 {
font-weight: 700;
font-size: 1.8rem;
margin-bottom: 0.5em;
color: var(--main-accent-color);
}
h2 {
font-size: 1.5rem;
}
h3 {
font-size: 1.2rem;
}
/* page header */
#space-image {
height: 12vh;
transition:
height 0.2s,
transform 0.2s;
transition: height 0.2s, transform 0.2s;
&:hover {
height: 14vh;
@ -105,9 +125,7 @@ nav {
margin-bottom: 0.4em;
text-transform: uppercase;
text-decoration: underline 0.15em var(--main-text-color);
transition:
text-decoration-color 0.3s,
color 0.25s;
transition: text-decoration-color 0.3s, color 0.25s;
&:focus,
&:hover {
@ -117,6 +135,8 @@ nav {
}
}
/* main grid */
main {
display: grid;
grid-template: ". content ." auto / 1fr minmax(min-content, 45rem) 1fr;
@ -132,12 +152,6 @@ main {
}
}
h1 {
font-weight: 700;
margin-bottom: 0.5em;
color: var(--main-accent-color);
}
footer {
background-color: var(--main-bg-color);
text-align: center;
@ -153,3 +167,50 @@ footer {
);
border-image-slice: 1;
}
/* calendar */
#dbkcalendar {
* {
border-radius: 0.25em;
}
.calendar-date th {
padding: 0.5em 1em;
background: oklch(40% 0 0);
}
td {
padding: 1em;
}
p {
margin: 0;
max-height: min-content;
&.categories {
margin-top: 0.2em;
em {
background-color: var(--main-accent-color);
padding: 0 0.25em;
font-style: normal;
font-weight: bold;
color: var(--main-bg-color);
}
}
}
}
em.summary {
font-style: normal;
font-weight: bold;
}
table {
border-spacing: 0;
border-collapse: collapse;
* {
text-align: left;
vertical-align: top;
}
}

View file

@ -16,10 +16,20 @@ function checkSpace() {
icon.src = data.state.icon.closed;
}
icon.alt = "Der Space ist " + openText;
const lastchangeString = data.state.lastchange
? new Date(data.state.lastchange * 1000).toLocaleString(true, {
timeStyle: "short",
dateStyle: "medium",
})
: "unbekannt";
icon.title = "Letzte Statusänderung: " + lastchangeString;
console.log("Icon: " + icon.src);
})
.catch((error) => {
console.error(error);
icon.src = "/img/unknown.png";
icon.alt = "Der Spacestatus ist unbekannt";
icon.title = "";
console.error("Error on space state retrieval:", error);
});
}