first commit
This commit is contained in:
commit
10927d4022
7 changed files with 47157 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.DS_Store
|
||||
.make.*
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 samhenrigold
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
From https://github.com/samhenrigold/emoji-metadata
|
||||
|
||||
Search for emoji
|
46989
emoji_metadata.json
Normal file
46989
emoji_metadata.json
Normal file
File diff suppressed because it is too large
Load diff
32
index.html
Normal file
32
index.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Emoji search</title>
|
||||
<script type="module" src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Emoji search</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<form id="search-form">
|
||||
<label for="query">Search:</label>
|
||||
<input type="search" id="query" name="query">
|
||||
</form>
|
||||
|
||||
<table id="results">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Emoji</th>
|
||||
<th colspan="2">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
62
schema.json
Normal file
62
schema.json
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"emoji": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"category": {
|
||||
"type": "string"
|
||||
},
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"unicode_version": {
|
||||
"type": "string"
|
||||
},
|
||||
"ios_version": {
|
||||
"type": "string"
|
||||
},
|
||||
"bucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"related": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" }
|
||||
},
|
||||
"rgb": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"emoji",
|
||||
"description",
|
||||
"category",
|
||||
"aliases",
|
||||
"unicode_version",
|
||||
"ios_version",
|
||||
"bucket",
|
||||
"related",
|
||||
"rgb"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
48
script.js
Normal file
48
script.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
async function setClipboard(text) {
|
||||
const type = "text/plain";
|
||||
const blob = new Blob([text], { type });
|
||||
const data = [new ClipboardItem({ [type]: blob })];
|
||||
await navigator.clipboard.write(data);
|
||||
}
|
||||
|
||||
async function go() {
|
||||
const data = await (await fetch('emoji_metadata.json')).json();
|
||||
console.log(data);
|
||||
|
||||
const form = document.getElementById('search-form');
|
||||
|
||||
const results_body = document.querySelector('#results tbody');
|
||||
|
||||
form.addEventListener('input', () => {
|
||||
const fd = new FormData(form);
|
||||
const params = Object.fromEntries(fd);
|
||||
update_search(params);
|
||||
})
|
||||
|
||||
function update_search({query}) {
|
||||
const matches = data.filter(d => {
|
||||
const desc = [d.description].concat(d.aliases).join(' ').toLowerCase();
|
||||
return desc.includes(query.toLowerCase());
|
||||
})
|
||||
console.log(matches);
|
||||
|
||||
results_body.innerHTML = '';
|
||||
for(let d of matches) {
|
||||
const tr = document.createElement('tr');
|
||||
results_body.append(tr);
|
||||
tr.innerHTML = `<td class="emoji">${d.emoji}</td><td>${d.description}</td><td>${d.aliases.join(', ')}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
results_body.addEventListener('click', e => {
|
||||
console.log(e.target);
|
||||
if(!e.target.classList.contains('emoji')) {
|
||||
return;
|
||||
}
|
||||
setClipboard(e.target.textContent);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
go();
|
Loading…
Add table
Add a link
Reference in a new issue