more fixes to encounters
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 46 KiB |
BIN
web/img/ark.jpg
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 32 KiB |