This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhouseBans.html
82 lines (66 loc) · 3.1 KB
/
houseBans.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!doctype html>
<html lang="de">
<head>
<title>House Bans | UCA</title>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=chrome">
<link rel="shortcut icon" href="common/img/UCLogo_new.png" type="image/x-icon">
<link rel="stylesheet" href="common/css/master.css">
<link rel="stylesheet" href="common/css/font.css">
<script src="common/js/master.js" async></script>
</head>
<body>
<nav id="nav"></nav>
<video autoplay muted loop id="backgroundVideo">
<source src="common/img/UnicacityAddonWebsiteBackground.mp4" type="video/mp4">
</video>
<div class="housebans">
<p class="text-50-700">House Bans</p>
<div id="content"></div>
</div>
<div id="footer"></div>
</body>
</html>
<script>
async function fetchAndDisplayContent() {
try {
const response = await fetch('https://rettichlp.de:8443/unicacityaddon/v1/dhgpsklnag2354668ec1d905xcv34d9bdee4b877/houseban?advanced=false');
const json = await response.json();
let count = 0;
const contentElement = document.getElementById("content");
json.forEach(entry => {
const name = entry.name;
const startTime = entry.startTime;
const expirationTime = entry.expirationTime;
const color = count++ % 2 === 1 ? "rgba(0, 0, 0, 0.5)" : "";
let reasons = "<ul>";
entry.houseBanReasonList.forEach(subEntry => reasons += "<li>" + subEntry.reason.replace("-", " ") + "</li>");
reasons += "</ul>";
const housebanFlexBar = document.createElement('div');
housebanFlexBar.className = 'housebans-flexBar';
housebanFlexBar.style.backgroundColor = color;
housebanFlexBar.style.padding = '0 10px';
const nameElement = document.createElement('div');
nameElement.classList.add('text-20-300');
nameElement.classList.add('housebans-flexBar-name');
nameElement.textContent = name;
const reasonElement = document.createElement('div');
reasonElement.classList.add('text-20-300');
reasonElement.classList.add('housebans-flexBar-reason');
reasonElement.innerHTML = reasons;
const dateElement = document.createElement('div');
dateElement.classList.add('text-20-300');
dateElement.classList.add('housebans-flexBar-date');
dateElement.textContent = new Date(startTime).toLocaleDateString() + " - " + new Date(expirationTime).toLocaleDateString();
housebanFlexBar.appendChild(nameElement);
housebanFlexBar.appendChild(reasonElement);
housebanFlexBar.appendChild(dateElement);
contentElement.appendChild(housebanFlexBar);
});
} catch (error) {
console.error('Cannot fetch data:', error);
}
}
</script>