Fixed JS labels

This commit is contained in:
Ignacio Rivero 2025-03-15 13:41:21 -03:00
parent 7bd77a4641
commit f42149125c
2 changed files with 629 additions and 607 deletions

View File

@ -193,6 +193,22 @@ class IPMPVServer:
html = html.replace("%STOP_LABEL%", _("stop"))
html = html.replace("%LANGUAGE_SELECTOR%", language_selector_html)
html = html.replace("%JS_LOADING%", _("loading"))
html = html.replace("%JS_NOW_PLAYING%", _("now_playing"))
html = html.replace("%JS_ERROR%", _("error"))
html = html.replace("%JS_CONNECTION_ERROR%", _("connection_error"))
html = html.replace("%JS_LOADING_CHANNEL%", _("loading_channel"))
html = html.replace("%JS_ERROR_LOADING_CHANNEL%", _("error_loading_channel"))
html = html.replace("%JS_VOLUME_LEVEL%", _("volume_level"))
html = html.replace("%JS_MUTED_YES%", _("muted_yes"))
html = html.replace("%JS_MUTED_NO%", _("muted_no"))
html = html.replace("%JS_LATENCY_LOW%", _("latency_low"))
html = html.replace("%JS_LATENCY_HIGH%", _("latency_high"))
html = html.replace("%JS_STOP_RETROARCH%", _("stop_retroarch"))
html = html.replace("%JS_START_RETROARCH%", _("start_retroarch"))
html = html.replace("%JS_ON_LABEL%", _("on"))
html = html.replace("%JS_OFF_LABEL%", _("off"))
return html
def _handle_play_custom(self):

View File

@ -540,7 +540,7 @@
// Show loading indicator
const playButton = document.querySelector('.input-btn');
const originalText = playButton.textContent;
playButton.textContent = "%LOADING%";
playButton.textContent = "%JS_LOADING%";
playButton.disabled = true;
fetch(`/play_custom?url=${encodeURIComponent(url)}`)
@ -551,15 +551,15 @@
if (data.success) {
// Show toast instead of alert on mobile
showToast("%NOW_PLAYING%: " + url);
showToast("%JS_NOW_PLAYING%: " + url);
} else {
showToast("%ERROR%: " + data.error);
showToast("%JS_ERROR%: " + data.error);
}
})
.catch(error => {
playButton.textContent = originalText;
playButton.disabled = false;
showToast("%CONNECTION_ERROR%");
showToast("%JS_CONNECTION_ERROR%");
});
}
@ -567,7 +567,7 @@
fetch(`/toggle_latency`)
.then(response => response.json())
.then(data => {
document.getElementById("latency-state").textContent = data.state ? "%LATENCY_LOW%" : "%LATENCY_HIGH%";
document.getElementById("latency-state").textContent = data.state ? "%JS_LATENCY_LOW%" : "%JS_LATENCY_HIGH%";
document.getElementById("latency-btn").className = data.state ? "ON" : "OFF";
});
}
@ -576,7 +576,7 @@
fetch(`/toggle_retroarch`)
.then(response => response.json())
.then(data => {
document.getElementById("retroarch-state").textContent = data.state ? "%STOP_RETROARCH%" : "%START_RETROARCH%";
document.getElementById("retroarch-state").textContent = data.state ? "%JS_STOP_RETROARCH%" : "%JS_START_RETROARCH%";
document.getElementById("retroarch-btn").className = data.state ? "ON" : "OFF";
});
}
@ -600,7 +600,7 @@
btn.disabled = true;
});
showToast("%LOADING_CHANNEL%");
showToast("%JS_LOADING_CHANNEL%");
fetch(`/channel?index=${index}`)
.then(() => window.location.reload())
@ -608,7 +608,7 @@
channelButtons.forEach(btn => {
btn.disabled = false;
});
showToast("%ERROR_LOADING_CHANNEL%");
showToast("%JS_ERROR_LOADING_CHANNEL%");
});
}
@ -616,7 +616,7 @@
fetch(`/toggle_deinterlace`)
.then(response => response.json())
.then(data => {
document.getElementById("deinterlace-state").textContent = data.state ? "%ON_LABEL%" : "%OFF_LABEL%";
document.getElementById("deinterlace-state").textContent = data.state ? "%JS_ON_LABEL%" : "%JS_OFF_LABEL%";
document.getElementById("deinterlace-btn").className = data.state ? "ON" : "OFF";
});
}
@ -633,7 +633,10 @@
fetch(`/volume_up`)
.then(response => response.json())
.then(data => {
showToast("%VOLUME_LEVEL%".replace("{0}", data.volume));
// Use a direct string with placeholder for proper rendering
let message = "%JS_VOLUME_LEVEL%";
message = message.replace("{0}", data.volume);
showToast(message);
});
}
@ -641,7 +644,10 @@
fetch(`/volume_down`)
.then(response => response.json())
.then(data => {
showToast("%VOLUME_LEVEL%".replace("{0}", data.volume));
// Use a direct string with placeholder for proper rendering
let message = "%JS_VOLUME_LEVEL%";
message = message.replace("{0}", data.volume);
showToast(message);
});
}
@ -649,19 +655,19 @@
fetch(`/toggle_mute`)
.then(response => response.json())
.then(data => {
muted = data.muted ? "%MUTED_YES%" : "%MUTED_NO%";
let muted = data.muted ? "%JS_MUTED_YES%" : "%JS_MUTED_NO%";
showToast(muted);
});
}
function channelUp() {
showToast("%LOADING_CHANNEL%");
showToast("%JS_LOADING_CHANNEL%");
fetch(`/channel_up`)
.then(() => window.location.reload())
}
function channelDown() {
showToast("%LOADING_CHANNEL%");
showToast("%JS_LOADING_CHANNEL%");
fetch(`/channel_down`)
.then(() => window.location.reload())
}