From 221b6451fb4f8559a10e7fefebd13ce125ef29d0 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 13 May 2021 14:50:51 +0200 Subject: Rewrite in TypeScript BuckleScript is no longer maintained. Choose a widely used techno that will still be maintained in the following years. --- src/main.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main.ts (limited to 'src/main.ts') diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..436a217 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,21 @@ +import * as Config from 'config' +import * as Form from 'view/form' +import * as Timer from 'view/timer' +import * as Router from 'router' + +export function showPage(route: Router.Route) { + if (route.kind === Router.Kind.Form) { + document.body.innerHTML = '' + document.body.appendChild(Form.view(route.config, showPage)) + } else if (route.kind === Router.Kind.Timer) { + document.body.innerHTML = '' + document.body.appendChild(Timer.view(route.config, showPage)) + } +} + +showPage(Router.from(document.location)) + +window.onpopstate = (event: Event) => { + Timer.clearInterval() + showPage(Router.from(document.location)) +} -- cgit v1.2.3