-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
85 lines (75 loc) · 1.58 KB
/
index.html
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
<html>
<head>
<title>
Dyna Search Engine
</title>
<style>
h1 {
text-align: center;
justify-content: center;
font-size: 4rem;
/* color: #ebdbb2; */
}
/* body { */
/* background-color: #1d2021; */
/* } */
input {
font-size: 2rem;
}
button {
font-size: 2rem;
font-family: monospace;
}
.container {
display: flex;
justify-content: center;
align-items: center;
font-size: 1rem;
}
a {
text-align: center;
}
</style>
<script>
function query_send() {
let url = "http://localhost:8080";
let dom_node = document.getElementById("searchbar");
let result_node = document.getElementById("results")
let query = dom_node.value;
let formatted_url = new URL(url);
formatted_url.searchParams.set("query", query);
fetch(formatted_url.toString(), {
mode: 'cors',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
}
})
.then(res => res.text())
.then(res => {
let res_obj = JSON.parse(res);
console.log(res_obj);
let output_html = "";
for (const [key, val] of Object.entries(res_obj)) {
let anchor_tags = `<a href=\"file://${key}\">${key}</a><br>`;
output_html = output_html.concat(anchor_tags);
}
console.log(output_html);
result_node.innerHTML = output_html;
})
.catch(e => {result_node.innerText = e});
}
</script>
</head>
<body>
<h1>
Dyna
</h1>
<div class="container">
<input id="searchbar" type="text"/>
<button onclick="query_send()">Search</button>
</div>
<div id="results">
</div>
</body>
</html>