Skip to content

Commit

Permalink
feat(web): show message on error
Browse files Browse the repository at this point in the history
  • Loading branch information
journey-ad committed Oct 20, 2024
1 parent 41bf6ca commit 97c529e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,25 @@
}

const query = new URLSearchParams(params).toString();
img.src = `${__global_data.site}/@${name}?${query}`;
code.textContent = img.src;
code.style.visibility = 'visible';
const imgSrc = `${__global_data.site}/@${name}?${query}`;
img.src = imgSrc

img.onload = () => img.scrollIntoView({ block: 'start', behavior: 'smooth' });
img.onload = () => {
img.scrollIntoView({ block: 'start', behavior: 'smooth' });

code.textContent = imgSrc;
code.style.visibility = 'visible';
}

img.onerror = () => {
fetch(imgSrc)
.then(async (res) => {
if (!res.ok) {
const { message } = await res.json();
alert(message);
}
})
};
}, 500));

code.addEventListener('click', (e) => {
Expand Down

0 comments on commit 97c529e

Please sign in to comment.