-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.en.html
114 lines (114 loc) · 6.6 KB
/
search.en.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
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<meta name="vieport" content="">
<title>Search | Endangered Languages Dictionary</title>
<link rel="stylesheet" href="/Endangered-Languages-Dictionary/styles.css">
<script src="/Endangered-Languages-Dictionary/dictionary.js"></script>
<script src="/Endangered-Languages-Dictionary/langs.js"></script>
<script src="/Endangered-Languages-Dictionary/search.js"></script>
</head>
<body>
<div class="header">
<h1 id="website-header">Endangered Languages Dictionary</h1>
<div class="nav">
<nav class="nav-header">
<a href="/Endangered-Languages-Dictionary/index.pl.html">Home</a>
| <a href="/Endangered-Languages-Dictionary/search.pl.html">Search</a>
| <a href="/Endangered-Languages-Dictionary/about.pl.html">About this site</a>
| Choose language:
<select name="langs" title="Choose language">
<option value="pl">Polski</option>
<option value="en">English</option>
<option value="de">Deutsch</option>
<option value="es">Español</option>
</select>
<button type="submit" id="lang-submit" onclick="changeLang('en');">Submit</button>
</nav>
</div>
</div>
<form id="search">
<input type="number" id="query-elasticity" name="elasticity" min="0" max="10" value="2" />
<input type="text" id="query-text" name="text" placeholder="Type searched text" />
<select id="query-dictionary" name="dictionary" title="Choose a dictionary">
<optgroup label="Kaszubski (Kaszëbsczi)">
<option value="pl_csb">Polski - Kaszubski (Kaszëbsczi)</option>
<option value="csb_pl">Kaszubski (Kaszëbsczi) - Polski</option>
</optgroup>
<optgroup label="Dolnołużycki (Dolnoserbski)">
<option value="pl_dsb">Polski - Dolnołużycki (Dolnoserbski)</option>
<option value="dsb_pl">Dolnołużycki (Dolnoserbski) - Polski</option>
</optgroup>
<optgroup label="Górnołużycki (Hornjoserbsce)">
<option value="pl_hsb">Polski - Górnołużycki (Hornjoserbsce) </option>
<option value="hsb_pl">Górnołużycki (Hornjoserbsce) - Polski</option>
</optgroup>
<optgroup label="Wilamowski (Wymysiöeryś)">
<option value="pl_wym">Polski - Wilamowski (Wymysiöeryś)</option>
<option value="wym_pl">Wilamowski (Wymysiöeryś) - Polski</option>
</optgroup>
<optgroup label="Rusiński">
<option value="pl_rue">Polski - Rusiński</option>
<option value="rue_pl">Rusiński - Polski</option>
</optgroup>
<optgroup label="Kashubian (Kaszëbsczi)">
<option value="pl_csb">English - Kashubian (Kaszëbsczi)</option>
<option value="csb_pl">Kashubian (Kaszëbsczi) - English</option>
</optgroup>
<optgroup label="Lower Sorbian (Dolnoserbski)">
<option value="pl_dsb">English - Lower Sorbian (Dolnoserbski)</option>
<option value="dsb_pl">Lower Sorbian (Dolnoserbski) - English</option>
</optgroup>
<optgroup label="Upper Sorbian (Hornjoserbsce)">
<option value="pl_hsb">English - Upper Sorbian (Hornjoserbsce) </option>
<option value="hsb_pl">Upper Sorbian (Hornjoserbsce) - English</option>
</optgroup>
<optgroup label="Vilamovian (Wymysiöeryś)">
<option value="pl_wym">English - Vilamovian (Wymysiöeryś)</option>
<option value="wym_pl">Vilamovian (Wymysiöeryś) - English</option>
</optgroup>
<optgroup label="Rusyn">
<option value="pl_rue">English - Rusyn</option>
<option value="rue_pl">Rusyn - English</option>
</optgroup>
</select>
<button type="submit" id="query-submit">Search</button>
</form>
<h4><strong>Search results:</strong></h4>
<div id="search-results"></div>
<script>
const URLQuery = new URLSearchParams(window.location.search);
console.log(URLQuery);
var resultsContainer = document.querySelector("#search-results");
if(!dictionaryExists(URLQuery.get("dictionary"))) {
var warning_img_hlink = document.createElement("a");
var warning_img = document.createElement("img");
warning_img_hlink.href = "/Endangered-Languages-Dictionary/about.en.html#langs";
warning_img.src = "/Endangered-Languages-Dictionary/in progress.jpg";
warning_img_hlink.appendChild(warning_img);
resultsContainer.appendChild(warning_img_hlink);
resultsContainer.appendChild(document.createElement("br"));
resultsContainer.appendChild(document.createTextNode("Dictionary in progress. Apologies."));
}
else {
var results = searchWithLevenshteinDist(URLQuery.get("text"), URLQuery.get("elasticity"), URLQuery.get("dictionary"));
while(resultsContainer.firstChild) resultsContainer.removeChild(resultsContainer.lastChild);
if(results.res.length == 0) {
resultsContainer.appendChild(document.createTextNode("Could not find anything matching searched phrase."));
}
else {
var res = results.res.sort();
for(var r of res) {
var phraseEntry = document.createElement("a");
phraseEntry.className = "search-result";
phraseEntry.href = "/Endangered-Languages-Dictionary/entry.en.html?q=" + r + "&dict=" + results.dict;
phraseEntry.appendChild(document.createTextNode(r));
resultsContainer.appendChild(phraseEntry);
resultsContainer.appendChild(document.createElement("br"));
}
}
}
</script>
</body>
</html>