-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.html
More file actions
127 lines (116 loc) · 4.3 KB
/
Copy pathstats.html
File metadata and controls
127 lines (116 loc) · 4.3 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Zinsen & Staatsanleihen – Übersicht</title>
<style>
body { background-color: black; color: #00ff00; font-family: monospace; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #00ff00; padding: 6px; text-align: left; }
input, button { background-color: black; color: #00ff00; border: 1px solid #00ff00; font-family: monospace; margin: 4px; }
.btn { cursor: pointer; padding: 6px 12px; margin: 2px; }
.nav { display: flex; gap: 8px; margin-bottom: 12px; }
.nav a { border: 1px solid #00ff00; background-color: black; color: #00ff00; text-decoration: none; padding: 6px 12px; }
</style>
</head>
<body>
<h1>Zinsen & Staatsanleihen – Übersicht</h1>
<div class="nav">
<a href="#" onclick="toggleTheme()">☀️🌙</a>
<a href="index.html">🕳 bond_calculator</a>
<a href="README.html">🕹 README.md</a>
<a href="money.html">🐈 M2 / M3</a>
<a href="stats.html">📊 Stats</a>
<a href="Wallet.html">🎫 Wallet</a>
<a href="#" onclick="downloadJSON()">💾 Download</a>
<label for="uploadFile" style="cursor:pointer;">Upload</label>
<input type="file" id="uploadFile" accept=".json" onchange="uploadJSON()" style="display:none;" />
</div>
<form id="entryForm">
<label>Datum: <input type="date" id="date"></label>
<label>Land: <input type="text" id="land"></label>
<label>Leitzins: <input type="number" step="0.01" id="leitzins"></label>
<label>Kaufkurs (1J): <input type="number" step="0.01" id="bond_kaufkurs"></label>
<label>Status/Event: <input type="text" id="status"></label>
<button type="button" class="btn" onclick="addEntry()">Eintrag hinzufügen</button>
</form>
<table id="dataTable">
<thead>
<tr>
<th>Datum</th><th>Land</th><th>Leitzins</th><th>Kaufkurs (1J)</th><th>Status/Event</th><th>Löschen</th>
</tr>
</thead>
<tbody id="tableBody"></tbody>
</table>
<script>
let data = [];
async function loadData() {
try {
const res = await fetch("data/stats.json");
data = await res.json();
renderTable();
} catch (e) {
console.error("Konnte data/stats.json nicht laden:", e);
}
}
function renderTable() {
const tbody = document.getElementById("tableBody");
tbody.innerHTML = "";
data.forEach((entry, index) => {
const row = document.createElement("tr");
["date","land","leitzins","bond_kaufkurs","status"].forEach(key => {
const cell = document.createElement("td");
cell.textContent = entry[key];
row.appendChild(cell);
});
const delCell = document.createElement("td");
const delBtn = document.createElement("button");
delBtn.textContent = "X";
delBtn.onclick = () => { data.splice(index,1); renderTable(); };
delCell.appendChild(delBtn);
row.appendChild(delCell);
tbody.appendChild(row);
});
}
function addEntry() {
const newEntry = {
date: document.getElementById("date").value,
land: document.getElementById("land").value,
leitzins: parseFloat(document.getElementById("leitzins").value),
bond_kaufkurs: parseFloat(document.getElementById("bond_kaufkurs").value),
status: document.getElementById("status").value
};
data.push(newEntry);
renderTable();
}
function downloadJSON() {
const blob = new Blob([JSON.stringify(data, null, 2)], {type: "application/json"});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "stats.json";
a.click();
URL.revokeObjectURL(url);
}
function uploadJSON() {
const file = document.getElementById("uploadFile").files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = e => {
try {
data = JSON.parse(e.target.result);
renderTable();
} catch (err) {
alert("Ungültige JSON-Datei!");
}
};
reader.readAsText(file);
}
function toggleTheme() {
document.body.style.backgroundColor =
document.body.style.backgroundColor === "black" ? "#111" : "black";
}
loadData();
</script>
</body>
</html>