From fb4c9e80239275055711141c4a56226fa1c4b32b Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Mon, 22 Jun 2020 10:13:40 -0400 Subject: Updated side bar to have drop downs --- JS/main.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'JS') diff --git a/JS/main.js b/JS/main.js index ec46e4c..e541d5f 100644 --- a/JS/main.js +++ b/JS/main.js @@ -1,9 +1,9 @@ function searchDuck(event){ var x = document.getElementById('Search').value; - if (event.keyCode == 13 || event.which == 13) { + if (event.keyCode == 13 || event.which == 13) { if (x == '/4chan'){ fourChan() - } + } else if (x == '/help'){ help() } @@ -11,4 +11,19 @@ function searchDuck(event){ } function FocusOnInput(){ document.getElementById("Search").focus(); -} \ No newline at end of file +} +function dropdown(theID) { + document.getElementById(theID).classList.toggle("show"); +} +window.onclick = function(event) { //when the user clicks anywhere else on the screen the menu disappears + if (!event.target.matches('.dropbtn')) { + var dropdowns = document.getElementsByClassName("dropdown-content"); + var i; + for (i = 0; i < dropdowns.length; i++) { + var openDropdown = dropdowns[i]; + if (openDropdown.classList.contains('show')) { + openDropdown.classList.remove('show'); + } + } + } +} -- cgit v1.2.3