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 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
|
||||
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 {
|
||||
const caption = document.getElementById('cw');
|
||||
const checked = skipAll ? skipAll.checked : false;
|
||||
const curCw = document.getElementById('cw');
|
||||
const coverNew = cw != '' && !opened.has(id) && !skipAll.checked;
|
||||
|
||||
if (!checked && !opened.has(id) && cw) {
|
||||
const template = document.getElementById('cw-template') as HTMLTemplateElement;
|
||||
const newCaption = template.content.firstElementChild!.cloneNode(true) as HTMLElement;
|
||||
newCaption.querySelector('#cw-text')!.innerHTML = cw;
|
||||
if (curCw && !coverNew) {
|
||||
// keep old cover until load
|
||||
mainimg.addEventListener('load', () => openCW(null, curCw), {once: true});
|
||||
} 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);
|
||||
|
||||
mainfig.insertBefore(newCaption, mainlink);
|
||||
if (curCw) openCW(null, curCw);
|
||||
mainfig.insertBefore(newCw, mainlink);
|
||||
mainlink.tabIndex = -1;
|
||||
|
||||
addCWListeners(id, newCaption);
|
||||
} else {
|
||||
if (caption) openCW(null, caption);
|
||||
addCWListeners(id, newCw);
|
||||
}
|
||||
// else no cover before or after
|
||||
|
||||
mainimg.src = src;
|
||||
mainimg.src = src;
|
||||
mainlink.href = href;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue