1
Fork 0

Fix linting issues.

This commit is contained in:
Bauke 2023-01-09 16:09:00 +01:00
parent 774e1411bb
commit 6e1a953d63
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
7 changed files with 35 additions and 24 deletions

View File

@ -1,4 +1,6 @@
window.addEventListener('DOMContentLoaded', async () => { /* global document window */
window.addEventListener("DOMContentLoaded", async () => {
const loop = async () => { const loop = async () => {
const listen = await getCurrentListen(); const listen = await getCurrentListen();
if (listen === undefined) { if (listen === undefined) {
@ -26,11 +28,14 @@ async function getCoverArt(listen) {
return; return;
} }
const result = await window.fetch(`https://coverartarchive.org/release/${releaseMbid}`, { const result = await window.fetch(
headers: { `https://coverartarchive.org/release/${releaseMbid}`,
Accept: 'application/json', {
headers: {
Accept: "application/json",
},
}, },
}); );
if (!result.ok) { if (!result.ok) {
return; return;
} }
@ -41,11 +46,15 @@ async function getCoverArt(listen) {
} }
const thumbnails = data.images[0].thumbnails; const thumbnails = data.images[0].thumbnails;
return thumbnails.small ?? thumbnails['250'] ?? thumbnails['500'] ?? undefined; return (
thumbnails.small ?? thumbnails["250"] ?? thumbnails["500"] ?? undefined
);
} }
async function getCurrentListen() { async function getCurrentListen() {
const result = await window.fetch('https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now'); const result = await window.fetch(
"https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now",
);
if (!result.ok) { if (!result.ok) {
console.warn(result.status); console.warn(result.status);
return; return;
@ -64,16 +73,16 @@ function insertHtml(listen, image) {
return; return;
} }
const existing = document.querySelector('.listenbrainz') ?? undefined; const existing = document.querySelector(".listenbrainz") ?? undefined;
if (existing !== undefined) { if (existing !== undefined) {
existing.remove(); existing.remove();
} }
const text = `${listen.track_metadata.artist_name} - ${listen.track_metadata.track_name}`; const text = `${listen.track_metadata.artist_name} - ${listen.track_metadata.track_name}`;
const alt = image === undefined ? 'ListenBrainz Logo' : `${text} Cover Art`; const alt = image === undefined ? "ListenBrainz Logo" : `${text} Cover Art`;
image = image ?? 'https://listenbrainz.org/static/img/logo_big.svg'; image = image ?? "https://listenbrainz.org/static/img/logo_big.svg";
image = image.startsWith('http://') ? 'https' + image.slice(4) : image; image = image.startsWith("http://") ? "https" + image.slice(4) : image;
const listenHtml = ` const listenHtml = `
<p class="listenbrainz"> <p class="listenbrainz">
@ -84,5 +93,7 @@ function insertHtml(listen, image) {
</a> </a>
</p>`; </p>`;
document.querySelector('.page-header').insertAdjacentHTML('beforeend', listenHtml); document
.querySelector(".page-header")
.insertAdjacentHTML("beforeend", listenHtml);
} }

View File

@ -1,4 +1,4 @@
@use 'mixins'; @use "mixins";
.listenbrainz { .listenbrainz {
align-items: center; align-items: center;

View File

@ -1,4 +1,4 @@
@use 'mixins'; @use "mixins";
.page-footer { .page-footer {
@include mixins.responsive-container; @include mixins.responsive-container;

View File

@ -1,4 +1,4 @@
@use 'mixins'; @use "mixins";
.page-header { .page-header {
--anchor-color: #000; --anchor-color: #000;

View File

@ -1,4 +1,4 @@
@use 'mixins'; @use "mixins";
.page-main { .page-main {
a { a {
@ -14,7 +14,7 @@
} }
&.driftingnebula { &.driftingnebula {
background: url('/assets/driftingnebula 2022-03-09.jpeg'); background: url("/assets/driftingnebula 2022-03-09.jpeg");
background-position: center center; background-position: center center;
background-repeat: no-repeat; background-repeat: no-repeat;
@ -24,7 +24,7 @@
} }
&.holllo { &.holllo {
background: url('/assets/holllo-mark-square-pattern.png'); background: url("/assets/holllo-mark-square-pattern.png");
background-color: #1f1731; background-color: #1f1731;
background-repeat: repeat; background-repeat: repeat;
background-size: 48px; background-size: 48px;

View File

@ -1,4 +1,4 @@
@use 'reset'; @use "reset";
html { html {
font-size: 62.5%; font-size: 62.5%;
@ -43,7 +43,7 @@ button {
margin-top: 2rem; margin-top: 2rem;
} }
@use 'components/page-footer'; @use "components/page-footer";
@use 'components/page-header'; @use "components/page-header";
@use 'components/page-main'; @use "components/page-main";
@use 'components/listenbrainz'; @use "components/listenbrainz";

View File

@ -1 +1 @@
@use '../../node_modules/modern-normalize/modern-normalize.css'; @use "../../node_modules/modern-normalize/modern-normalize.css";