Files
AudioRating/templates/admin_add_task.html
T
2026-11-13 16:18:25 +01:00

96 lines
3.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "admin.html" %}
{% block admin_title %}Kopie erstellen{% endblock %}
{% block admin_content %}
<form class="form" id="form">
<label for="mode">Modus</label>
<select id="mode" name="mode">
<option value="cbr">Konstant (CBR)</option>
<option value="vbr">Variabel (VBR)</option>
</select>
<div id="cbr-field">
<label for="bitrate">Bitrate (kbit/s)</label>
<select id="bitrate" name="bitrate">
{% for b in [32, 48, 64, 96, 128, 160, 192, 256, 320] if b * 1000 <= song.original.bitrate %}
<option value="{{ b }}">{{ b }} kbit/s</option>
{% endfor %}
</select>
</div>
<div id="vbr-field" hidden>
<label for="quality">VBR-Qualität</label>
<select id="quality" name="quality">
<option value="0">V0 (beste, ca. 220–260 kbit/s)</option>
<option value="2">V2 (ca. 170–210 kbit/s)</option>
<option value="4">V4 (ca. 140–185 kbit/s)</option>
<option value="6">V6 (ca. 100–130 kbit/s)</option>
<option value="8">V8 (ca. 70–105 kbit/s)</option>
<option value="9">V9 (schlechteste, ca. 65–85 kbit/s)</option>
</select>
</div>
<label for="sampling_rate">Abtastrate (Hz)</label>
<select id="sampling_rate" name="sampling_rate" required>
{% for r in [8000, 11025, 16000, 22050, 32000, 44100, 48000] if r <= song.original.sampling_rate %}
<option value="{{ r }}" {% if r == song.original.sampling_rate %}selected{% endif %}>{{ r }} Hz</option>
{% endfor %}
</select>
<button type="submit">Erstellen</button>
</form>
<div class="table-wrap" style="margin-top: 2rem;">
<table>
<thead>
<th>ID</th>
<th>Bitrate (bit/s)</th>
<th>Abtastrate (Hz)</th>
</thead>
<tbody>
<tr>
<td>Original</td>
<td>{{ song.original.bitrate }}</td>
<td>{{ song.original.sampling_rate }}</td>
</tr>
{% if song.edits %}
{% for e in song.edits %}
<tr>
<td>{{ e.id }}</td>
<td>{{ e.bitrate }} ({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%) {{ e.get("mode", "cbr") | upper }}</td>
<td>{{ e.sampling_rate }} ({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
<script>
const form = document.getElementById("form");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const button = form.querySelector("button");
button.disabled = true; // Doppelklick verhindern
try {
const res = await fetch("/api/admin/add/{{ song.id }}", {
method: "POST",
body: new FormData(form),
});
if (!res.ok) throw new Error("Fehler " + res.status);
location.reload(); // Tabelle aktualisieren
} catch (err) {
alert("Erstellen fehlgeschlagen: " + err.message);
button.disabled = false;
}
});
const mode = document.getElementById("mode");
mode.addEventListener("change", () => {
document.getElementById("cbr-field").hidden = mode.value !== "cbr";
document.getElementById("vbr-field").hidden = mode.value !== "vbr";
});
</script>
{% endblock %}