Replace innerText with textContent

This commit is contained in:
Eduard Urbach 2018-06-28 15:30:24 +09:00
parent 00678cf6a4
commit 050355d8ae
9 changed files with 26 additions and 25 deletions

View File

@ -26,7 +26,7 @@ export function removeAnimeFromCollection(arn: AnimeNotifier, button: HTMLElemen
return return
} }
button.innerText = "Removing..." button.textContent = "Removing..."
let {animeId, nick} = button.dataset let {animeId, nick} = button.dataset
let apiEndpoint = arn.findAPIEndpoint(button) let apiEndpoint = arn.findAPIEndpoint(button)

View File

@ -4,7 +4,7 @@ import AnimeNotifier from "../AnimeNotifier"
export function followUser(arn: AnimeNotifier, elem: HTMLElement) { export function followUser(arn: AnimeNotifier, elem: HTMLElement) {
return arn.post(elem.dataset.api) return arn.post(elem.dataset.api)
.then(() => arn.reloadContent()) .then(() => arn.reloadContent())
.then(() => arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").innerText + ".")) .then(() => arn.statusMessage.showInfo("You are now following " + document.getElementById("nick").textContent + "."))
.catch(err => arn.statusMessage.showError(err)) .catch(err => arn.statusMessage.showError(err))
} }
@ -12,6 +12,6 @@ export function followUser(arn: AnimeNotifier, elem: HTMLElement) {
export function unfollowUser(arn: AnimeNotifier, elem: HTMLElement) { export function unfollowUser(arn: AnimeNotifier, elem: HTMLElement) {
return arn.post(elem.dataset.api) return arn.post(elem.dataset.api)
.then(() => arn.reloadContent()) .then(() => arn.reloadContent())
.then(() => arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").innerText + ".")) .then(() => arn.statusMessage.showInfo("You stopped following " + document.getElementById("nick").textContent + "."))
.catch(err => arn.statusMessage.showError(err)) .catch(err => arn.statusMessage.showError(err))
} }

View File

@ -112,7 +112,7 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
searchPageTitle = document.getElementsByTagName("h1")[0] searchPageTitle = document.getElementsByTagName("h1")[0]
} }
searchPageTitle.innerText = document.title searchPageTitle.textContent = document.title
if(!term || term.length < 1) { if(!term || term.length < 1) {
await arn.innerHTML(searchPage, emptySearchHTML) await arn.innerHTML(searchPage, emptySearchHTML)

View File

@ -4,7 +4,7 @@ import AnimeNotifier from "../AnimeNotifier"
export async function save(arn: AnimeNotifier, input: HTMLElement) { export async function save(arn: AnimeNotifier, input: HTMLElement) {
let obj = {} let obj = {}
let isContentEditable = input.isContentEditable let isContentEditable = input.isContentEditable
let value = isContentEditable ? input.innerText : (input as HTMLInputElement).value let value = isContentEditable ? input.textContent : (input as HTMLInputElement).value
if(value === undefined) { if(value === undefined) {
return return
@ -134,8 +134,8 @@ export function increaseEpisode(arn: AnimeNotifier, element: HTMLElement) {
} }
let prev = element.previousSibling as HTMLElement let prev = element.previousSibling as HTMLElement
let episodes = parseInt(prev.innerText) let episodes = parseInt(prev.textContent)
prev.innerText = String(episodes + 1) prev.textContent = String(episodes + 1)
save(arn, prev) save(arn, prev)
} }

View File

@ -168,14 +168,18 @@ export default class AnimeNotifier {
]) ])
// Apply page title // Apply page title
this.applyPageTitle()
}
applyPageTitle() {
let headers = document.getElementsByTagName("h1") let headers = document.getElementsByTagName("h1")
if(this.app.currentPath === "/" || headers.length === 0 || headers[0].innerText === "NOTIFY.MOE") { if(this.app.currentPath === "/" || headers.length === 0 || headers[0].textContent === "NOTIFY.MOE") {
if(document.title !== this.title) { if(document.title !== this.title) {
document.title = this.title document.title = this.title
} }
} else { } else {
document.title = headers[0].innerText document.title = headers[0].textContent
} }
} }
@ -445,11 +449,11 @@ export default class AnimeNotifier {
} }
for(let element of findAll("count-up")) { for(let element of findAll("count-up")) {
let final = parseInt(element.innerText) let final = parseInt(element.textContent)
let duration = 2000.0 let duration = 2000.0
let start = Date.now() let start = Date.now()
element.innerText = "0" element.textContent = "0"
let callback = () => { let callback = () => {
let progress = (Date.now() - start) / duration let progress = (Date.now() - start) / duration
@ -458,7 +462,7 @@ export default class AnimeNotifier {
progress = 1 progress = 1
} }
element.innerText = String(Math.round(progress * final)) element.textContent = String(Math.round(progress * final))
if(progress < 1) { if(progress < 1) {
window.requestAnimationFrame(callback) window.requestAnimationFrame(callback)
@ -917,12 +921,9 @@ export default class AnimeNotifier {
scrollTo(target: HTMLElement) { scrollTo(target: HTMLElement) {
const duration = 250.0 const duration = 250.0
const steps = 60
const interval = duration / steps
const fullSin = Math.PI / 2 const fullSin = Math.PI / 2
const contentPadding = 24 const contentPadding = 24
let scrollHandle: number
let newScroll = 0 let newScroll = 0
let finalScroll = Math.max(target.offsetTop - contentPadding, 0) let finalScroll = Math.max(target.offsetTop - contentPadding, 0)

View File

@ -201,7 +201,7 @@ export default class AudioPlayer {
// Remove title // Remove title
this.trackLink.href = "" this.trackLink.href = ""
this.trackLink.innerText = "" this.trackLink.textContent = ""
// Hide anime info // Hide anime info
this.animeLink.href = "" this.animeLink.href = ""
@ -287,7 +287,7 @@ export default class AudioPlayer {
let trackInfoResponse = await fetch("/api/soundtrack/" + trackId) let trackInfoResponse = await fetch("/api/soundtrack/" + trackId)
let track = await trackInfoResponse.json() let track = await trackInfoResponse.json()
this.trackLink.href = "/soundtrack/" + track.id this.trackLink.href = "/soundtrack/" + track.id
this.trackLink.innerText = track.title.canonical || track.title.native this.trackLink.textContent = track.title.canonical || track.title.native
let animeId = "" let animeId = ""

View File

@ -61,7 +61,7 @@ function getRemainingTime(remaining: number): string {
export function displayAiringDate(element: HTMLElement, now: Date) { export function displayAiringDate(element: HTMLElement, now: Date) {
if(element.dataset.startDate === "") { if(element.dataset.startDate === "") {
element.innerText = "" element.textContent = ""
return return
} }
@ -86,7 +86,7 @@ export function displayAiringDate(element: HTMLElement, now: Date) {
remainingString = remainingString.substring(1) + " ago" remainingString = remainingString.substring(1) + " ago"
} }
element.innerText = remainingString element.textContent = remainingString
if(remaining < 0) { if(remaining < 0) {
airingVerb = "aired" airingVerb = "aired"
@ -104,7 +104,7 @@ export function displayAiringDate(element: HTMLElement, now: Date) {
export function displayDate(element: HTMLElement, now: Date) { export function displayDate(element: HTMLElement, now: Date) {
if(element.dataset.date === "") { if(element.dataset.date === "") {
element.innerText = "" element.textContent = ""
return return
} }
@ -122,7 +122,7 @@ export function displayDate(element: HTMLElement, now: Date) {
remainingString = remainingString.substring(1) + " ago" remainingString = remainingString.substring(1) + " ago"
} }
element.innerText = remainingString element.textContent = remainingString
let tooltip = dayNames[startDate.getDay()] + " " + startTime let tooltip = dayNames[startDate.getDay()] + " " + startTime
if(element.classList.contains("no-tip")) { if(element.classList.contains("no-tip")) {
@ -135,7 +135,7 @@ export function displayDate(element: HTMLElement, now: Date) {
export function displayTime(element: HTMLElement, now: Date) { export function displayTime(element: HTMLElement, now: Date) {
if(element.dataset.date === "") { if(element.dataset.date === "") {
element.innerText = "" element.textContent = ""
return return
} }
@ -145,5 +145,5 @@ export function displayTime(element: HTMLElement, now: Date) {
let m = startDate.getMinutes() let m = startDate.getMinutes()
let startTime = (h <= 9 ? "0" + h : h) + ":" + (m <= 9 ? "0" + m : m) let startTime = (h <= 9 ? "0" + h : h) + ":" + (m <= 9 ? "0" + m : m)
element.innerText = startTime element.textContent = startTime
} }

View File

@ -27,7 +27,7 @@ export default class NotificationManager {
render() { render() {
Diff.mutations.queue(() => { Diff.mutations.queue(() => {
this.counter.innerText = this.unseen.toString() this.counter.textContent = this.unseen.toString()
if(this.unseen === 0) { if(this.unseen === 0) {
this.counter.classList.add("hidden") this.counter.classList.add("hidden")

View File

@ -12,7 +12,7 @@ export default class StatusMessage {
show(message: string, duration: number) { show(message: string, duration: number) {
let messageId = String(Date.now()) let messageId = String(Date.now())
this.text.innerText = message this.text.textContent = message
this.container.classList.remove("fade-out") this.container.classList.remove("fade-out")
this.container.dataset.messageId = messageId this.container.dataset.messageId = messageId