re-code the userscript
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Failing after 7s

This commit is contained in:
Lee
2024-04-25 23:39:26 +01:00
parent a8158c73c8
commit c8990f21cd
17 changed files with 1928 additions and 122 deletions

34
src/pages/page-handler.ts Normal file
View File

@ -0,0 +1,34 @@
import Page from "./page";
import PlayerPage from "./impl/player-page";
import {pageChangeCallback} from "../common/page-utils";
export default class PageHandler {
private pages: Page[] = [];
constructor() {
// Register the pages to handle
this.registerPage(new PlayerPage());
// Handle page changes
pageChangeCallback((path) => {
console.log(`Page changed to: ${path}`);
for (let page of this.pages) {
if (path.startsWith(page.route)) {
console.log(`Handling page: ${page.route}`);
page.onLoad();
}
}
});
}
/**
* Registers a page to be handled
*
* @param page The page to register
*/
private registerPage(page: Page) {
console.log(`Registered page: ${page.route}`)
this.pages.push(page);
}
}