47 lines
847 B
TypeScript
Raw Normal View History

2017-06-19 14:49:24 +00:00
import { Application } from "./Application"
export class AnimeNotifier {
app: Application
constructor(app: Application) {
this.app = app
}
2017-06-19 15:45:27 +00:00
onReadyStateChange() {
if(document.readyState !== "interactive") {
return
}
this.run()
}
2017-06-19 14:49:24 +00:00
run() {
this.app.content = this.app.find("content")
this.app.loading = this.app.find("loading")
this.app.run()
}
2017-06-19 15:45:27 +00:00
onContentLoaded() {
this.updateAvatars()
}
updateAvatars() {
let images = document.querySelectorAll('.user-image')
for(let i = 0; i < images.length; ++i) {
let img = images[i] as HTMLImageElement
if(img.naturalWidth === 0) {
img.onload = function() {
this.classList.add("user-image-found")
}
img.onerror = function() {
this.classList.add("user-image-not-found")
}
} else {
img.classList.add("user-image-found")
}
}
}
2017-06-19 14:49:24 +00:00
}