Web-Submit: Bestätigung mit Referenz-ID + Kopier-Button + Lösch-Hinweis
- /api/submit gibt jetzt submission_id + delete_hint zurück
- Frontend zeigt nach erfolgreichem Submit eine Erfolgsmeldung mit ID
- '📋 Kopieren'-Button speichert die ID in die Zwischenablage
- Hinweis, dass die ID für spätere Löschung notiert werden soll
- Overlay schließt nach 8s (statt 2.5s) — Zeit zum Kopieren
This commit is contained in:
@@ -2127,7 +2127,16 @@ def public_frontend():
|
||||
const r = await fetch('/api/submit', { method:'POST', body:formData });
|
||||
const data = await r.json();
|
||||
if (r.ok) {
|
||||
sStatus.textContent = data.message;
|
||||
const subId = data.submission_id;
|
||||
const hint = data.delete_hint || 'Notiere dir diese ID — mit ihr kannst du den Beitrag später löschen lassen.';
|
||||
sStatus.innerHTML = '<div style="background:#e8f5e9;border-radius:12px;padding:1rem;margin-top:0.5rem;text-align:center;">'
|
||||
+ '<div style="font-size:1.1rem;font-weight:700;color:#20228a;margin-bottom:0.4rem;">✅ ' + data.message + '</div>'
|
||||
+ '<div style="display:flex;align-items:center;justify-content:center;gap:0.5rem;margin:0.6rem 0;">'
|
||||
+ '<code id="refId" style="background:#fff;padding:0.4rem 0.8rem;border-radius:6px;font-size:1.2rem;font-weight:700;color:#20228a;border:1.5px solid #20228a;">#' + subId + '</code>'
|
||||
+ '<button id="copyIdBtn" style="background:#20228a;color:#fff;border:none;border-radius:6px;padding:0.4rem 0.8rem;font-size:0.78rem;font-weight:600;cursor:pointer;font-family:inherit;">📋 Kopieren</button>'
|
||||
+ '</div>'
|
||||
+ '<p style="font-size:0.72rem;color:#666;margin:0.4rem 0 0 0;">' + hint + '</p>'
|
||||
+ '</div>';
|
||||
sStatus.style.color = '#20228a';
|
||||
document.getElementById('subName').value = '';
|
||||
document.getElementById('subText').value = '';
|
||||
@@ -2138,7 +2147,22 @@ def public_frontend():
|
||||
document.getElementById('filePreview').style.display = 'none';
|
||||
document.getElementById('subHalle').value = '';
|
||||
document.getElementById('subSpiel').value = '';
|
||||
setTimeout(() => { sOverlay.classList.remove('open'); sOpen = false; sStatus.textContent = ''; }, 2500);
|
||||
// Kopier-Button aktivieren
|
||||
setTimeout(function() {
|
||||
var copyBtn = document.getElementById('copyIdBtn');
|
||||
if (copyBtn) {
|
||||
copyBtn.addEventListener('click', function() {
|
||||
navigator.clipboard.writeText('#' + subId).then(function() {
|
||||
copyBtn.textContent = '✓ Kopiert!';
|
||||
setTimeout(function() { copyBtn.textContent = '📋 Kopieren'; }, 2000);
|
||||
}).catch(function() {
|
||||
copyBtn.textContent = 'Fehler';
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 50);
|
||||
// Overlay schließt automatisch nach 8 Sekunden
|
||||
setTimeout(function() { sOverlay.classList.remove('open'); sOpen = false; sStatus.innerHTML = ''; }, 8000);
|
||||
} else {
|
||||
sStatus.textContent = data.error || 'Fehler beim Senden.';
|
||||
sStatus.style.color = '#dc3545';
|
||||
@@ -2489,8 +2513,14 @@ def api_submit():
|
||||
('web', sender_id, sender_name, msg_type, text or None, media_path, halle_valid, spiel_titel or None),
|
||||
)
|
||||
db.commit()
|
||||
sub_id = db.execute("SELECT last_insert_rowid()").fetchone()[0]
|
||||
|
||||
return jsonify({'ok': True, 'message': 'Danke für deine Einreichung! Wir schauen sie uns an. 🎲'})
|
||||
return jsonify({
|
||||
'ok': True,
|
||||
'message': f'Beitrag #{sub_id} erfolgreich übermittelt! 🎲',
|
||||
'submission_id': sub_id,
|
||||
'delete_hint': 'Notiere dir diese ID — mit ihr kannst du den Beitrag später löschen lassen.',
|
||||
})
|
||||
|
||||
|
||||
@app.route("/beitrag/<int:sub_id>")
|
||||
|
||||
Reference in New Issue
Block a user