diff --git a/scripts/Actions/Activity.ts b/scripts/Actions/Activity.ts index a3f06325..93320d6a 100644 --- a/scripts/Actions/Activity.ts +++ b/scripts/Actions/Activity.ts @@ -3,4 +3,4 @@ import AnimeNotifier from "scripts/AnimeNotifier" // Reload content of current page export function reloadContent(arn: AnimeNotifier) { return arn.reloadContent() -} \ No newline at end of file +} diff --git a/scripts/Actions/Diff.ts b/scripts/Actions/Diff.ts index fa6dc820..95cf1976 100644 --- a/scripts/Actions/Diff.ts +++ b/scripts/Actions/Diff.ts @@ -30,4 +30,4 @@ export async function diff(arn: AnimeNotifier, element: HTMLElement) { } 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 63bffbba..2fc76e2e 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -67,4 +67,4 @@ export async function calendarShowAddedAnimeOnly(arn: AnimeNotifier, element: HT } 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 153dd92b..c8e22596 100644 --- a/scripts/Actions/Forum.ts +++ b/scripts/Actions/Forum.ts @@ -175,4 +175,4 @@ async function setThreadLock(arn: AnimeNotifier, element: HTMLButtonElement, sta } catch(err) { arn.statusMessage.showError(err) } -} \ No newline at end of file +} diff --git a/scripts/Actions/Group.ts b/scripts/Actions/Group.ts index 0c07f244..e2585e4e 100644 --- a/scripts/Actions/Group.ts +++ b/scripts/Actions/Group.ts @@ -32,4 +32,4 @@ export async function leave(arn: AnimeNotifier, element: HTMLElement) { } catch(err) { arn.statusMessage.showError(err) } -} \ No newline at end of file +} diff --git a/scripts/Actions/InfiniteScroller.ts b/scripts/Actions/InfiniteScroller.ts index 6fde07c9..eb6d4a4f 100644 --- a/scripts/Actions/InfiniteScroller.ts +++ b/scripts/Actions/InfiniteScroller.ts @@ -52,4 +52,4 @@ export async function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) { arn.loading(false) button.disabled = false } -} \ No newline at end of file +} diff --git a/scripts/Actions/Install.ts b/scripts/Actions/Install.ts index 7699aa2d..6ab15c56 100644 --- a/scripts/Actions/Install.ts +++ b/scripts/Actions/Install.ts @@ -1,4 +1,4 @@ // Desktop app installation export function installApp() { alert("Open your browser menu > 'Install Anime Notifier'.") -} \ No newline at end of file +} diff --git a/scripts/Actions/Like.ts b/scripts/Actions/Like.ts index fd063df0..6590d8de 100644 --- a/scripts/Actions/Like.ts +++ b/scripts/Actions/Like.ts @@ -24,4 +24,4 @@ export async function unlike(arn: AnimeNotifier, element: HTMLElement) { } catch(err) { arn.statusMessage.showError(err) } -} \ No newline at end of file +} diff --git a/scripts/Actions/Map.ts b/scripts/Actions/Map.ts index d4ace5d7..f4658415 100644 --- a/scripts/Actions/Map.ts +++ b/scripts/Actions/Map.ts @@ -32,4 +32,4 @@ // let chart = new window["google"].visualization.GeoChart(element) // console.log(element, data) // chart.draw(data, options) -// } \ No newline at end of file +// } diff --git a/scripts/Actions/Notifications.ts b/scripts/Actions/Notifications.ts index 86b0b9f3..09f932ed 100644 --- a/scripts/Actions/Notifications.ts +++ b/scripts/Actions/Notifications.ts @@ -41,4 +41,4 @@ export async function markNotificationsAsSeen(arn: AnimeNotifier) { // Update notifications arn.reloadContent() -} \ No newline at end of file +} diff --git a/scripts/Actions/Object.ts b/scripts/Actions/Object.ts index 37e72b46..e3e92f5c 100644 --- a/scripts/Actions/Object.ts +++ b/scripts/Actions/Object.ts @@ -52,4 +52,4 @@ export async function deleteObject(arn: AnimeNotifier, button: HTMLButtonElement } catch(err) { arn.statusMessage.showError(err) } -} \ No newline at end of file +} diff --git a/scripts/Actions/Publish.ts b/scripts/Actions/Publish.ts index 76e765c6..9b175b23 100644 --- a/scripts/Actions/Publish.ts +++ b/scripts/Actions/Publish.ts @@ -22,4 +22,4 @@ export async function unpublish(arn: AnimeNotifier, button: HTMLButtonElement) { } catch(err) { arn.statusMessage.showError(err) } -} \ No newline at end of file +} diff --git a/scripts/Actions/Serialization.ts b/scripts/Actions/Serialization.ts index 1f362d8d..41f8cabc 100644 --- a/scripts/Actions/Serialization.ts +++ b/scripts/Actions/Serialization.ts @@ -200,4 +200,4 @@ export function addNumber(arn: AnimeNotifier, element: HTMLElement) { input.value = newValue.toString() return save(arn, input) -} \ No newline at end of file +} diff --git a/scripts/Actions/Shop.ts b/scripts/Actions/Shop.ts index ccf6b0c1..0c3b9491 100644 --- a/scripts/Actions/Shop.ts +++ b/scripts/Actions/Shop.ts @@ -83,4 +83,4 @@ export function buyItem(arn: AnimeNotifier, button: HTMLElement) { .then(() => arn.statusMessage.showInfo(`You bought ${itemName} for ${price} gems. Check out your inventory to confirm the purchase.`, 4000)) .catch(err => arn.statusMessage.showError(err)) .then(() => arn.loading(false)) -} \ No newline at end of file +} diff --git a/scripts/Actions/SideBar.ts b/scripts/Actions/SideBar.ts index cb25d03a..01f3b700 100644 --- a/scripts/Actions/SideBar.ts +++ b/scripts/Actions/SideBar.ts @@ -4,4 +4,4 @@ import AnimeNotifier from "../AnimeNotifier" export function toggleSidebar(_: AnimeNotifier) { const sidebar = document.getElementById("sidebar") as HTMLElement sidebar.classList.toggle("sidebar-visible") -} \ No newline at end of file +} diff --git a/scripts/Actions/StatusMessage.ts b/scripts/Actions/StatusMessage.ts index 735e7ee0..bf03400a 100644 --- a/scripts/Actions/StatusMessage.ts +++ b/scripts/Actions/StatusMessage.ts @@ -3,4 +3,4 @@ import AnimeNotifier from "../AnimeNotifier" // Close status message export function closeStatusMessage(arn: AnimeNotifier) { arn.statusMessage.close() -} \ No newline at end of file +} diff --git a/scripts/Actions/Upload.ts b/scripts/Actions/Upload.ts index a311eeb9..b049a735 100644 --- a/scripts/Actions/Upload.ts +++ b/scripts/Actions/Upload.ts @@ -186,4 +186,4 @@ function updateSideBarAvatar(url: string) { } else { location.reload() } -} \ No newline at end of file +} diff --git a/scripts/Actions/User.ts b/scripts/Actions/User.ts index 82257739..d09c9725 100644 --- a/scripts/Actions/User.ts +++ b/scripts/Actions/User.ts @@ -39,4 +39,4 @@ export function showMore(_: AnimeNotifier, showMoreElement: HTMLElement) { } Diff.mutations.queue(() => showMoreElement.classList.add("show-more")) -} \ No newline at end of file +} diff --git a/scripts/Actions/Video.ts b/scripts/Actions/Video.ts index f6382d84..d872322e 100644 --- a/scripts/Actions/Video.ts +++ b/scripts/Actions/Video.ts @@ -64,4 +64,4 @@ export function toggleFullscreen(_: AnimeNotifier, button: HTMLElement) { } else { requestFullscreen.call(element) } -} \ No newline at end of file +} diff --git a/scripts/Actions/index.ts b/scripts/Actions/index.ts index dd88dde3..b75605c8 100644 --- a/scripts/Actions/index.ts +++ b/scripts/Actions/index.ts @@ -20,4 +20,4 @@ export * from "./SideBar" export * from "./StatusMessage" export * from "./Theme" export * from "./Upload" -export * from "./Video" \ No newline at end of file +export * from "./Video" diff --git a/scripts/Analytics.ts b/scripts/Analytics.ts index 3ccf92e7..30a2f53b 100644 --- a/scripts/Analytics.ts +++ b/scripts/Analytics.ts @@ -38,4 +38,4 @@ export default class Analytics { body: JSON.stringify(analytics) }) } -} \ No newline at end of file +} diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 6288b512..2cf10a81 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -310,18 +310,25 @@ export default class AnimeNotifier { // search.setAttribute("list", titleList.id) } - async onBeforeUnload(e: BeforeUnloadEvent) { - let message = "" + onBeforeUnload(e: BeforeUnloadEvent) { + if(this.app.currentPath !== "/new/thread") { + return + } + + if(!document.activeElement) { + return + } + + if(document.activeElement.tagName !== "TEXTAREA") { + return + } + + if((document.activeElement as HTMLTextAreaElement).value.length < 20) { + return + } // Prevent closing tab on new thread page - if(this.app.currentPath === "/new/thread" && document.activeElement && document.activeElement.tagName === "TEXTAREA" && (document.activeElement as HTMLTextAreaElement).value.length > 20) { - message = "You have unsaved changes on the current page. Are you sure you want to leave?" - } - - if(message) { - e.returnValue = message - return message - } + e.returnValue = "You have unsaved changes on the current page. Are you sure you want to leave?" } prepareTooltips(elements?: IterableIterator) { @@ -1156,7 +1163,7 @@ export default class AnimeNotifier { async diff(url: string) { if(url === this.app.currentPath) { - return null + return } const path = "/_" + url diff --git a/scripts/AudioPlayer.ts b/scripts/AudioPlayer.ts index 3ce2cddf..9467735d 100644 --- a/scripts/AudioPlayer.ts +++ b/scripts/AudioPlayer.ts @@ -326,4 +326,4 @@ export default class AudioPlayer { this.animeImage.classList.remove("hidden") this.animeImage["became visible"]() } -} \ No newline at end of file +} diff --git a/scripts/DateView.ts b/scripts/DateView.ts index 845ea42d..2ebe9614 100644 --- a/scripts/DateView.ts +++ b/scripts/DateView.ts @@ -146,4 +146,4 @@ export function displayTime(element: HTMLElement) { const startTime = (h <= 9 ? "0" + h : h) + ":" + (m <= 9 ? "0" + m : m) element.textContent = startTime -} \ No newline at end of file +} diff --git a/scripts/Diff.ts b/scripts/Diff.ts index 44ef8680..63a00995 100644 --- a/scripts/Diff.ts +++ b/scripts/Diff.ts @@ -156,4 +156,4 @@ export default class Diff { Diff.childNodes(a, b) } } -} \ No newline at end of file +} diff --git a/scripts/Elements/svg-icon/svg-icon.ts b/scripts/Elements/svg-icon/svg-icon.ts index 539ff9e1..2ff1033f 100644 --- a/scripts/Elements/svg-icon/svg-icon.ts +++ b/scripts/Elements/svg-icon/svg-icon.ts @@ -65,4 +65,4 @@ export default class SVGIcon extends HTMLElement { set name(value: string) { this.setAttribute("name", value) } -} \ No newline at end of file +} diff --git a/scripts/Elements/tool-tip/tool-tip.ts b/scripts/Elements/tool-tip/tool-tip.ts index cc9ee041..53148b2c 100644 --- a/scripts/Elements/tool-tip/tool-tip.ts +++ b/scripts/Elements/tool-tip/tool-tip.ts @@ -63,4 +63,4 @@ export default class ToolTip extends HTMLElement { this.setAttribute("active", "true") }) } -} \ No newline at end of file +} diff --git a/scripts/InfiniteScroller.ts b/scripts/InfiniteScroller.ts index 61c8d21f..672010e1 100644 --- a/scripts/InfiniteScroller.ts +++ b/scripts/InfiniteScroller.ts @@ -36,4 +36,4 @@ export default class InfiniteScroller { button.click() } -} \ No newline at end of file +} diff --git a/scripts/MutationQueue.ts b/scripts/MutationQueue.ts index 79cbcccc..7e4992e4 100644 --- a/scripts/MutationQueue.ts +++ b/scripts/MutationQueue.ts @@ -65,4 +65,4 @@ export default class MutationQueue { this.onClearCallBacks.push(callBack) } -} \ No newline at end of file +} diff --git a/scripts/NotificationManager.ts b/scripts/NotificationManager.ts index 15ec7173..971fd452 100644 --- a/scripts/NotificationManager.ts +++ b/scripts/NotificationManager.ts @@ -46,4 +46,4 @@ export default class NotificationManager { } }) } -} \ No newline at end of file +} diff --git a/scripts/PushManager.ts b/scripts/PushManager.ts index 383ea44d..886bb443 100644 --- a/scripts/PushManager.ts +++ b/scripts/PushManager.ts @@ -108,4 +108,4 @@ function urlBase64ToUint8Array(base64String: string) { const rawData = window.atob(base64) return Uint8Array.from([...rawData].map(char => char.charCodeAt(0))) -} \ No newline at end of file +} diff --git a/scripts/ServerEvents.ts b/scripts/ServerEvents.ts index a04e48f7..c7bf40a7 100644 --- a/scripts/ServerEvents.ts +++ b/scripts/ServerEvents.ts @@ -97,4 +97,4 @@ export default class ServerEvents { this.arn.notificationManager.setCounter(parseInt(e.data)) } -} \ No newline at end of file +} diff --git a/scripts/ServiceWorker/old/old.MyClient.ts b/scripts/ServiceWorker/old/old.MyClient.ts index 34c599c3..7e39a026 100644 --- a/scripts/ServiceWorker/old/old.MyClient.ts +++ b/scripts/ServiceWorker/old/old.MyClient.ts @@ -96,4 +96,4 @@ // return this.postMessage({ // type: "reload styles" // }) -// } \ No newline at end of file +// } diff --git a/scripts/ServiceWorker/old/old.onRequest.ts b/scripts/ServiceWorker/old/old.onRequest.ts index 13722476..019a8af4 100644 --- a/scripts/ServiceWorker/old/old.onRequest.ts +++ b/scripts/ServiceWorker/old/old.onRequest.ts @@ -66,4 +66,4 @@ // return evt.respondWith(this.networkFirst(request, network, onResponse)) // } -// return evt.respondWith(this.cacheFirst(request, network, onResponse)) \ No newline at end of file +// return evt.respondWith(this.cacheFirst(request, network, onResponse)) diff --git a/scripts/ServiceWorkerManager.ts b/scripts/ServiceWorkerManager.ts index 5d7184a7..1521895e 100644 --- a/scripts/ServiceWorkerManager.ts +++ b/scripts/ServiceWorkerManager.ts @@ -101,4 +101,4 @@ export default class ServiceWorkerManager { // break } } -} \ No newline at end of file +} diff --git a/scripts/SideBar.ts b/scripts/SideBar.ts index 7fb6df80..cae1db01 100644 --- a/scripts/SideBar.ts +++ b/scripts/SideBar.ts @@ -38,4 +38,4 @@ export default class SideBar { this.element.style.display = "flex" } } -} \ No newline at end of file +} diff --git a/scripts/Types/Anime.d.ts b/scripts/Types/Anime.d.ts index 1cdf1e71..0699aa92 100644 --- a/scripts/Types/Anime.d.ts +++ b/scripts/Types/Anime.d.ts @@ -82,4 +82,4 @@ export interface Anime { createdBy: string; edited: string; editedBy: string; -} \ No newline at end of file +} diff --git a/scripts/Utils/bytesHumanReadable.ts b/scripts/Utils/bytesHumanReadable.ts index 554dc495..2e537aa6 100644 --- a/scripts/Utils/bytesHumanReadable.ts +++ b/scripts/Utils/bytesHumanReadable.ts @@ -12,4 +12,4 @@ export function bytesHumanReadable(fileSize: number): string { } return `${fileSize.toFixed(0)} ${unit}` -} \ No newline at end of file +} diff --git a/scripts/Utils/delay.ts b/scripts/Utils/delay.ts index 3098be3e..7e411f7c 100644 --- a/scripts/Utils/delay.ts +++ b/scripts/Utils/delay.ts @@ -1,3 +1,3 @@ export function delay(millis: number, value?: T): Promise { return new Promise(resolve => setTimeout(() => resolve(value), millis)) -} \ No newline at end of file +} diff --git a/scripts/Utils/index.ts b/scripts/Utils/index.ts index 02a729b0..9184981a 100644 --- a/scripts/Utils/index.ts +++ b/scripts/Utils/index.ts @@ -6,4 +6,4 @@ export * from "./plural" export * from "./requestIdleCallback" export * from "./swapElements" export * from "./uploadWithProgress" -export * from "./bytesHumanReadable" \ No newline at end of file +export * from "./bytesHumanReadable" diff --git a/scripts/Utils/plural.ts b/scripts/Utils/plural.ts index f52a45f6..59996c1a 100644 --- a/scripts/Utils/plural.ts +++ b/scripts/Utils/plural.ts @@ -12,4 +12,4 @@ export function plural(count: number, singular: string): string { } return count + " " + singular + "s" -} \ No newline at end of file +} diff --git a/scripts/Utils/requestIdleCallback.ts b/scripts/Utils/requestIdleCallback.ts index 5b7ede59..7bddd7e0 100644 --- a/scripts/Utils/requestIdleCallback.ts +++ b/scripts/Utils/requestIdleCallback.ts @@ -4,4 +4,4 @@ export function requestIdleCallback(func: Function) { } else { func() } -} \ No newline at end of file +} diff --git a/scripts/Utils/supportsWebP.ts b/scripts/Utils/supportsWebP.ts index 978536fb..47c22414 100644 --- a/scripts/Utils/supportsWebP.ts +++ b/scripts/Utils/supportsWebP.ts @@ -6,4 +6,4 @@ export async function supportsWebP(): Promise { const data = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=" const blob = await fetch(data).then(r => r.blob()) return createImageBitmap(blob).then(() => true, () => false) -} \ No newline at end of file +} diff --git a/scripts/Utils/swapElements.ts b/scripts/Utils/swapElements.ts index ccaefe71..eb80ad6f 100644 --- a/scripts/Utils/swapElements.ts +++ b/scripts/Utils/swapElements.ts @@ -20,4 +20,4 @@ export function swapElements(a: Node, b: Node) { bParent.appendChild(a) } } -} \ No newline at end of file +} diff --git a/scripts/VideoPlayer.ts b/scripts/VideoPlayer.ts index 8bf644c2..7cc62d21 100644 --- a/scripts/VideoPlayer.ts +++ b/scripts/VideoPlayer.ts @@ -14,4 +14,4 @@ export default class VideoPlayer { playPause() { } -} \ No newline at end of file +} diff --git a/scripts/WebComponents.ts b/scripts/WebComponents.ts index f3b529c6..0bfca7da 100644 --- a/scripts/WebComponents.ts +++ b/scripts/WebComponents.ts @@ -17,4 +17,4 @@ export function register() { for(const [tag, definition] of elements.entries()) { window.customElements.define(tag, definition) } -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 81bdf9e3..a7d01470 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,9 @@ "strict": false, "strictFunctionTypes": false, "strictNullChecks": true, + "noImplicitReturns": true, "noUnusedLocals": true, - "noUnusedParameters": true + "noUnusedParameters": true, + "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} diff --git a/tslint.json b/tslint.json index a9121ecb..6896fb07 100644 --- a/tslint.json +++ b/tslint.json @@ -11,7 +11,8 @@ "arrow-parens": false, "trailing-comma": false, "prefer-const": true, - "no-var-keyword": true + "no-var-keyword": true, + "eofline": true }, "rulesDirectory": [] }