Spaces:
Configuration error
Configuration error
Download frontend/src/utils/browser-tab.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/utils/browser-tab.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/utils/browser-tab.ts
-
curl -L -o browser-tab.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/utils/browser-tab.ts
1.42 kB
| let originalTitle = ""; | |
| let titleInterval: number | undefined; | |
| const isBrowser = | |
| typeof window !== "undefined" && typeof document !== "undefined"; | |
| export const browserTab = { | |
| startNotification(message: string) { | |
| if (!isBrowser) return; | |
| // Store original title if not already stored | |
| if (!originalTitle) { | |
| originalTitle = document.title; | |
| } | |
| // Clear any existing interval | |
| if (titleInterval) { | |
| this.stopNotification(); | |
| } | |
| // Alternate between original title and notification message | |
| titleInterval = window.setInterval(() => { | |
| document.title = | |
| document.title === originalTitle ? message : originalTitle; | |
| }, 1000); | |
| // Set favicon to indicate notification | |
| const favicon = document.querySelector( | |
| 'link[rel="icon"]', | |
| ) as HTMLLinkElement; | |
| if (favicon) { | |
| favicon.href = favicon.href.includes("?notification") | |
| ? favicon.href | |
| : `${favicon.href}?notification`; | |
| } | |
| }, | |
| stopNotification() { | |
| if (!isBrowser) return; | |
| if (titleInterval) { | |
| window.clearInterval(titleInterval); | |
| titleInterval = undefined; | |
| } | |
| if (originalTitle) { | |
| document.title = originalTitle; | |
| } | |
| // Reset favicon | |
| const favicon = document.querySelector( | |
| 'link[rel="icon"]', | |
| ) as HTMLLinkElement; | |
| if (favicon) { | |
| favicon.href = favicon.href.replace("?notification", ""); | |
| } | |
| }, | |
| }; | |