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