gammatools/web/assets/js/loading.js

24 lines
920 B
JavaScript

export function loadingGif(resultSection) {
// Insert the loading.gif before making the fetch request
resultSection.innerHTML = '';
let imgElement = document.createElement('img');
imgElement.src = `/assets/img/checking.gif`;
imgElement.style.width = '275px';
imgElement.style.height = '275px';
imgElement.style.display = 'block';
imgElement.style.marginLeft = 'auto';
imgElement.style.marginRight = 'auto';
resultSection.appendChild(imgElement);
return imgElement;
}
export function setResultImage(document, name) {
let imgElement = document.createElement('img');
let resultSection = document.getElementById('resultSection');
imgElement.src = `/assets/img/` + name + ".jpg";
console.log(imgElement.src);
imgElement.onerror = function () {
this.src = `/assets/img/404.jpg`;
};
resultSection.appendChild(imgElement);
}