parent
ff906f8b5e
commit
70e3e36244
2 changed files with 17 additions and 14 deletions
|
@ -62,7 +62,7 @@ make' root siteName prefix nsfw _dataDir dir
|
||||||
let updates = sort $ updatesFor nsfw info
|
let updates = sort $ updatesFor nsfw info
|
||||||
let updatesList = makeUpdates updates
|
let updatesList = makeUpdates updates
|
||||||
|
|
||||||
let makePrefetch img = [b|<link rel=preload as=image href=$path'>|]
|
let makePrefetch img = [b|<link rel=prefetch as=image href=$path'>|]
|
||||||
where path' = bigFile img
|
where path' = bigFile img
|
||||||
let prefetches = map makePrefetch otherImages
|
let prefetches = map makePrefetch otherImages
|
||||||
|
|
||||||
|
|
|
@ -22,25 +22,28 @@ function addCWListeners(id: string | null, caption: HTMLElement): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setImage(id: string, src: string, href: string, cw: string): void {
|
function setImage(id: string, src: string, href: string, cw: string): void {
|
||||||
const caption = document.getElementById('cw');
|
const curCw = document.getElementById('cw');
|
||||||
const checked = skipAll ? skipAll.checked : false;
|
const coverNew = cw != '' && !opened.has(id) && !skipAll.checked;
|
||||||
|
|
||||||
if (!checked && !opened.has(id) && cw) {
|
if (curCw && !coverNew) {
|
||||||
const template = document.getElementById('cw-template') as HTMLTemplateElement;
|
// keep old cover until load
|
||||||
const newCaption = template.content.firstElementChild!.cloneNode(true) as HTMLElement;
|
mainimg.addEventListener('load', () => openCW(null, curCw), {once: true});
|
||||||
newCaption.querySelector('#cw-text')!.innerHTML = cw;
|
} else if (coverNew) {
|
||||||
|
// place new cover
|
||||||
|
const newCw =
|
||||||
|
(document.getElementById('cw-template') as HTMLTemplateElement)
|
||||||
|
.content.firstElementChild!.cloneNode(true) as HTMLElement;
|
||||||
|
newCw.querySelector('#cw-text')!.innerHTML = cw;
|
||||||
|
|
||||||
if (caption) openCW(null, caption);
|
if (curCw) openCW(null, curCw);
|
||||||
|
mainfig.insertBefore(newCw, mainlink);
|
||||||
mainfig.insertBefore(newCaption, mainlink);
|
|
||||||
mainlink.tabIndex = -1;
|
mainlink.tabIndex = -1;
|
||||||
|
|
||||||
addCWListeners(id, newCaption);
|
addCWListeners(id, newCw);
|
||||||
} else {
|
|
||||||
if (caption) openCW(null, caption);
|
|
||||||
}
|
}
|
||||||
|
// else no cover before or after
|
||||||
|
|
||||||
mainimg.src = src;
|
mainimg.src = src;
|
||||||
mainlink.href = href;
|
mainlink.href = href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue