-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
183 lines (155 loc) · 7 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Classical Latin LASLA/Forcellini Lemma Dictionnary</title>
<style type="text/css">
.navbar .form-control {
padding: .75rem 1rem;
border-width: 0;
border-radius: 0;
}
.form-control-dark {
color: #fff;
background-color: rgba(255, 255, 255, 1);
border-color: rgba(255, 255, 255, .4);
}
.form-control-dark:focus {
border-color: transparent;
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}
.bg-white {
background-color: #fff;
}
.container {
min-height: 50px;
margin-top: 1em;
}
.navbar-brand {
font-size: 1em;
}
.hidden {
display:none;
}
</style>
</head>
<body class="bg-light">
<nav class="navbar navbar-dark bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-sm-4 col-md-2 mr-0" href="#">Latin Lemma Dictionnary</a>
</nav>
<div class="container text-center" id="loading">
<p><img src="loading.gif" alt="Loading Icon" /><br />Loading</p>
</div>
<div class="container bg-white hidden" id="search-container">
<p class="small" style="text-align: center;">Found an error ? Want to add details ? <a href="https://github.com/lascivaroma/forcellini-lemmas/edit/master/dictionary.tsv">Please propose some changes</a>.</p>
<div class="small">
<p>Source dictionary:</p>
<ul>
<li><a href="https://archive.org/details/Vol.1.A-c.LexiconTotiusLatinitatisForcelliniEd.Quarta/mode/2up">A-C</a></li>
<li><a href="https://archive.org/details/Vol.2.D-k.Ed.Quarta.lexiconTotiusLatinitatisAegidioForcelliniLucubratum">D-K</a></li>
<li><a href="https://archive.org/details/Vol.3.L-qLexiconTotiusLatinitatisAbAegidioForcelliniLucubratum.Ed">L-Q</a></li>
<li><a href="https://archive.org/details/Vol.4.A.R-sLexiconTotiusLatinitatisAegidioForcelliniLucubratum.Vol">R-S</a></li>
<li><a href="https://archive.org/details/Vol.4.B.T-z.LexiconTotiusLatinitatisAegidioForcelliniLucubratum.Vol">T-Z</a></li>
</ul>
</div>
<form id="search_run" method="GET" style="margin-bottom: 2em;">
<div class="input-group input-group-lg">
<input type="text" class="form-control" name="q" id="q" value=""
placeholder="Search using * if you want to use wildcard" aria-label="Search" />
<div class="input-group-prepend">
<button class="btn btn-primary" type="submit">Search</button>
</div>
</div>
You can use * as a wildcard.
</form>
<table class="table table-stripped">
<thead></thead>
<tbody></tbody>
</table>
<footer class="small">Favicon source : https://fr.m.wikipedia.org/wiki/Fichier:Closed_Book_Icon.svg, author Boca Tutor</footer>
</div>
<script src="https://unpkg.com/lunr/lunr.js"></script>
<script type="text/javascript">
// self executing function here
(function() {
const urlParams = new URLSearchParams(window.location.search);
const keep_rows = 5;
tbody = document.getElementsByTagName("tbody")[0],
query = document.getElementById("q"), // Text Input
form = document.getElementById("search_run"); // Form
let documents = [],
idx = [];
fetch("./dictionary.tsv")
.then(function(response) {
if (response.status >= 200 && response.status < 300){
return response.text();
} else {
alert("Loading data failed.");
}
})
.then(function(data) {
idx = lunr(function () {
this.ref('id');
this.field("lemma");
this.field("Variation");
const rows = data.split(/\n/);
let tbody = ""
let key_names = [];
// Iterate over rows of the TSV
for (let i = 0; i < rows.length; i++) {
let tds = rows[i].split(/\t/, keep_rows);
// Parse the header
if (i == 0) {
key_names = tds;
document.getElementsByTagName('thead')[0].innerHTML = "<tr><th>"+tds.join("</th><th>")+"</th></tr>";
} else if (tds[0] != false) {
//Parse the lemma
documents.push({});
let current = documents[documents.length-1];
for (let j =0; j < key_names.length; j++) {
current[key_names[j]] = tds[j];
}
current.html = document.createElement("tr");
current.html.innerHTML = "<td>"+tds.join("</td><td>")+"</td>";
current.id = documents.length-1;
this.add(current);
}
} // Endfor
form.dispatchEvent(new Event('build'));
}); // End LUNR
}); // End "AJAX"
form.addEventListener("build", function (e) {
document.getElementById("loading").remove();
document.getElementById("search-container").classList.toggle("hidden");
const seeAll = function() {
tbody.innerHTML = "";
for (var i = 0; i < documents.length; i++) {
tbody.appendChild(documents[i].html);
}
};
const noResults = document.createElement("tr");
noResults.innerHTML = `<td class="bg-warning" colspan="${keep_rows}">No results</td>`;
form.addEventListener("submit", function(e) {
e.preventDefault();
let q = query.value;
// Prevent a full search
if (q.match(/^[\s\*]*$/)) { return seeAll(); }
let results = idx.search(q);
tbody.innerHTML = "";
if (results.length) {
for (var i = 0; i < results.length; i++) {
tbody.appendChild(documents[results[i].ref].html);
}
} else {
tbody.appendChild(noResults);
}
});
}, false);
})();
</script>
</body>
</html>