přidán první navrh stránky

This commit is contained in:
archos 2024-06-11 20:54:08 +02:00
parent 6982f1403e
commit 0f93fc31be
5 changed files with 190 additions and 0 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2024 Archos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,74 @@
# Přehled Financí Komunity
Tento projekt slouží k zobrazení transparentního přehledu financí komunity. Stránka zobrazuje seznam příjmů a výdajů, které jsou uloženy v CSV souboru, a aktuální stav účtu.
## Struktura projektu
- `index.html` - Hlavní HTML soubor obsahující strukturu stránky.
- `styly.css` - CSS soubor obsahující styly pro stránku.
- `skript.js` - JavaScript soubor obsahující logiku pro načítání a zpracování dat.
- `finance.csv` - CSV soubor obsahující data o transakcích.
- `README.md` - Tento soubor s informacemi o projektu.
## Jak používat
### 1. Klonování repozitáře
Nejprve naklonujte tento repozitář na svůj počítač:
```bash
git clone https://git.arch-linux.cz/Archos/prehlad-financi-komunity.git
```
### 2. Spuštění lokálního serveru
Pro zobrazení stránky je potřeba spustit jednoduchý HTTP server. Můžete použít Python:
- Použití Python 3
```bash
cd prehlad-financi-komunity
python -m http.server
```
- Použití Python 2
```bash
cd prehlad-financi-komunity
python -m SimpleHTTPServer
```
### 3. Otevření prohlížeče
Otevřete webový prohlížeč a přejděte na adresu:
```bash
http://localhost:8000
```
### 4. Aktualizace dat
Pro aktualizaci dat stačí upravit nebo přidat nové záznamy do souboru finance.csv a stránka se automaticky aktualizuje při příštím načtení.
## Struktura CSV souboru
Soubor finance.csv by měl mít následující strukturu:
```bash
Datum,Popis,Částka,Měna,Typ
2024-06-01,Příspěvek Archos,100,EUR,Příjem
2024-06-05,Údržba serveru,-50,EUR,Výdaj
2024-06-10,Členský poplatek,1200,CZK,Příjem
2024-06-15,Obnovení domény,-300,CZK,Výdaj
```
## Přizpůsobení
- Kurz měny: Pro jednoduchost je v kódu nastavený kurz 1 EUR = 25 CZK. Tento kurz můžete upravit podle potřeby v JavaScript kódu v souboru index.html.
## Kontakt
Pokud máte nějaké otázky nebo potřebujete pomoc, můžete mě kontaktovat na [archos@arch-linux.cz](mailto:archos@arch-linux.cz).
Tento README soubor poskytuje užitečné informace o projektu, včetně návodu na spuštění lokálního serveru, struktury CSV souboru a kontaktních informací. Můžeš jej upravit podle potřeby a přidat další informace, které by byly pro uživatele užitečné.

48
index.html Normal file
View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Přehled Financí Komunity</title>
<!-- Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="styly.css" rel="stylesheet">
</head>
<body>
<div class="container">
<header class="text-center">
<h1>Přehled Financí Komunity</h1>
<p>Tento projekt poskytuje transparentní přehled transakcí na našem <a href="https://transparentniucty.moneta.cz/264043266" target="_blank">transparentním účtu</a>.</p>
</header>
<div class="account-balance text-center">
Aktuální stav účtu: <span id="account-balance">Načítání...</span>
</div>
<table id="finance-table" class="table table-striped">
<thead class="thead-dark">
<tr>
<th>Datum</th>
<th>Popis</th>
<th>Částka</th>
<th>Měna</th>
<th>Typ</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<footer class="text-center">
<p>&copy; 2024 <a href="https://git.arch-linux.cz/Archos/prehlad-financi-komunity" target="_blank">Archos</a></p>
</footer>
</div>
<!-- Bootstrap JS and dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- Custom JS -->
<script src="skript.js"></script>
</body>
</html>

43
skript.js Normal file
View File

@ -0,0 +1,43 @@
document.addEventListener('DOMContentLoaded', function() {
fetch('finance.csv')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(data => {
let rows = data.split('\n').slice(1);
rows = rows.filter(row => row.trim() !== ""); // Remove empty rows
rows.reverse(); // Reverse the order of rows
const tableBody = document.querySelector('#finance-table tbody');
let accountBalance = 0;
rows.forEach(row => {
const columns = row.split(',');
if (columns.length >= 5) {
const tr = document.createElement('tr');
columns.forEach(column => {
const td = document.createElement('td');
td.textContent = column;
tr.appendChild(td);
});
tableBody.appendChild(tr);
// Calculate account balance
const amount = parseFloat(columns[2]);
const currency = columns[3];
if (currency === 'CZK') {
accountBalance += amount;
} else if (currency === 'EUR') {
// For simplicity, assume 1 EUR = 25 CZK (you can adjust the conversion rate)
accountBalance += amount * 25;
}
}
});
document.getElementById('account-balance').textContent = accountBalance.toFixed(2) + ' CZK';
})
.catch(error => {
console.error('Error fetching the CSV file:', error);
document.getElementById('account-balance').textContent = 'Chyba při načítání dat';
});
});

16
styly.css Normal file
View File

@ -0,0 +1,16 @@
body {
padding: 20px;
}
h1 {
margin-bottom: 20px;
}
table {
width: 100%;
}
th, td {
text-align: left;
}
.account-balance {
font-size: 1.5em;
margin-bottom: 20px;
}