From 10edd306f16af9eb8468d3bdf6266a800b63d29f Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 19 Jun 2017 16:49:24 +0200 Subject: [PATCH] Improved architecture --- scripts/AnimeNotifier.ts | 15 +++++++++++++++ scripts/{Aero/Aero.ts => Application.ts} | 10 +++++----- scripts/main.ts | 14 +++++--------- 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 scripts/AnimeNotifier.ts rename scripts/{Aero/Aero.ts => Application.ts} (98%) diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts new file mode 100644 index 00000000..d1b9ac2f --- /dev/null +++ b/scripts/AnimeNotifier.ts @@ -0,0 +1,15 @@ +import { Application } from "./Application" + +export class AnimeNotifier { + app: Application + + constructor(app: Application) { + this.app = app + } + + run() { + this.app.content = this.app.find("content") + this.app.loading = this.app.find("loading") + this.app.run() + } +} \ No newline at end of file diff --git a/scripts/Aero/Aero.ts b/scripts/Application.ts similarity index 98% rename from scripts/Aero/Aero.ts rename to scripts/Application.ts index 9d41e16c..c669f537 100644 --- a/scripts/Aero/Aero.ts +++ b/scripts/Application.ts @@ -1,4 +1,4 @@ -class Aero { +export class Application { ajaxClass: string fadeOutClass: string activeLinkClass: string @@ -124,6 +124,8 @@ class Aero { let link = links[i] as HTMLElement link.classList.remove(this.ajaxClass) + + let self = this link.onclick = function(e) { // Middle mouse button should have standard behaviour if(e.which === 2) @@ -138,7 +140,7 @@ class Aero { return // Load requested page - aero.load(url, true) + self.load(url, true) } } } @@ -156,6 +158,4 @@ class Aero { parent.scrollTop = 0 } } -} - -export var aero = new Aero() \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/main.ts b/scripts/main.ts index 4ccebc0e..cca43926 100644 --- a/scripts/main.ts +++ b/scripts/main.ts @@ -1,16 +1,12 @@ -import { aero as app } from "./Aero/Aero" +import { Application } from "./Application" +import { AnimeNotifier } from "./AnimeNotifier" -class AnimeNotifier { - constructor() { - app.content = app.find("content") - app.loading = app.find("loading") - app.run() - } -} +let app = new Application() +let arn = new AnimeNotifier(app) document.onreadystatechange = function() { if(document.readyState === "interactive") { - let arn = new AnimeNotifier() + arn.run() } }