Refactor scripts
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import requestIdleCallback from "scripts/Utils/requestIdleCallback"
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { requestIdleCallback } from "../Utils"
|
||||
|
||||
// Load
|
||||
export function load(arn: AnimeNotifier, element: HTMLElement) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import emptyPixel from "scripts/Utils/emptyPixel"
|
||||
import findAll from "scripts/Utils/findAll"
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { findAll } from "scripts/Utils"
|
||||
|
||||
// Filter anime on explore page
|
||||
export function filterAnime(arn: AnimeNotifier, _: HTMLInputElement) {
|
||||
@ -12,7 +13,7 @@ export function filterAnime(arn: AnimeNotifier, _: HTMLInputElement) {
|
||||
|
||||
for(const element of findAll("anime-grid-image")) {
|
||||
const img = element as HTMLImageElement
|
||||
img.src = arn.emptyPixel()
|
||||
img.src = emptyPixel
|
||||
img.classList.remove("element-found")
|
||||
img.classList.remove("element-color-preview")
|
||||
}
|
||||
|
@ -2,24 +2,24 @@ import AnimeNotifier from "../AnimeNotifier"
|
||||
|
||||
// Enable notifications
|
||||
export async function enableNotifications(arn: AnimeNotifier, _: HTMLElement) {
|
||||
if(!arn.user || !arn.user.dataset.id) {
|
||||
if(!arn.user) {
|
||||
return
|
||||
}
|
||||
|
||||
arn.statusMessage.showInfo("Enabling instant notifications...")
|
||||
await arn.pushManager.subscribe(arn.user.dataset.id)
|
||||
await arn.pushManager.subscribe(arn.user.id)
|
||||
arn.updatePushUI()
|
||||
arn.statusMessage.showInfo("Enabled instant notifications for this device.")
|
||||
}
|
||||
|
||||
// Disable notifications
|
||||
export async function disableNotifications(arn: AnimeNotifier, _: HTMLElement) {
|
||||
if(!arn.user || !arn.user.dataset.id) {
|
||||
if(!arn.user) {
|
||||
return
|
||||
}
|
||||
|
||||
arn.statusMessage.showInfo("Disabling instant notifications...")
|
||||
await arn.pushManager.unsubscribe(arn.user.dataset.id)
|
||||
await arn.pushManager.unsubscribe(arn.user.id)
|
||||
arn.updatePushUI()
|
||||
arn.statusMessage.showInfo("Disabled instant notifications for this device.")
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Diff from "scripts/Diff"
|
||||
import delay from "scripts/Utils/delay"
|
||||
import requestIdleCallback from "scripts/Utils/requestIdleCallback"
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { delay, requestIdleCallback } from "../Utils"
|
||||
import Diff from "scripts/Diff";
|
||||
|
||||
// Search page reference
|
||||
let emptySearchHTML = ""
|
||||
@ -111,7 +112,7 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
|
||||
searchPageTitle.textContent = document.title
|
||||
|
||||
if(!term || term.length < 1) {
|
||||
await arn.innerHTML(searchPage, emptySearchHTML)
|
||||
await Diff.innerHTML(searchPage, emptySearchHTML)
|
||||
arn.app.emit("DOMContentLoaded")
|
||||
return
|
||||
}
|
||||
@ -168,7 +169,7 @@ function showResponseInElement(arn: AnimeNotifier, url: string, typeName: string
|
||||
correctResponseRendered[typeName] = true
|
||||
}
|
||||
|
||||
await arn.innerHTML(element, html)
|
||||
await Diff.innerHTML(element, html)
|
||||
arn.onNewContent(element)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import hexToHSL from "scripts/Utils/hexToHSL"
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { hexToHSL } from "scripts/Utils"
|
||||
|
||||
let currentThemeName = "light"
|
||||
let previewTimeoutID: number = 0
|
||||
@ -7,8 +7,8 @@ let previewTimeoutID: number = 0
|
||||
// let themeWheelTimeoutID: number = 0
|
||||
|
||||
const themes = {
|
||||
"light": {},
|
||||
"dark": {
|
||||
light: {},
|
||||
dark: {
|
||||
"link-color-h": "45",
|
||||
"link-color-s": "100%",
|
||||
"link-color-l": "66%",
|
||||
@ -117,7 +117,7 @@ export function applyThemeAndPreview(arn: AnimeNotifier, themeName: string) {
|
||||
clearTimeout(previewTimeoutID)
|
||||
|
||||
// If it's the free light theme or a PRO user, nothing to do here
|
||||
if(currentThemeName === "light" || (arn.user && arn.user.dataset.pro == "true")) {
|
||||
if(currentThemeName === "light" || (arn.user && arn.user.IsPro())) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import bytesHumanReadable from "scripts/Utils/bytesHumanReadable"
|
||||
import uploadWithProgress from "scripts/Utils/uploadWithProgress"
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { bytesHumanReadable, uploadWithProgress } from "../Utils"
|
||||
|
||||
// Select file
|
||||
export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
const fileType = button.dataset.type
|
||||
const endpoint = button.dataset.endpoint
|
||||
|
||||
if(endpoint === "/api/upload/user/cover" && arn.user && arn.user.dataset.pro !== "true") {
|
||||
if(endpoint === "/api/upload/user/cover" && arn.user && !arn.user.IsPro()) {
|
||||
alert("Please buy a PRO account to use this feature.")
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user