diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2025-12-09 22:16:48 -0600 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2025-12-09 22:16:57 -0600 |
| commit | 3e7fdfb6c8a50c59ac933f701526ad1815dded92 (patch) | |
| tree | d2c699ff93e23d0fe45845a4c2dc05d820ec317b /static/src/pages.js | |
| parent | 39738b84e9164b0f2d01f22440548c4393160013 (diff) | |
| download | immich-frame-0.3.0.tar.xz immich-frame-0.3.0.zip | |
refactor codebase. Reorganize file structure. Replace webpack for vite. Setup setuptools for application. Move closer to distributable appv0.3.0
Diffstat (limited to 'static/src/pages.js')
| -rw-r--r-- | static/src/pages.js | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/static/src/pages.js b/static/src/pages.js deleted file mode 100644 index e2199a4..0000000 --- a/static/src/pages.js +++ /dev/null @@ -1,54 +0,0 @@ -const menu = document.querySelector("#menu") - -export default class Page { - static pages = {} - static currentPage = null - - static pathnameCallback() { - const path = window.location.pathname.replace(/\/$/, "") - const page = Page.pages[path] - - if (!page) - throw new Error(`Path '${path}' does not exist`) - - if (Page.currentPage) - Page.currentPage.setVisible(false) - - page.setVisible(true) - Page.currentPage = page - } - - static softRedirect(path) { - window.history.pushState({}, "", path) - Page.pathnameCallback() - } - - constructor(pageContainer, endpoints, f_initialize) { - for (const endpoint of endpoints) - Page.pages[endpoint] = this - - this.pageContainer = pageContainer - this.endpoints = endpoints - this.initialize = f_initialize - this.visible = false - this.initialized = false - } - - async setVisible(visible) { - this.pageContainer.classList.toggle("hidden!", !visible) - this.visible = visible - if (this.visible) { - /* initialize page */ - if (!this.initialized && this.initialize) - this.initialized = await this.initialize(this.pageContainer) - - /* set selected attribute on the link */ - for (const a of menu.querySelectorAll("a")) { - if (this.endpoints.includes(a.getAttribute("href"))) - a.dataset.selected = "1" - else - delete a.dataset.selected - } - } - } -} |
