-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
98 lines (88 loc) · 2.99 KB
/
search.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
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>lexicring archival | search</title>
<style>
* {
font-family: "Noto Sans", "Droid Sans", "Liberation Sans", "Arimo", "Segoe UI", -apple-system, "Roboto", "Helvetica", "Arial", sans-serif;
}
.suggestions {
border: 1px solid #ccc;
max-height: 500px;
overflow-y: auto;
position: absolute;
background-color: white;
width: 100%;
}
.suggestion-item {
padding: 10px;
cursor: pointer;
}
.suggestion-item:hover {
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div id="header">
<h1>lexicring archival</h1>
</div>
<div id="content">
<p>Search</p><br>
<div align="center">
<p><input id="link" onkeyup="showSuggestions()">
<button onclick="search()">proudly stolen from stack overflow</button>
</p>
<div id="suggestions" class="suggestions"></div>
</div>
</div>
<h2>Unsearchable Articles</h2>
<h3>Articles</h3>
<a href="articles/modern_pop_music.html">(Ancient) Modern Pop Music</a><br>
<a href="articles/nft_nuclear_waste.html">(Ancient) NFT Nuclear Waste</a><br>
<a href="articles/trial.html">Trial</a><br>
<h3>CJKVZ+</h3>
<a href="cjkv/index.html">CJKVZ+ Documentation</a><br>
<h3>Languages</h3>
<a href="languages">Index</a><br>
<a href="languages/genalphid-language.html">Genalphid Language</a><br>
<a href="languages/tvb-fictional-languages.html">TVB Fictional Languages</a><br>
<script>
const repo = 'FishlandicFishy/lexicring';
async function fetchArticles() {
const response = await fetch(`https://api.github.com/repos/${repo}/contents/archival`);
const data = await response.json();
return data.filter(item => item.type === 'file' && item.name.endsWith('.md')).map(item => item.name.replace('.md', ''));
}
async function showSuggestions() {
const input = document.getElementById('link').value.toLowerCase();
const suggestions = document.getElementById('suggestions');
suggestions.innerHTML = '';
if (input) {
const articles = await fetchArticles();
const filteredSuggestions = articles.filter(item => item.includes(input));
filteredSuggestions.forEach(item => {
const div = document.createElement('div');
div.classList.add('suggestion-item');
div.innerText = item;
div.onclick = () => {
document.getElementById('link').value = item;
suggestions.innerHTML = '';
search();
};
suggestions.appendChild(div);
});
}
}
function search() {
var baseUrl = "https://" + window.location.hostname + "/lexicring/archival/";
var inputText = document.getElementById("link").value.toLowerCase();
var formattedInput = inputText.split(" ").join("-") + ".html";
var url = baseUrl + formattedInput;
window.location = url;
}
</script>
</body>
</html>