From ab0c933b3d91cf8bd721678e2c3e79a017281ca0 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 2 Apr 2018 07:44:11 +0200 Subject: [PATCH] Deleted app.find() --- scripts/Actions/AnimeList.ts | 2 +- scripts/Actions/Explore.ts | 8 ++++---- scripts/Actions/FollowUser.ts | 4 ++-- scripts/Actions/Forum.ts | 24 ++++++++++++------------ scripts/Actions/InfiniteScroller.ts | 2 +- scripts/Actions/Serialization.ts | 2 +- scripts/Actions/SideBar.ts | 2 +- scripts/AnimeNotifier.ts | 22 +++++++++++----------- scripts/Application.ts | 4 ---- 9 files changed, 33 insertions(+), 37 deletions(-) diff --git a/scripts/Actions/AnimeList.ts b/scripts/Actions/AnimeList.ts index 3fbe97d5..8c7baaa1 100644 --- a/scripts/Actions/AnimeList.ts +++ b/scripts/Actions/AnimeList.ts @@ -32,6 +32,6 @@ export function removeAnimeFromCollection(arn: AnimeNotifier, button: HTMLElemen let apiEndpoint = arn.findAPIEndpoint(button) arn.post(apiEndpoint + "/remove/" + animeId, "") - .then(() => arn.app.load(`/+${nick}/animelist/` + (arn.app.find("Status") as HTMLSelectElement).value)) + .then(() => arn.app.load(`/+${nick}/animelist/` + (document.getElementById("Status") as HTMLSelectElement).value)) .catch(err => arn.statusMessage.showError(err)) } \ No newline at end of file diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index b97ba40e..ddb32242 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -3,11 +3,11 @@ import { findAll } from "scripts/Utils"; // Filter anime on explore page export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { - let root = arn.app.find("filter-root") + let root = document.getElementById("filter-root") - let elementYear = arn.app.find("filter-year") as HTMLSelectElement - let elementStatus = arn.app.find("filter-status") as HTMLSelectElement - let elementType = arn.app.find("filter-type") as HTMLSelectElement + let elementYear = document.getElementById("filter-year") as HTMLSelectElement + let elementStatus = document.getElementById("filter-status") as HTMLSelectElement + let elementType = document.getElementById("filter-type") as HTMLSelectElement for(let element of findAll("anime-grid-image")) { let img = element as HTMLImageElement diff --git a/scripts/Actions/FollowUser.ts b/scripts/Actions/FollowUser.ts index 01a87e74..00861602 100644 --- a/scripts/Actions/FollowUser.ts +++ b/scripts/Actions/FollowUser.ts @@ -4,7 +4,7 @@ import AnimeNotifier from "../AnimeNotifier" export function followUser(arn: AnimeNotifier, elem: HTMLElement) { return arn.post(elem.dataset.api, "") .then(() => arn.reloadContent()) - .then(() => arn.statusMessage.showInfo("You are now following " + arn.app.find("nick").innerText + ".")) + .then(() => arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").innerText + ".")) .catch(err => arn.statusMessage.showError(err)) } @@ -12,6 +12,6 @@ export function followUser(arn: AnimeNotifier, elem: HTMLElement) { export function unfollowUser(arn: AnimeNotifier, elem: HTMLElement) { return arn.post(elem.dataset.api, "") .then(() => arn.reloadContent()) - .then(() => arn.statusMessage.showInfo("You stopped following " + arn.app.find("nick").innerText + ".")) + .then(() => arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").innerText + ".")) .catch(err => arn.statusMessage.showError(err)) } \ No newline at end of file diff --git a/scripts/Actions/Forum.ts b/scripts/Actions/Forum.ts index 48d08a43..a63e5033 100644 --- a/scripts/Actions/Forum.ts +++ b/scripts/Actions/Forum.ts @@ -4,11 +4,11 @@ import AnimeNotifier from "../AnimeNotifier" export function editPost(arn: AnimeNotifier, element: HTMLElement) { let postId = element.dataset.id - let render = arn.app.find("render-" + postId) - let toolbar = arn.app.find("toolbar-" + postId) - let title = arn.app.find("title-" + postId) - let source = arn.app.find("source-" + postId) - let edit = arn.app.find("edit-toolbar-" + postId) + let render = document.getElementById("render-" + postId) + let toolbar = document.getElementById("toolbar-" + postId) + let title = document.getElementById("title-" + postId) + let source = document.getElementById("source-" + postId) + let edit = document.getElementById("edit-toolbar-" + postId) render.classList.toggle("hidden") toolbar.classList.toggle("hidden") @@ -23,8 +23,8 @@ export function editPost(arn: AnimeNotifier, element: HTMLElement) { // Save post export function savePost(arn: AnimeNotifier, element: HTMLElement) { let postId = element.dataset.id - let source = arn.app.find("source-" + postId) as HTMLTextAreaElement - let title = arn.app.find("title-" + postId) as HTMLInputElement + let source = document.getElementById("source-" + postId) as HTMLTextAreaElement + let title = document.getElementById("title-" + postId) as HTMLInputElement let text = source.value let updates: any = { @@ -58,8 +58,8 @@ export function deletePost(arn: AnimeNotifier, element: HTMLElement) { // Forum reply export function forumReply(arn: AnimeNotifier) { - let textarea = arn.app.find("new-reply") as HTMLTextAreaElement - let thread = arn.app.find("thread") + let textarea = document.getElementById("new-reply") as HTMLTextAreaElement + let thread = document.getElementById("thread") let post = { text: textarea.value, @@ -80,9 +80,9 @@ export function newGroupPost(arn: AnimeNotifier) { // Create thread export function createThread(arn: AnimeNotifier) { - let title = arn.app.find("title") as HTMLInputElement - let text = arn.app.find("text") as HTMLTextAreaElement - let category = arn.app.find("tag") as HTMLInputElement + let title = document.getElementById("title") as HTMLInputElement + let text = document.getElementById("text") as HTMLTextAreaElement + let category = document.getElementById("tag") as HTMLInputElement let thread = { title: title.value, diff --git a/scripts/Actions/InfiniteScroller.ts b/scripts/Actions/InfiniteScroller.ts index 8ec05354..ca2c176c 100644 --- a/scripts/Actions/InfiniteScroller.ts +++ b/scripts/Actions/InfiniteScroller.ts @@ -11,7 +11,7 @@ export async function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) { arn.loading(true) button.disabled = true - let target = arn.app.find("load-more-target") + let target = document.getElementById("load-more-target") let index = button.dataset.index try { diff --git a/scripts/Actions/Serialization.ts b/scripts/Actions/Serialization.ts index af4e192f..91769d67 100644 --- a/scripts/Actions/Serialization.ts +++ b/scripts/Actions/Serialization.ts @@ -138,7 +138,7 @@ export function addNumber(arn: AnimeNotifier, element: HTMLElement) { return } - let input = arn.app.find(element.dataset.id) as HTMLInputElement + let input = document.getElementById(element.dataset.id) as HTMLInputElement let add = parseInt(element.dataset.add) let num = parseInt(input.value) let newValue = num + add diff --git a/scripts/Actions/SideBar.ts b/scripts/Actions/SideBar.ts index fd88b30e..6b542441 100644 --- a/scripts/Actions/SideBar.ts +++ b/scripts/Actions/SideBar.ts @@ -2,5 +2,5 @@ import AnimeNotifier from "../AnimeNotifier" // Toggle sidebar export function toggleSidebar(arn: AnimeNotifier) { - arn.app.find("sidebar").classList.toggle("sidebar-visible") + document.getElementById("sidebar").classList.toggle("sidebar-visible") } \ No newline at end of file diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 261e6b96..852ffc36 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -102,9 +102,9 @@ export default class AnimeNotifier { this.webpEnabled = canUseWebP() // Initiate the elements we need - this.user = this.app.find("user") - this.app.content = this.app.find("content") - this.app.loading = this.app.find("loading") + this.user = document.getElementById("user") + this.app.content = document.getElementById("content") + this.app.loading = document.getElementById("loading") // Theme if(this.user && this.user.dataset.pro === "true" && this.user.dataset.theme !== "light") { @@ -113,8 +113,8 @@ export default class AnimeNotifier { // Status message this.statusMessage = new StatusMessage( - this.app.find("status-message"), - this.app.find("status-message-text") + document.getElementById("status-message"), + document.getElementById("status-message-text") ) // Push manager @@ -130,7 +130,7 @@ export default class AnimeNotifier { this.analytics = new Analytics() // Sidebar control - this.sideBar = new SideBar(this.app.find("sidebar")) + this.sideBar = new SideBar(document.getElementById("sidebar")) // Infinite scrolling this.infiniteScroller = new InfiniteScroller(this.app.content.parentElement, 150) @@ -205,7 +205,7 @@ export default class AnimeNotifier { // document.body.appendChild(titleList) - // let search = this.app.find("search") as HTMLInputElement + // let search = document.getElementById("search") as HTMLInputElement // search.setAttribute("list", titleList.id) } @@ -314,9 +314,9 @@ export default class AnimeNotifier { return } - let enableButton = this.app.find("enable-notifications") as HTMLButtonElement - let disableButton = this.app.find("disable-notifications") as HTMLButtonElement - let testButton = this.app.find("test-notification") as HTMLButtonElement + let enableButton = document.getElementById("enable-notifications") as HTMLButtonElement + let disableButton = document.getElementById("disable-notifications") as HTMLButtonElement + let testButton = document.getElementById("test-notification") as HTMLButtonElement if(!this.pushManager.pushSupported) { enableButton.classList.add("hidden") @@ -912,7 +912,7 @@ export default class AnimeNotifier { // "F" = Search if(e.keyCode === 70) { - let search = this.app.find("search") as HTMLInputElement + let search = document.getElementById("search") as HTMLInputElement search.focus() search.select() diff --git a/scripts/Application.ts b/scripts/Application.ts index e3ab41d8..0b11ea1d 100644 --- a/scripts/Application.ts +++ b/scripts/Application.ts @@ -30,10 +30,6 @@ export default class Application { }) } - find(id: string): HTMLElement | null { - return document.getElementById(id) - } - get(url: string): Promise { // return fetch(url, { // credentials: "same-origin"