mirror of
https://github.com/TheErrorExe/blockattack
synced 2025-09-05 21:11:00 +02:00
Create ankündigungen-debug.html
This commit is contained in:
parent
a59f078286
commit
ea1e523739
143
ankündigungen-debug.html
Normal file
143
ankündigungen-debug.html
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Ankündigungen - Blockattack</title>
|
||||||
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
|
<script src="/static/js/script.js" defer></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
background-color: #0a0b1e;
|
||||||
|
color: #fff;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
header, footer {
|
||||||
|
background: #1d1d2b;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
header h1 {
|
||||||
|
color: #00d8ff;
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement {
|
||||||
|
margin: 20px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement h2 {
|
||||||
|
color: #00d8ff;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement .meta {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #aaa;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement .content img {
|
||||||
|
max-width: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement a {
|
||||||
|
color: #00d8ff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.announcement a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>Blockattack - Ankündigungen</h1>
|
||||||
|
</header>
|
||||||
|
<main id="announcements">
|
||||||
|
<p>Lade Ankündigungen...</p>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>© 2025 Blockattack. Alle Rechte vorbehalten.</p>
|
||||||
|
</footer>
|
||||||
|
<script>
|
||||||
|
// API URL
|
||||||
|
const apiUrl = 'https://api.errexe.xyz/blockattack-api/v1/an/';
|
||||||
|
|
||||||
|
// Hilfsfunktion für Zeilenumbrüche
|
||||||
|
function formatContent(content) {
|
||||||
|
return content
|
||||||
|
.replace(/<!enter>/g, '<br>')
|
||||||
|
.replace(/<!img="([^"]+)"\?festegrösse=true>/g, '<img src="$1" style="max-width:300px;max-height:300px;">')
|
||||||
|
.replace(/<!img64=([^?]+)\?festegrösse=true>/g, '<img src="data:image/png;base64,$1" style="max-width:300px;max-height:300px;">')
|
||||||
|
.replace(/<!link="([^"]+)"\?name=([^>]+)>/g, '<a href="$1" target="_blank">$2</a>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hilfsfunktion zum Sortieren
|
||||||
|
function sortAnnouncements(data) {
|
||||||
|
return data.sort((a, b) => {
|
||||||
|
const dateA = new Date(a.Date.split('.').reverse().join('-'));
|
||||||
|
const dateB = new Date(b.Date.split('.').reverse().join('-'));
|
||||||
|
if (dateA < dateB) return 1;
|
||||||
|
if (dateA > dateB) return -1;
|
||||||
|
return Math.random() > 0.5 ? 1 : -1; // Zufällige Reihenfolge bei gleichem Datum
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ankündigungen filtern basierend auf !new-an und !stop
|
||||||
|
function filterContent(content) {
|
||||||
|
const newAnIndex = content.indexOf('!new-an');
|
||||||
|
const stopIndex = content.indexOf('!stop');
|
||||||
|
|
||||||
|
if (newAnIndex === -1) return ''; // Wenn !new-an nicht vorhanden ist, ignorieren
|
||||||
|
const start = newAnIndex + '!new-an'.length;
|
||||||
|
const end = stopIndex !== -1 ? stopIndex : content.length;
|
||||||
|
|
||||||
|
return content.slice(start, end).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ankündigungen abrufen und anzeigen
|
||||||
|
fetch(apiUrl)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
const container = document.getElementById('announcements');
|
||||||
|
container.innerHTML = ''; // Alte Inhalte entfernen
|
||||||
|
|
||||||
|
const sortedData = sortAnnouncements(data);
|
||||||
|
|
||||||
|
sortedData.forEach(announcement => {
|
||||||
|
let filteredContent = filterContent(announcement.Content);
|
||||||
|
if (!filteredContent) return; // Ignorieren, wenn kein !new-an vorhanden ist
|
||||||
|
|
||||||
|
const formattedContent = formatContent(filteredContent);
|
||||||
|
|
||||||
|
const announcementDiv = document.createElement('div');
|
||||||
|
announcementDiv.className = 'announcement';
|
||||||
|
|
||||||
|
announcementDiv.innerHTML = `
|
||||||
|
<h2>${announcement.Author}</h2>
|
||||||
|
<div class="meta">Datum: ${announcement.Date}</div>
|
||||||
|
<div class="content">${formattedContent}</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
container.appendChild(announcementDiv);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
document.getElementById('announcements').innerHTML = '<p>Fehler beim Laden der Ankündigungen.</p>';
|
||||||
|
console.error('Fehler:', error);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user