more fixes to encounters

This commit is contained in:
Greg Gauthier 2024-07-02 13:15:12 +01:00
parent 5e3e241dec
commit 2620720b47
16 changed files with 18 additions and 26 deletions

View File

@ -43,11 +43,11 @@ document.getElementById('terrainForm').addEventListener('submit', function (even
function setResultImage(name) { function setResultImage(name) {
let imgElement = document.createElement('img'); let imgElement = document.createElement('img');
imgElement.src = './img/' + name + ".jpg"; imgElement.src = '/img/' + name + ".jpg";
console.log(imgElement.src); console.log(imgElement.src);
imgElement.onerror = function () { imgElement.onerror = function () {
this.onerror = null; this.onerror = null;
this.src = './img/404.jpg'; this.src = '/img/404.jpg';
}; };
resultSection.appendChild(imgElement); resultSection.appendChild(imgElement);
} }
@ -67,6 +67,7 @@ document.getElementById('terrainForm').addEventListener('submit', function (even
// Make the key names bold: // Make the key names bold:
tdKey.style.fontWeight = 'bold'; tdKey.style.fontWeight = 'bold';
if (Array.isArray(data[key])) { if (Array.isArray(data[key])) {
if (key === 'environ' || key === 'mutations') { if (key === 'environ' || key === 'mutations') {
tdValue.innerText = data[key].join(', '); tdValue.innerText = data[key].join(', ');
@ -98,31 +99,22 @@ document.getElementById('terrainForm').addEventListener('submit', function (even
tdValue.innerText = data[key]; tdValue.innerText = data[key];
} }
tr.appendChild(tdKey); if (key === 'name') {
tr.appendChild(tdValue); let imgURL = "/img/" + data[key] + ".jpg";
table.appendChild(tr); tdKey.innerHTML = `
<div>
<h2 style=\'font-size: 1.2em;\'>${data[key].toUpperCase()}</h2>
</div>`;
tdValue.innerHTML = `
<div>
<img src='${imgURL}' onerror='this.src="/img/404.jpg";' style='width: 230px; height: 230px;'>
</div>`;
console.log(tdValue.innerHTML);
} }
// append image row if name key exists
if(data.name) {
let tr = document.createElement('tr');
let tdKey = document.createElement('td');
let tdValue = document.createElement('td');
let imgElement = document.createElement('img');
tdKey.innerText = 'IMAGE';
tdKey.style.fontWeight = 'bold';
imgElement.src = './img/' + data.name + ".jpg";
imgElement.onerror = function() {
this.onerror = null;
this.src = './img/404.jpg';
};
tdValue.appendChild(imgElement);
tr.appendChild(tdKey); tr.appendChild(tdKey);
tr.appendChild(tdValue); tr.appendChild(tdValue);
table.appendChild(tr); table.appendChild(tr);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 32 KiB