[ai] new option on how to continue for mapping

This commit is contained in:
2025-08-09 22:59:40 +02:00
parent ce863f4d02
commit 02cd5da886
4 changed files with 244 additions and 25 deletions

View File

@@ -117,6 +117,14 @@
<label for="song">Song:</label>
<input type="text" id="song" name="song" required>
</div>
<div>
<label for="mode">Mode:</label>
<select id="mode" name="mode">
<option value="s">Single (play selected song / file)</option>
<option value="f">Folder (play selected folder, then stop)</option>
<option value="c">Continuous (continuous playback / loop folder)</option>
</select>
</div>
<button type="button" class="action-btn" style="grid-column: 1 / -1;" onclick="editMapping()">Update Mapping</button>
</form>

View File

@@ -164,13 +164,17 @@ function playNamedSong(song) {
function editMapping() {
var rfid = document.getElementById('rfid').value;
var song = document.getElementById('song').value;
var modeEl = document.getElementById('mode');
var mode = modeEl ? modeEl.value : 's';
var xhr = new XMLHttpRequest();
xhr.open("POST", "/edit_mapping", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.send("rfid=" + encodeURIComponent(rfid) + "&song=" + encodeURIComponent(song));
xhr.send("rfid=" + encodeURIComponent(rfid) + "&song=" + encodeURIComponent(song) + "&mode=" + encodeURIComponent(mode));
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
alert("Mapping updated successfully!");
} else if (xhr.readyState === 4) {
alert("Failed to update mapping: " + (xhr.responseText || xhr.status));
}
};
}