-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
38 lines (27 loc) · 792 Bytes
/
search.js
File metadata and controls
38 lines (27 loc) · 792 Bytes
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
import {nav,getData,display} from './navbar.js';
let navbar=nav();
document.getElementById("main").innerHTML=navbar;
let un=JSON.parse(localStorage.getItem("showuser"));
document.getElementById("username").innerText=un.Name;
document.getElementById("searchbox").addEventListener("keypress",Wao);
let pare=document.querySelector("#container");
let interval;
function Wao(){
if(interval){
clearTimeout(interval);
}
interval=setTimeout(()=>{
pta();
},1000)
}
async function pta(){
try {
let inp=document.querySelector("#searchbox").value;
let data=await getData(inp);
// console.log(data.meals[0].strMeal);
// console.log(data);
display(data,pare);
}
catch (error) {
console.log("error2");
}}