-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainindex.js
58 lines (41 loc) · 1.25 KB
/
mainindex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import apiCall from "./fetch.js";
// <script>
window.onscroll = function () { stickyNavbar() };
var navbar = document.querySelector("#secondNav");
var sticky = navbar.offsetTop;
function stickyNavbar() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("fixed", "w-full", "top-0")
} else {
navbar.classList.remove("fixed");
}
}
// document.querySelector("#input").addEventListener("keypress", getData);
//
function getData(event) {
var input = document.querySelector("#input").value
if (event.key === "Enter") {
console.log(input)
let url = "http://127.0.0.1:4000/api/gameAllData?genre=" + input + "";
let res = apiCall(url);
res.then((res) => {
//console.log(res)
data = res;
console.log(data.length)
if (data.length === 0) {
alert("No Result Found");
}
appendData(res);
})
res.catch((error) => {
console.log(error)
})
}
}
function showInputBoxInMobileView() {
document.querySelector('#dicoverHide').classList.toggle("hidden")
document.querySelector('#searchDiv').classList.toggle("hidden",)
document.querySelector('#searchicon').classList.add("hidden")
document.querySelector('#secondNav').classList.toggle("justify-start")
}
// </script>