fix pathing for production

This commit is contained in:
Greg Gauthier 2024-07-17 00:12:31 +01:00
parent 5f86de040b
commit 38aad36fc8
4 changed files with 12 additions and 8 deletions

View File

@ -11,7 +11,7 @@ export function androidResultTable(data, creatureName) {
container.appendChild(creatureTitle)
let image = document.createElement('img');
image.src = '/assets/img/android.jpg';
image.src = `${window.IMG}/android.jpg`;
image.onerror = () => { image.src = '/assets/img/404.jpg' };
image.style.width = '275px';
image.style.height = '275px';

View File

@ -24,7 +24,7 @@ document.getElementById('searchForm').addEventListener('submit', function (event
})
.then((json) => {
if (json === null) { // if json is null update the image and stop execution
imgElement.src = '/assets/img/404.jpg';
imgElement.src = `${window.IMG}/404.jpg`;
throw new Error('No data found'); // this will stop the execution and go to the catch block
}
resultSection.innerHTML = ''; // Clear previous content
@ -37,7 +37,7 @@ document.getElementById('searchForm').addEventListener('submit', function (event
.catch((err) => {
console.log(err);
if (!resultSection.hasChildNodes()) { // Only update the image if it wasn't already updated
imgElement.src = '/assets/img/404.jpg';
imgElement.src = `${window.IMG}/404.jpg`;
}
});
}, 1000);

View File

@ -1,13 +1,17 @@
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
window.BASE_URL = 'http://127.0.0.1:5000';
} else {
window.BASE_URL = 'https://gammaworld.gmgauthier.com';
}
window.IMG = "/assets/img";
window.CSS = "/assets/css";
window.JS = "/assets/js";
window.DOC = "/pages";
} else {
window.BASE_URL = 'https://gammaworld.gmgauthier.com';
window.IMG = "/gw/assets/img";
window.CSS = "/gw/assets/css";
window.JS = "/gw/assets/js";
window.DOC = "/gw/pages";
}
console.log(window.location.hostname)
console.log(window.BASE_URL)

View File

@ -13,7 +13,7 @@ export function setCreatureTable(data, creatureName) {
creatureId.className = 'creature_id';
creatureId.innerHTML = `
<h2>${creatureName.toUpperCase()}</h2>
<img src='/assets/img/${creatureName}.jpg' onerror='this.src="/assets/img/404.jpg";' style='width: 275px; height: 275px;'>
<img src='${window.IMG}/${creatureName}.jpg' onerror='this.src="${window.IMG}/404.jpg";' style='width: 275px; height: 275px;'>
`;
let profile = createProfileSection(data);