Ready For 1.1
This commit is contained in:
parent
c23f2f88e8
commit
7a221acb8e
11 changed files with 297 additions and 146 deletions
|
@ -1,15 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>{{ _('My Games') }}</h1>
|
||||
<div>
|
||||
<a href="{{ url_for('export_games') }}" class="btn btn-outline-secondary">⬇️ {{ _('Export CSV') }}</a>
|
||||
<a href="{{ url_for('export_pdf') }}" class="btn btn-outline-secondary">⬇️ Export PDF (for sharing)</a>
|
||||
<a href="{{ url_for('import_games') }}" class="btn btn-outline-secondary">⬆️ {{ _('Import CSV') }}</a>
|
||||
<a href="{{ url_for('add_game') }}" class="btn btn-primary">+ {{ _('Add New Game') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button id="toggle-keys" class="btn btn-sm btn-outline-secondary mb-2">{{ _('Show/Hide Keys') }}</button>
|
||||
{% if games %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
|
@ -17,7 +8,7 @@
|
|||
<tr>
|
||||
<th>{{ _('Cover') }}</th>
|
||||
<th>{{ _('Name') }}</th>
|
||||
<th>{{ _('Key') }}</th>
|
||||
<th class="key-col d-md-table-cell">{{ _('Key') }}</th>
|
||||
<th>{{ _('Status') }}</th>
|
||||
<th>{{ _('Created') }}</th>
|
||||
<th>{{ _('Redeem by') }}</th>
|
||||
|
@ -33,15 +24,15 @@
|
|||
<a href="{{ url_for('game_details', game_id=game.id) }}" title="{{ _('Details') }}">
|
||||
{% if game.steam_appid %}
|
||||
<img src="https://cdn.cloudflare.steamstatic.com/steam/apps/{{ game.steam_appid }}/header.jpg"
|
||||
alt="Steam Header"
|
||||
alt="Steam Header"
|
||||
class="game-cover"
|
||||
{% if loop.first %}fetchpriority="high"{% endif %}
|
||||
width="368"
|
||||
width="368"
|
||||
height="172"
|
||||
loading="lazy">
|
||||
{% elif game.url and 'gog.com' in game.url %}
|
||||
<img src="{{ url_for('static', filename='gog_logo.webp') }}"
|
||||
alt="GOG Logo"
|
||||
alt="GOG Logo"
|
||||
class="game-cover"
|
||||
width="368"
|
||||
height="172"
|
||||
|
@ -50,7 +41,7 @@
|
|||
</a>
|
||||
</td>
|
||||
<td>{{ game.name }}</td>
|
||||
<td class="font-monospace">{{ game.steam_key }}</td>
|
||||
<td class="font-monospace key-col d-none d-md-table-cell">{{ game.steam_key }}</td>
|
||||
<td>
|
||||
{% if game.status == 'nicht eingelöst' %}
|
||||
<span class="badge bg-warning text-dark">{{ _('Not redeemed') }}</span>
|
||||
|
@ -100,8 +91,8 @@
|
|||
</td>
|
||||
<td class="text-nowrap">
|
||||
{% if game.status == 'geschenkt' %}
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-success generate-redeem"
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-success generate-redeem"
|
||||
data-game-id="{{ game.id }}"
|
||||
title="{{ _('Generate redeem link') }}">
|
||||
🔗
|
||||
|
@ -122,7 +113,7 @@
|
|||
document.querySelectorAll('.generate-redeem').forEach(btn => {
|
||||
btn.addEventListener('click', async function() {
|
||||
const gameId = this.dataset.gameId;
|
||||
const flashContainer = document.querySelector('.flash-container');
|
||||
const flashContainer = document.querySelector('.flash-container')
|
||||
|
||||
try {
|
||||
const response = await fetch(`/generate_redeem/${gameId}`, {
|
||||
|
@ -134,22 +125,36 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
|
|||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || '{{ _("Unknown error") }}');
|
||||
}
|
||||
|
||||
if (data.url) {
|
||||
await navigator.clipboard.writeText(data.url);
|
||||
|
||||
// Erfolgsmeldung mit übersetztem Text
|
||||
flashContainer.innerHTML = `
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ _("Link copied") }}: <a href="${data.url}" target="_blank">${data.url}</a>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
`;
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(data.url)
|
||||
.then(() => {
|
||||
// Succcess ?? maybe
|
||||
flashContainer.innerHTML = `
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
{{ _("Link copied") }}: <a href="${data.url}" target="_blank">${data.url}</a>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
.catch(err => {
|
||||
flashContainer.innerHTML = `
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
{{ _("Clipboard error") }}: ${err.message}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
alert("Clipboard API is not supported in your browser or context.");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
// Fehlermeldung mit übersetztem Text
|
||||
flashContainer.innerHTML = `
|
||||
|
@ -162,7 +167,26 @@ 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');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log("Button with ID 'toggle-keys' not found!");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% else %}
|
||||
<div class="alert alert-info">{{ _('No games yet') }}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue