Refactor: Update brand name and dynamic titles
Consistently use "Oscar Pool" as the brand name. Dynamically update page titles to include the active Oscar year. Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
co-authored by
mathieumoran1
parent
88129ca5ac
commit
76e9a934d6
@@ -7,7 +7,27 @@ function isTokenExpired(decoded) {
|
||||
return !!decoded.exp && decoded.exp < currentTime;
|
||||
}
|
||||
|
||||
async function applyActiveOscarYearToTitle() {
|
||||
const base = 'Oscar Pool';
|
||||
const current = String(document.title || base);
|
||||
const sep = ' - ';
|
||||
const idx = current.indexOf(sep);
|
||||
const suffix = idx >= 0 ? current.slice(idx) : '';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/settings/year', { method: 'GET' });
|
||||
const data = res.ok ? await res.json().catch(() => null) : null;
|
||||
const year = Number(data?.year);
|
||||
document.title = Number.isInteger(year) ? `${base} (${year})${suffix}` : `${base}${suffix}`;
|
||||
} catch (_) {
|
||||
document.title = `${base}${suffix}`;
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
// Best-effort: update page title with active year.
|
||||
applyActiveOscarYearToTitle();
|
||||
|
||||
const token = localStorage.getItem('auth_token');
|
||||
if (!token) {
|
||||
window.location.href = '/';
|
||||
|
||||
Reference in New Issue
Block a user