From 273d876758d5af8f1b2a6650bb410323d79cdf95 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 15 Jul 2017 20:18:24 +0200 Subject: [PATCH] Improved iframe diff --- pages/profile/stats.go | 4 +++- scripts/Diff.ts | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pages/profile/stats.go b/pages/profile/stats.go index 05b79b81..0a28bbef 100644 --- a/pages/profile/stats.go +++ b/pages/profile/stats.go @@ -35,7 +35,9 @@ func GetStatsByUser(ctx *aero.Context) string { } for _, item := range animeList.Items { - duration := time.Duration(item.Episodes * item.Anime().EpisodeLength) + currentWatch := item.Episodes * item.Anime().EpisodeLength + reWatch := item.RewatchCount * item.Anime().EpisodeCount * item.Anime().EpisodeLength + duration := time.Duration(currentWatch + reWatch) userStats.AnimeWatchingTime += duration * time.Minute ratings[strconv.Itoa(int(item.Rating.Overall+0.5))]++ diff --git a/scripts/Diff.ts b/scripts/Diff.ts index 051aa55a..b1fe5318 100644 --- a/scripts/Diff.ts +++ b/scripts/Diff.ts @@ -47,15 +47,19 @@ export class Diff { let elemA = a as HTMLElement let elemB = b as HTMLElement - // Skip iframes - if(elemA.tagName === "IFRAME") { + // Ignore lazy images if they have the same source + if(elemA.classList.contains("lazy")) { + if(elemA.dataset.src !== elemB.dataset.src) { + elemA.dataset.src = elemB.dataset.src + elemA.title = elemB.title + } continue } - // Ignore lazy images if they have the same source - if(elemA.classList.contains("lazy")) { - elemA.dataset.src = elemB.dataset.src - elemA.title = elemB.title + // Skip iframes + // This part needs to be executed AFTER lazy images check + // to allow lazily loaded iframes to update their data src. + if(elemA.tagName === "IFRAME") { continue }