diff --git a/index.html b/index.html index 30d24e7..48b243a 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@
diff --git a/main.js b/main.js index c47bf07..1c1e748 100644 --- a/main.js +++ b/main.js @@ -229,7 +229,7 @@ function loadDictionary() { //add: translations, meanings for (let o = 0; o < values[i].length; o++) { - if (values[i][o].hasOwnProperty("translation")) searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"], true)); + if (values[i][o].hasOwnProperty("translation")){searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"], true))}; if (values[i][o].hasOwnProperty("meaning")) searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"], true)); } } catch (e) { @@ -301,16 +301,19 @@ function clickSearch(word) { //minds too hazy for this rn though... } -function doSearch(state = true, all = false) { - if (all == true) { - header.querySelector("input").value = "show:all"; - } +function doSearch(state = true) { let val = header.querySelector("input").value; if (val == "") { main.innerHTML = "enter some search terms..."; return; } - let results = search(val == "show:all" ? "" : val); + + //Manage search methods + val = (val.indexOf("show:random") !== -1) ? random.choice(list(searchDictionary.values())) : val; + val = (val.indexOf("show:all") !== -1) ? "" : val; + + //Results + let results = search(val); if (results.length == 0) { main.innerHTML = "no results (todo: cool form)"; } else { @@ -428,9 +431,22 @@ function doSearch(state = true, all = false) { types = sortObject(types); let header = document.createElement("div"); header.classList.add("results-header"); - header.innerHTML += "search results for: " + val + "