diff --git a/database.json b/database.json index a82ba7d..cf52ac7 100644 --- a/database.json +++ b/database.json @@ -15,5 +15,13 @@ "1400", "any" ] + }, + { + "url": "gifs/100/oldsite_0.gif", + "tags": [ + "oldsite", + "100", + "any" + ] } -] +] \ No newline at end of file diff --git a/gifs/100/oldsite_0.gif b/gifs/100/oldsite_0.gif new file mode 100644 index 0000000..b41c505 Binary files /dev/null and b/gifs/100/oldsite_0.gif differ diff --git a/gifs/200/oldsite_0.gif b/gifs/200/oldsite_0.gif new file mode 100644 index 0000000..067649f Binary files /dev/null and b/gifs/200/oldsite_0.gif differ diff --git a/gifs/300/oldsite_0.gif b/gifs/300/oldsite_0.gif new file mode 100644 index 0000000..c8da77c Binary files /dev/null and b/gifs/300/oldsite_0.gif differ diff --git a/gifs/300/oldsite_1.gif b/gifs/300/oldsite_1.gif new file mode 100644 index 0000000..58d36c1 Binary files /dev/null and b/gifs/300/oldsite_1.gif differ diff --git a/gifs/400/oldsite_0.gif b/gifs/400/oldsite_0.gif new file mode 100644 index 0000000..59e7184 Binary files /dev/null and b/gifs/400/oldsite_0.gif differ diff --git a/gifs/500/oldsite_0.gif b/gifs/500/oldsite_0.gif new file mode 100644 index 0000000..a229b5d Binary files /dev/null and b/gifs/500/oldsite_0.gif differ diff --git a/gifs/500/oldsite_1.gif b/gifs/500/oldsite_1.gif new file mode 100644 index 0000000..6ab51cc Binary files /dev/null and b/gifs/500/oldsite_1.gif differ diff --git a/gifsearch.js b/gifsearch.js index 2ba7b00..f4d5589 100644 --- a/gifsearch.js +++ b/gifsearch.js @@ -3,80 +3,83 @@ let xhr = new XMLHttpRequest(); xhr.open("GET", "database.json"); xhr.send(); xhr.onload = () => { - database = JSON.parse(xhr.responseText); + database = JSON.parse(xhr.responseText); } function getGifs(searchTags) { - return database.filter(gif => { - for (let tag of searchTags) - if (!gif.tags.includes(tag)) - return false; - return true; - }); + return database.filter(gif => { + for (let tag of searchTags) + if (!gif.tags.includes(tag)) + return false; + return true; + }); } // Tags that will show up as examples -var allTags = ["any", "hundo", "trueskip", "everred", "noot"]; +var allTags = ["any", "hundo", "gemskip", "trueskip", "everred", "noot"]; var everredTags = ["any", "hundo", "trueskip", "gemskip"]; var nootTags = ["any", "hundo"]; var adelieTags = ["any", "hundo", "gemskip"]; +var oldsiteTags = ["any", "hundo", "gemskip "]; -var tagsField = document.getElementById("tags"); -var modSelect = document.getElementById("modName"); -let textbox = document.getElementById('search') -let submitButton = document.getElementById('submit'); + var tagsField = document.getElementById("tags"); + var modSelect = document.getElementById("modName"); + let textbox = document.getElementById('search') + let submitButton = document.getElementById('submit'); -textbox.addEventListener("keyup", (e) => { - if (e.keyCode === 13) - submitButton.click(); -}); + textbox.addEventListener("keyup", (e) => { + if (e.keyCode === 13) + submitButton.click(); + }); -// Function that changes the example tags based on the selected dropdown option -function changeTags() { - var modName = modSelect.options[modSelect.selectedIndex].value; - switch (modName) { - case "all": - tagsField.innerHTML = allTags.join(', '); - break; - case "everred": - tagsField.innerHTML = everredTags.join(', '); - break; - case "adelie": - tagsField.innerHTML = adelieTags.join(', '); - break; - case "noot": - tagsField.innerHTML = nootTags.join(', '); - break; - } -} -// Funtion to be triggered when the dropdown value changes -modSelect.addEventListener("change", changeTags); + // Function that changes the example tags based on the selected dropdown option + function changeTags() { + var modName = modSelect.options[modSelect.selectedIndex].value; + switch (modName) { + case "all": + tagsField.innerHTML = allTags.join(', '); + break; + case "everred": + tagsField.innerHTML = everredTags.join(', '); + break; + case "adelie": + tagsField.innerHTML = adelieTags.join(', '); + break; + case "noot": + tagsField.innerHTML = nootTags.join(', '); + break; + case "oldsite": + tagsField.innerHTML = oldsiteTags.join(', '); + break; + } + } + // Funtion to be triggered when the dropdown value changes + modSelect.addEventListener("change", changeTags); -submitButton.addEventListener('click', () => { - var modName = modSelect.options[modSelect.selectedIndex].value; - if (modName == "all") { - querry = textbox.value; - } - else { - querry = textbox.value + ' ' + modName; - } - let searchTags = new Set(querry.split(/\s+/).filter(x => x != '')); - if (searchTags.size == 0) - return; + submitButton.addEventListener('click', () => { + var modName = modSelect.options[modSelect.selectedIndex].value; + if (modName == "all") { + querry = textbox.value; + } else { + querry = textbox.value + ' ' + modName; + } + let searchTags = new Set(querry.split(/\s+/).filter(x => x != '')); + if (searchTags.size == 0) + return; - let content = document.getElementById('content'); - while (content.firstChild) { - content.firstChild.remove(); - } + let content = document.getElementById('content'); + while (content.firstChild) { + content.firstChild.remove(); + } - let gifResults = getGifs(searchTags); - for (let gif of gifResults) { - let img = document.createElement("img"); - img.src = gif.url; - img.title = 'Tags: ' + gif.tags.join(", "); + let gifResults = getGifs(searchTags); + for (let gif of gifResults) { + let img = document.createElement("img"); + img.src = gif.url; + img.title = 'Tags: ' + gif.tags.join(", "); - content.appendChild(img); - } -}); + content.appendChild(img); + } + }); -window.onload = changeTags(); + window.onload = changeTags(); \ No newline at end of file diff --git a/index.html b/index.html index 084f67c..6abf506 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,7 @@ +