Files
AudioRating/templates/admin_add_task.html
robin a9ccdca62c feat: show percentages
feat: show file size in MB
2026-11-13 17:09:21 +01:00

99 lines
3.8 KiB
HTML
Raw Permalink 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>
<th>Dateigröße (MB)</th>
</thead>
<tbody>
<tr>
<td>Original</td>
<td>{{ song.original.bitrate }}</td>
<td>{{ song.original.sampling_rate }}</td>
<td>{{ (song.original.size / 1000000) | round(2) }}</td>
</tr>
{% if song.edits %}
{% for e in song.edits %}
<tr>
<td>{{ e.id }}</td>
<td>{{ e.bitrate }} <span class="percentage">({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%) {{ e.get("mode", "cbr") | upper }}</span></td>
<td>{{ e.sampling_rate }} <span class="percentage">({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</span></td>
<td>{{ (e.size / 1000000) | round(2) }} <span class="percentage">({{ (e.size / song.original.size * 100) | round(1) }}%)</span></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 %}