gammatools/web/assets/js/loading.js

26 lines
973 B
JavaScript
Raw Normal View History

export function loadingGif(resultSection) {
// Insert the loading.gif before making the fetch request
resultSection.innerHTML = '';
let imgElement = document.createElement('img');
2024-07-16 23:50:14 +00:00
imgElement.src = `${window.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;
}
2024-07-17 00:08:58 +00:00
export function setResultImage(document, name) {
let imgElement = document.createElement('img');
let resultSection = document.getElementById('resultSection');
2024-07-17 00:08:58 +00:00
let safeName = name.replace(/ /g,"%20");
imgElement.src = `${window.IMG}/${safeName}.jpg`;
console.log(imgElement.src);
imgElement.onerror = function () {
2024-07-16 23:50:14 +00:00
this.src = `${window.IMG}/404.jpg`;
};
resultSection.appendChild(imgElement);
}