quick fix 2

This commit is contained in:
Bartłomiej Patyk
2025-10-22 19:05:25 +02:00
commit e5e64b6dc8
598 changed files with 300649 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./webcss/nav.css">
<link rel="stylesheet" href="./webcss/main.css">
<title>Kontakt</title>
</head>
<body>
<nav>
<ul>
<li><a href="main.html">Strona główna</a></li>
<li><a href="danebota.html">Dane Bota</a></li>
<li><a href="sugestie.html">Sugestie</a></li>
<li><a href="https://discord.com/oauth2/authorize?client_id=1379068224947093536">dodaj mojego bota!</a></li>
<li><a href="Kontakt.html">Kontakt</a></li>
</ul>
</nav>
<main>
<h1>Kontakty</h1>
<p>Możesz się ze mną skontaktować na Discordie: softfrog</p>
</main>
</body>
</html>

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./webcss/nav.css">
<link rel="stylesheet" href="./webcss/bota.css">
<link rel="stylesheet" href="./webcss/main.css">
<!-- load the script at the end of body instead of link in head -->
<title>Danebota</title>
</head>
<body>
<nav>
<ul>
<li><a href="main.html">Strona główna</a></li>
<li><a href="danebota.html">Dane Bota</a></li>
<li><a href="sugestie.html">Sugestie</a></li>
<li><a href="https://discord.com/oauth2/authorize?client_id=1379068224947093536">dodaj mojego bota!</a></li>
<li><a href="Kontakt.html">Kontakt</a></li>
</ul>
</nav>
<main>
<h1>Dane Bota</h1>
<p>Tu znajdziesz informacje o bocie.</p>
<section>
<h2>Statystyki</h2>
<div id="bot-stats">
<p>Liczba serwerów: 56</p>
</div>
</section>
</main>
<script src="./data.js"></script>
</body>
</html>

62
webserver/web/data.js Normal file
View File

@ -0,0 +1,62 @@
// Fetch playcount data from backend API and expose a helper to render it
async function fetchPlaycounts() {
try {
const resp = await fetch('/api/playcounts');
if (!resp.ok) throw new Error('Network response was not ok');
return await resp.json();
} catch (err) {
return { error: err.message };
}
}
// Simple renderer for danebota.html - injects table counts
async function renderStats() {
const out = document.getElementById('bot-stats');
if (!out) return;
out.textContent = 'Ładowanie…';
// prefer the summary endpoint which gives aggregated totals
try {
const resp = await fetch('/api/playcounts/summary');
if (!resp.ok) throw new Error('Network response was not ok');
const summary = await resp.json();
if (summary.error) {
out.textContent = 'Błąd: ' + (summary.detail || summary.error);
return;
}
let html = '';
html += `<p>Liczba serwerów z discord: ${summary.total_servers}</p>`;
html += `<p>Suma wszystkich odtworzeń: ${summary.total_plays}</p>`;
// Render each server and its top 5 tracks
const servers = summary.servers || {};
for (const [server, info] of Object.entries(servers)) {
html += `<section class="server-block"><h3>Serwer: ${server}</h3>`;
html += `<p>Łącznie odtworzeń: ${info.total}</p>`;
const tracks = info.tracks || {};
// sort tracks by plays desc
const sorted = Object.entries(tracks).sort((a, b) => b[1] - a[1]).slice(0, 10000);
if (sorted.length === 0) {
html += `<p>Brak danych o utworach.</p>`;
} else {
html += `<ol>`;
html += `<br>`;
for (const [tname, plays] of sorted) {
html += `<li style="margin-top: 10px;">${tname}${plays} odtworzeń</li>`;
}
html += `</ol>`;
}
html += `</section>`;
}
out.innerHTML = html;
} catch (err) {
out.textContent = 'Błąd sieci: ' + err.message;
}
}
// Auto-run when included from danebota.html
if (typeof window !== 'undefined') {
window.addEventListener('DOMContentLoaded', renderStats);
}

33
webserver/web/main.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./webcss/nav.css">
<link rel="stylesheet" href="./webcss/main.css">
<title>Główna Strona</title>
</head>
<body>
<nav>
<ul>
<li><a href="main.html">Strona główna</a></li>
<li><a href="danebota.html">Dane Bota</a></li>
<li><a href="sugestie.html">Sugestie</a></li>
<li><a href="https://discord.com/oauth2/authorize?client_id=1379068224947093536">dodaj mojego bota!</a></li>
<li><a href="Kontakt.html">Kontakt</a></li>
</ul>
</nav>
<main>
<h1>Witamy na Stronie Głównej</h1>
<p>To jest główna strona mojego bota.</p>
<br><br>
<section>
<h1>Update</h1>
<h2>General Update #1 19.10.2025</h2>
<p>1. dodano statystyki bota na danebota</p>
<p>2. </p>
<p>3. </p>
</section>
</main>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./webcss/nav.css">
<link rel="stylesheet" href="./webcss/main.css">
<title>sugestie</title>
</head>
<body>
<nav>
<ul>
<li><a href="main.html">Strona główna</a></li>
<li><a href="danebota.html">Dane Bota</a></li>
<li><a href="sugestie.html">Sugestie</a></li>
<li><a href="https://discord.com/oauth2/authorize?client_id=1379068224947093536">dodaj mojego bota!</a></li>
<li><a href="Kontakt.html">Kontakt</a></li>
</ul>
</nav>
<main>
<h1>Podaj swoją sugestię muzyki</h1>
<div id="dataContainer">
<div class="input-group">
<label for="var1">Nazwa Utworu: (OBOWIĄZKOWY)</label>
<br>
<input type="text" name="sugestia" id="sugestia" style="height: 30px; width: 400px;" placeholder="Twoja sugestia..." required>
</div>
<div class="input-group">
<label for="var2">Link:</label>
<br>
<input type="url" name="link" id="link" style="height: 30px; width: 400px;" placeholder="Link do utworu...">
</div>
<button id="sendButton">Wyślij do Bazy</button>
</div>
<div id="status"></div>
</main>
<script src="./sugestie.js"></script>
</body>
</html>

60
webserver/web/sugestie.js Normal file
View File

@ -0,0 +1,60 @@
// Zmieniamy 'sugestionForm' i 'submit' na 'sendButton' i 'click'
document.getElementById('sendButton').addEventListener('click', async function(event) {
// Nie musimy już wywoływać event.preventDefault(), ponieważ to nie jest submit formularza
const statusDiv = document.getElementById('status');
statusDiv.textContent = 'Wysyłanie danych...';
statusDiv.style.color = 'orange';
// 1. Pobranie zmiennych z pól wejściowych
const zmienna1 = document.getElementById('sugestia').value;
const zmienna2 = document.getElementById('link').value;
// Weryfikacja obowiązkowej zmiennej 1
if (!zmienna1.trim()) {
statusDiv.textContent = 'BŁĄD: Zmienna 1 jest obowiązkowa!';
statusDiv.style.color = 'red';
return; // Zatrzymuje wysyłanie
}
// 2. Przygotowanie danych jako obiekt JavaScript (JSON)
const dataToSend = {
zmienna1: zmienna1,
zmienna2: zmienna2
};
// 3. Wysłanie danych do API za pomocą Fetch API
try {
const response = await fetch('/api/sugestie', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(dataToSend)
});
const result = await response.json();
if (response.ok && result.success) {
// Sukces
statusDiv.textContent = 'Sukces! Twoje dane nigdy nie będą przeczytane';
statusDiv.style.color = 'green';
// Opcjonalne: Wyczyść pola po sukcesie
document.getElementById('sugestia').value = '';
document.getElementById('link').value = '';
} else {
// Błąd
const errorMessage = result.error || 'Nieznany błąd zapisu.';
statusDiv.textContent = 'BŁĄD: ' + errorMessage;
statusDiv.style.color = 'red';
}
} catch (error) {
// Błąd sieci
statusDiv.textContent = 'BŁĄD POŁĄCZENIA: Nie można połączyć się z serwerem Flask.';
statusDiv.style.color = 'red';
console.error('Fetch error:', error);
}
});