Skip to content

Commit

Permalink
Updated JS to display the artist's credits
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatSINEWAVE committed May 17, 2024
1 parent 8eee895 commit 153010e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,36 @@ document.addEventListener('DOMContentLoaded', () => {
const artistNameElement = document.getElementById('artist-name');
const sourceLinkElement = document.getElementById('source-link');

const artistName = data.images[0].artist || 'Unknown artist';
const source = data.images[0].source || 'Unknown source';
const artistInfo = data.images[0].artist;
let artistName = 'Unknown artist';
let artistLink = '';

if (artistInfo) {
if (artistInfo.deviant_art) {
artistLink = artistInfo.deviant_art;
} else if (artistInfo.twitter) {
artistLink = artistInfo.twitter;
} else if (artistInfo.pixiv) {
artistLink = artistInfo.pixiv;
} else if (artistInfo.patreon) {
artistLink = artistInfo.patreon;
}

artistName = artistInfo.name;
}

artistNameElement.textContent = artistName;

if (artistLink) {
artistNameElement.href = artistLink;
artistNameElement.target = '_blank';
} else {
artistNameElement.removeAttribute('href');
artistNameElement.removeAttribute('target');
}

const source = data.images[0].source || 'Unknown source';

sourceLinkElement.textContent = 'View Source';
sourceLinkElement.href = source;
sourceLinkElement.target = '_blank';
Expand Down

0 comments on commit 153010e

Please sign in to comment.