mirror of
https://github.com/driftywinds/driftywinds.github.io.git
synced 2025-12-19 19:13:33 +00:00
Handle missing/non-existent images
This commit is contained in:
4
app.html
4
app.html
@@ -22,7 +22,7 @@
|
|||||||
Back
|
Back
|
||||||
</button>
|
</button>
|
||||||
<div id="title" class="hidden">
|
<div id="title" class="hidden">
|
||||||
<img src="img/generic_app.jpeg" alt="generic-app-icon">
|
<img id="app-icon" src="img/generic_app.jpeg" alt="generic-app-icon">
|
||||||
<p>AltSource</p>
|
<p>AltSource</p>
|
||||||
</div>
|
</div>
|
||||||
<a href="https://example.com" class="install hidden">
|
<a href="https://example.com" class="install hidden">
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="app-header">
|
<div class="app-header">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<img src="img/generic_app.jpeg" alt="generic-app-icon">
|
<img id="app-icon" src="img/generic_app.jpeg" alt="generic-app-icon">
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<p class="title">AltSource</p>
|
<p class="title">AltSource</p>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function main(json) {
|
|||||||
if (app.screenshotURLs) {
|
if (app.screenshotURLs) {
|
||||||
html += `
|
html += `
|
||||||
<div class="screenshots">`;
|
<div class="screenshots">`;
|
||||||
for (let i = 0; i < app.screenshotURLs.length, i < 2; i++) html += `
|
for (let i = 0; i < app.screenshotURLs.length, i < 2; i++) if (app.screenshotURLs[i]) html += `
|
||||||
<img src="${app.screenshotURLs[i]}" class="screenshot">`;
|
<img src="${app.screenshotURLs[i]}" class="screenshot">`;
|
||||||
html += `
|
html += `
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ function waitForAllImagesToLoad() {
|
|||||||
newImage.addEventListener("load", loaded);
|
newImage.addEventListener("load", loaded);
|
||||||
// Set src
|
// Set src
|
||||||
newImage.src = image.src;
|
newImage.src = image.src;
|
||||||
|
|
||||||
|
// Unable to load image
|
||||||
|
image.addEventListener("error", (event) => {
|
||||||
|
if (event.target.id == "app-icon") {
|
||||||
|
event.target.src = "img/generic_app.jpeg";
|
||||||
|
} else event.target.remove()
|
||||||
|
loaded();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||||
const sourceURL = urlSearchParams.get('source');
|
const sourceURL = urlSearchParams.get('source').replaceAll("+", "%2B");
|
||||||
// https://stackoverflow.com/a/8943487
|
// https://stackoverflow.com/a/8943487
|
||||||
const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ const appHeaderHTML = app => app ? `
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="app-header">
|
<div class="app-header">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<img src="${app.iconURL}" alt="">
|
<img id="app-icon" src="${app.iconURL}" alt="">
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<p class="title">${app.name}</p>
|
<p class="title">${app.name}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user