Improved diff

This commit is contained in:
Eduard Urbach 2017-07-19 04:47:32 +02:00
parent 406306df37
commit 647aed0e76
3 changed files with 27 additions and 21 deletions

View File

@ -43,8 +43,8 @@ component AnimeList(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User
td.anime-list-item-name
a.ajax(href=item.Link(animeList.User().Nick))= item.Anime().Title.Canonical
if user != nil && item.Status == arn.AnimeListStatusWatching && item.Anime().EpisodeByNumber(item.Episodes + 1) != nil
td.anime-list-item-actions
td.anime-list-item-actions
if user != nil && item.Status == arn.AnimeListStatusWatching && item.Anime().EpisodeByNumber(item.Episodes + 1) != nil
for _, link := range item.Anime().EpisodeByNumber(item.Episodes + 1).Links
a(href=link, title="Watch episode " + toString(item.Episodes + 1) + " on twist.moe", target="_blank", rel="noopener")
RawIcon("eye")

View File

@ -152,7 +152,7 @@ export class Application {
for(let i = 0; i < links.length; i++) {
let link = links[i] as HTMLElement
link.classList.remove(this.ajaxClass)
// link.classList.remove(this.ajaxClass)
let self = this
link.onclick = function(e) {

View File

@ -82,29 +82,35 @@ export class Diff {
for(let x = 0; x < elemB.attributes.length; x++) {
let attrib = elemB.attributes[x]
if(attrib.specified) {
// Skip mountables
if(attrib.name == "class") {
let classesA = elemA.classList
let classesB = elemB.classList
for(let className of classesA) {
if(!classesB.contains(className) && !Diff.persistentClasses.has(className)) {
classesA.remove(className)
}
}
for(let className of classesB) {
if(!classesA.contains(className)) {
classesA.add(className)
}
}
if(!attrib.specified) {
continue
}
if(attrib.name === "class") {
// If the class is exactly the same, skip this attribute.
if(elemA.getAttribute("class") === attrib.value) {
continue
}
elemA.setAttribute(attrib.name, elemB.getAttribute(attrib.name))
let classesA = elemA.classList
let classesB = elemB.classList
for(let className of classesA) {
if(!classesB.contains(className) && !Diff.persistentClasses.has(className)) {
classesA.remove(className)
}
}
for(let className of classesB) {
if(!classesA.contains(className)) {
classesA.add(className)
}
}
continue
}
elemA.setAttribute(attrib.name, elemB.getAttribute(attrib.name))
}
// Special case: Apply state of input elements