From 08b700bb14e5e12c1dff283e2eef729816a97f15 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Jun 2022 20:57:06 -0300 Subject: lots of fixes from eslint --- src/static/client.js | 41 +++-------------------------------------- src/static/lazy-loading.js | 5 +++-- 2 files changed, 6 insertions(+), 40 deletions(-) (limited to 'src/static') diff --git a/src/static/client.js b/src/static/client.js index 8342eb15..1ffcb939 100644 --- a/src/static/client.js +++ b/src/static/client.js @@ -11,8 +11,8 @@ import {getColors} from '../util/colors.js'; import {getArtistNumContributions} from '../util/wiki-data.js'; -let albumData, artistData, flashData; -let officialAlbumData, fandomAlbumData, artistNames; +let albumData, artistData; +let officialAlbumData, fandomAlbumData; let ready = false; @@ -73,43 +73,12 @@ function getAlbum(el) { return albumData.find((album) => album.directory === directory); } -function getFlash(el) { - const directory = cssProp(el, '--flash-directory'); - return flashData.find((flash) => flash.directory === directory); -} - // TODO: These should pro8a8ly access some shared urlSpec path. We'd need to // separ8te the tooling around that into common-shared code too. const getLinkHref = (type, directory) => rebase(`${type}/${directory}`); const openAlbum = (d) => rebase(`album/${d}`); const openTrack = (d) => rebase(`track/${d}`); const openArtist = (d) => rebase(`artist/${d}`); -const openFlash = (d) => rebase(`flash/${d}`); - -function getTrackListAndIndex() { - const album = getAlbum(document.body); - const directory = cssProp(document.body, '--track-directory'); - if (!directory && !album) return {}; - if (!directory) return {list: album.tracks}; - const trackIndex = album.tracks.findIndex( - (track) => track.directory === directory - ); - return {list: album.tracks, index: trackIndex}; -} - -function openRandomTrack() { - const {list} = getTrackListAndIndex(); - if (!list) return; - return openTrack(pick(list)); -} - -function getFlashListAndIndex() { - const list = flashData.filter((flash) => !flash.act8r8k); - const flash = getFlash(document.body); - if (!flash) return {list}; - const flashIndex = list.indexOf(flash); - return {list, index: flashIndex}; -} // TODO: This should also use urlSpec. function fetchData(type, directory) { @@ -230,7 +199,6 @@ fetch(rebase('data.json', 'rebaseShared')) .then((data) => { albumData = data.albumData; artistData = data.artistData; - flashData = data.flashData; officialAlbumData = albumData.filter((album) => album.groups.includes('group:official') @@ -238,9 +206,6 @@ fetch(rebase('data.json', 'rebaseShared')) fandomAlbumData = albumData.filter( (album) => !album.groups.includes('group:official') ); - artistNames = artistData - .filter((artist) => !artist.alias) - .map((artist) => artist.name); for (const element of elements1) element.style.display = 'none'; for (const element of elements2) element.style.display = 'block'; @@ -436,7 +401,7 @@ function makeInfoCardLinkHandlers(type) { infoCard.cancelHide(); }, - mouseleave(evt) { + mouseleave() { clearTimeout(hoverTimeout); if (fastHover && !endFastHoverTimeout) { diff --git a/src/static/lazy-loading.js b/src/static/lazy-loading.js index 8f3e8cf5..1b779d26 100644 --- a/src/static/lazy-loading.js +++ b/src/static/lazy-loading.js @@ -33,16 +33,17 @@ function lazyLoadMain() { } var lazyElements = document.getElementsByClassName('lazy'); + var i; if (window.IntersectionObserver) { observer = new IntersectionObserver(lazyLoad, { rootMargin: '200px', threshold: 1.0, }); - for (var i = 0; i < lazyElements.length; i++) { + for (i = 0; i < lazyElements.length; i++) { observer.observe(lazyElements[i]); } } else { - for (var i = 0; i < lazyElements.length; i++) { + for (i = 0; i < lazyElements.length; i++) { var element = lazyElements[i]; var original = element.getAttribute('data-original'); element.setAttribute('src', original); -- cgit 1.3.0-6-gf8a5