Player text visibility option #55
+2
-8
@@ -129,14 +129,8 @@
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="player_ui_show_source">
|
||||
<label class="form-check-label" for="player_ui_show_source">Afficher “Source”</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="player_ui_show_progress">
|
||||
<label class="form-check-label" for="player_ui_show_progress">Afficher “Progress”</label>
|
||||
<input class="form-check-input" type="checkbox" id="player_ui_show_status">
|
||||
<label class="form-check-label" for="player_ui_show_status">Afficher “Source” + “Progress”</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ window.onload = async function () {
|
||||
const saveActiveYearBtn = document.getElementById('save-active-year');
|
||||
|
||||
// Player UI (settings tab): show/hide admin status blocks in player.html
|
||||
const playerUiShowSourceEl = document.getElementById('player_ui_show_source');
|
||||
const playerUiShowProgressEl = document.getElementById('player_ui_show_progress');
|
||||
const playerUiShowStatusEl = document.getElementById('player_ui_show_status');
|
||||
const playerUiReloadBtn = document.getElementById('player_ui_reload');
|
||||
const playerUiSaveBtn = document.getElementById('player_ui_save');
|
||||
|
||||
@@ -193,21 +192,22 @@ window.onload = async function () {
|
||||
}
|
||||
|
||||
function setPlayerUiForm(value) {
|
||||
if (!playerUiShowSourceEl || !playerUiShowProgressEl) return;
|
||||
playerUiShowSourceEl.checked = !!value.showSource;
|
||||
playerUiShowProgressEl.checked = !!value.showProgress;
|
||||
if (!playerUiShowStatusEl) return;
|
||||
// Single checkbox controls both flags.
|
||||
playerUiShowStatusEl.checked = !!value.showSource && !!value.showProgress;
|
||||
}
|
||||
|
||||
function getPlayerUiFormValue() {
|
||||
const enabled = !!playerUiShowStatusEl?.checked;
|
||||
return normalizePlayerUi({
|
||||
showSource: !!playerUiShowSourceEl?.checked,
|
||||
showProgress: !!playerUiShowProgressEl?.checked,
|
||||
showSource: enabled,
|
||||
showProgress: enabled,
|
||||
});
|
||||
}
|
||||
|
||||
async function loadPlayerUiIntoUi() {
|
||||
// If the section isn't present (older HTML), skip gracefully.
|
||||
if (!playerUiShowSourceEl) return;
|
||||
if (!playerUiShowStatusEl) return;
|
||||
try {
|
||||
const value = await fetchPlayerUi();
|
||||
setPlayerUiForm(value);
|
||||
|
||||
+27
-4
@@ -139,6 +139,20 @@ async function fetchActiveOscarYear() {
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchPlayerAdminStatusUi() {
|
||||
try {
|
||||
const res = await fetch('/api/settings/player-admin-status-ui', { method: 'GET' });
|
||||
if (!res.ok) return { showSource: true, showProgress: true };
|
||||
const data = await res.json().catch(() => ({}));
|
||||
return {
|
||||
showSource: data?.showSource === undefined ? true : !!data.showSource,
|
||||
showProgress: data?.showProgress === undefined ? true : !!data.showProgress,
|
||||
};
|
||||
} catch (_) {
|
||||
return { showSource: true, showProgress: true };
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchPlaybackProgress(movieId, token) {
|
||||
try {
|
||||
const res = await fetch(`/api/movies/${encodeURIComponent(movieId)}/progress`, {
|
||||
@@ -868,8 +882,9 @@ window.onload = async function () {
|
||||
}
|
||||
pageLoader.setProgress(14);
|
||||
|
||||
// Load the active Oscar year in parallel with the movie fetch.
|
||||
// Load the active Oscar year (and player UI flags) in parallel with the movie fetch.
|
||||
const activeYearPromise = fetchActiveOscarYear();
|
||||
const playerUiPromise = fetchPlayerAdminStatusUi();
|
||||
|
||||
let decoded = null;
|
||||
try {
|
||||
@@ -889,8 +904,6 @@ window.onload = async function () {
|
||||
if (decoded.admin) {
|
||||
const adminLink = document.getElementById('admin-control-link');
|
||||
if (adminLink) adminLink.classList.remove('d-none');
|
||||
const adminStatus = document.getElementById('player-admin-status');
|
||||
if (adminStatus) adminStatus.classList.remove('d-none');
|
||||
}
|
||||
|
||||
const logoffBtn = document.getElementById('log-off');
|
||||
@@ -927,10 +940,20 @@ window.onload = async function () {
|
||||
return;
|
||||
}
|
||||
|
||||
const activeYear = await activeYearPromise;
|
||||
const [activeYear, playerUi] = await Promise.all([activeYearPromise, playerUiPromise]);
|
||||
setHeader(movie, { activeYear });
|
||||
pageLoader.setProgress(58);
|
||||
|
||||
// Admin-only status block (Source + Progress) can be globally disabled via settings.
|
||||
if (decoded?.admin) {
|
||||
const enabled = !!playerUi?.showSource && !!playerUi?.showProgress;
|
||||
const adminStatus = document.getElementById('player-admin-status');
|
||||
if (adminStatus) {
|
||||
if (enabled) adminStatus.classList.remove('d-none');
|
||||
else adminStatus.classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
const resolved = resolveMovieSource(movie);
|
||||
if (!resolved?.src) {
|
||||
setSourceLabel('—');
|
||||
|
||||
Reference in New Issue
Block a user