updated index.html

This commit is contained in:
nocci 2025-05-12 12:15:57 +02:00
parent f2b434983e
commit 24ae1a622c
1 changed files with 25 additions and 15 deletions

View File

@ -8,7 +8,7 @@
<tr>
<th>{{ _('Cover') }}</th>
<th>{{ _('Name') }}</th>
<th class="key-col d-md-table-cell">{{ _('Key') }}</th>
<th class="key-col">{{ _('Key') }}</th>
<th>{{ _('Status') }}</th>
<th>{{ _('Created') }}</th>
<th>{{ _('Redeem by') }}</th>
@ -41,7 +41,7 @@
</a>
</td>
<td>{{ game.name }}</td>
<td class="font-monospace key-col d-none d-md-table-cell">{{ game.steam_key }}</td>
<td class="font-monospace key-col">{{ game.steam_key }}</td>
<td>
{% if game.status == 'nicht eingelöst' %}
<span class="badge bg-warning text-dark">{{ _('Not redeemed') }}</span>
@ -169,19 +169,30 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
console.log("DOM ist geladen!"); // Überprüfe, ob DOMContentLoaded überhaupt ausgeführt wird
const toggleKeysButton = document.getElementById('toggle-keys');
if (toggleKeysButton) {
console.log("Button with ID 'toggle-keys' found!");
toggleKeysButton.addEventListener('click', function() {
console.log("Button clicked!");
const keyCols = document.querySelectorAll('.key-col');
keyCols.forEach(function(el) {
el.classList.toggle('hidden');
const KEY_STORAGE = 'showKeys';
const toggleBtn = document.getElementById('toggle-keys');
function toggleKeys(visible) {
document.querySelectorAll('.key-col').forEach(el => {
visible ? el.classList.remove('d-none') : el.classList.add('d-none');
});
}
const savedState = localStorage.getItem(KEY_STORAGE);
const initialVisibility = savedState ? JSON.parse(savedState) : true;
toggleKeys(initialVisibility);
if (toggleBtn) {
let isVisible = initialVisibility;
toggleBtn.addEventListener('click', () => {
isVisible = !isVisible;
toggleKeys(isVisible);
localStorage.setItem(KEY_STORAGE, JSON.stringify(isVisible));
console.log(`Keys sind jetzt: ${isVisible ? 'sichtbar' : 'versteckt'}`);
console.log(`LocalStorage-Wert: ${localStorage.getItem(KEY_STORAGE)}`);
});
} else {
console.log("Button with ID 'toggle-keys' not found!");
}
});
</script>
@ -189,4 +200,3 @@ document.addEventListener('DOMContentLoaded', function() {
<div class="alert alert-info">{{ _('No games yet') }}</div>
{% endif %}
{% endblock %}