add images to the encounter table

This commit is contained in:
Greg Gauthier 2024-07-01 23:28:05 +01:00
parent 5a502fb308
commit 5e3e241dec
7 changed files with 27 additions and 0 deletions

View File

@ -54,6 +54,9 @@ document.getElementById('terrainForm').addEventListener('submit', function (even
function setResultTable(data) {
let table = document.createElement('table');
table.style.fontSize = '18px';
table.style.fontFamily = 'Arial';
for (let key in data) {
let tr = document.createElement('tr');
let tdKey = document.createElement('td');
@ -99,6 +102,30 @@ document.getElementById('terrainForm').addEventListener('submit', function (even
tr.appendChild(tdValue);
table.appendChild(tr);
}
// 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(tdValue);
table.appendChild(tr);
}
resultSection.appendChild(table);
}
}, 1000);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 38 KiB