const gifSearchBar = document.getElementById('gifSearch') const loadGIFs = document.getElementById('gifs-load-more'); const noGIFs = document.getElementById('no-gifs-found'); const container = document.getElementById('GIFs'); let commentFormID; function insertGIF(url) { const commentBox = document.getElementById(commentFormID); const old = commentBox.value; if (old) commentBox.value = `${old}\n${url}`; else commentBox.value = url if (typeof checkForRequired === "function") checkForRequired(); } document.getElementById('gifModal').addEventListener('shown.bs.modal', function () { gifSearchBar.focus(); setTimeout(() => { gifSearchBar.focus(); }, 200); setTimeout(() => { gifSearchBar.focus(); }, 1000); }); document.getElementById('gifModal').addEventListener('shown.bs.modal', function () { gifSearchBar.focus(); setTimeout(() => { gifSearchBar.focus(); }, 200); setTimeout(() => { gifSearchBar.focus(); }, 1000); }); async function getGifs(form) { commentFormID = form; gifSearchBar.value = null; noGIFs.innerHTML = null; loadGIFs.innerHTML = null; container.innerHTML = `
Aw shucks. No GIFs found...
'; container.innerHTML = null; loadGIFs.innerHTML = null; } else { for (let i = 0; i < 48; i++) { gifURL[i] = "https://media.giphy.com/media/" + data[i].id + "/giphy.webp"; const insert = `` container.insertAdjacentHTML('beforeend', insert); noGIFs.innerHTML = null; loadGIFs.innerHTML = 'Thou hast reached the end of the list!
'; } } } document.getElementById('gifs-back-btn').onclick = getGifs; document.getElementById('gifs-cancel-btn').onclick = getGifs;