-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.html
More file actions
99 lines (81 loc) · 1.75 KB
/
main.html
File metadata and controls
99 lines (81 loc) · 1.75 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>wikipedia searcher</title>
<style>
body {
background-color: #f58b54;
}
#button {
width: 30%;
height: 200px;
background-color: lightgreen;
}
#place {
width: 50%;
height: 300px;
position: absolute;
top: 400px;
left: 400px;
background-color: #dfddc7;
}
#place {
font-size: 36px;
font-family: sans-serif;
justify-content: center;
padding: 20px;
}
#text-box {
width: 30%;
height: 50px;
border-radius: 3%;
border: 0px;
position: absolute;
left: 32.5%;
top: 30%;
right: auto;
font-size: 45px;
}
#button1 {
width: 100px;
height: 50px;
position: absolute;
background-color: #f2eee5;
left: 65%;
top: 30%;
margin: 0;
}
#button1:hover {
animation: turncolor 2s 1;
}
@keyframes turncolor {
from {
background-color: #f2eee5;
}
to {
background-color: #ff4d00;
color: white;
font-style: bold;
}
}
</style>
</head>
<body>
<div id="container">
<input type="text" id="text-box">
<button id="button1" onclick="getData()">Click here
</div>
<div id="place"></div>
<script>
var put = document.getElementById('place');
async function getData() {
const search1 = document.getElementById('text-box').value;
const response = await fetch(`https://en.wikipedia.org/w/api.php?&origin=*&action=opensearch&limit=5&search=${search1}`);
const blob = await response.json();
put.innerHTML = blob[2][0];
put.style.color = "black";
}
</script>
</body>
</html>