-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (82 loc) · 2.53 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
<!-- https://github.com/desoga10/Countrypedia/blob/master/script.js -->
<!-- https://www.javascripttutorial.net/javascript-fetch-api/ -->
<!-- RegExp https://levelup.gitconnected.com/use-regex-and-javascript-to-improve-search-results-870932050d08 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<!-- <link rel="stylesheet" href="css/style.css" /> -->
<style>
body {
background-color: rgb(255, 249, 249);
font-family: Verdana;
font-size: 2rem;
margin: 20px;
}
#row-container {
text-align: center;
}
#countryList {
text-align: center;
}
</style>
<title>Santali Emoji Search</title>
</head>
<body>
<div class="row-container">
<div class="input-field col s6">
<h5 class="center-align">
<i class="small material-icons"></i>Type your emoji
</h5>
<input placeholder="e.g ᱥᱟᱭ" id="search" type="text" class="validate" />
</div>
</div>
<div id="countryList"></div>
<script>
//Get Countries From Json File
const searchcountry = async searchBox => {
const res = await fetch('emoji.json');
const countries = await res.json();
//Get Entered Data
let fits = countries.filter(country => {
const regex = new RegExp(`[^]*${searchBox}`, 'gi');
// const regex = new RegExp(`^${searchBox}`, 'gi');
return (country.title.match(regex) || country.keywords.match(regex) || country.santali.match(regex) || country.hindi.match(regex));
});
if (searchBox.length === 0) {
fits = [];
countryList.innerHTML = '';
}
outputHtml(fits);
};
// show results in HTML
const outputHtml = fits => {
if (fits.length > 0) {
const html = fits
.map(
fit => `
<div class="row">
<div class="col s12">
<div class="card grey darken-4 darken-1">
<div class="card-content white-text">
<h4 class="card-title m1">${fit.symbol} (${fit.title})<span class="blue-text m-4"></span></h4>
</div>
</div>
</div>
</div>
`
)
.join('');
document.getElementById('countryList').innerHTML = html;
}
};
document
.getElementById('search')
.addEventListener('input', () => searchcountry(search.value));
</script>
</body>
</html>