diff --git a/TODO.md b/TODO.md index bb0728c..25391cf 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,6 @@ ## Minor Gameplay Polish -- [ ] **Add crew/player/rat name to page title, if available**. This will make it easier to distinguish tabs/browser history entries - [ ] **Save active sessions in browser local storage**. Whenever you create or join a game, your browser local storage should be updated with the game ID, player ID, crew name, and player/rat names (if available). Going to the home page with saved sessions should provide a menu of games to rejoin in addition to the ability to start a new game. It should be possible to delete entries from this list, which only affects the browser local storage, not the backend database, and is undoable (the entry doesn't disappear immediately, it's just marked as deleted until page refresh). - [ ] **Dead Pi-Rat rank voting streamlined**. Don't allow voting for dead Pi-Rats. If a player's only vote options are dead, then they skip voting entirely. diff --git a/frontend/src/lib/title.js b/frontend/src/lib/title.js new file mode 100644 index 0000000..5654eb7 --- /dev/null +++ b/frontend/src/lib/title.js @@ -0,0 +1,9 @@ +// Sets document.title to a " · "-joined set of page specifics followed by the +// app name, so tabs and browser history entries are easy to tell apart. +// Falsy parts are dropped; with no parts the title is just the app name. +const BASE = 'Rats with Gats'; + +export function setPageTitle(...parts) { + const prefix = parts.filter(Boolean).join(' · '); + document.title = prefix ? `${prefix} — ${BASE}` : BASE; +} diff --git a/frontend/src/pages/Admin.svelte b/frontend/src/pages/Admin.svelte index 6d2ac4e..4eea047 100644 --- a/frontend/src/pages/Admin.svelte +++ b/frontend/src/pages/Admin.svelte @@ -1,6 +1,7 @@