-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
149 lines (148 loc) · 3.77 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TLDs</title>
<style>
body {
margin:0;
color:#f0f0f0;
background:#121212;
height: 100%;
font-family: sans-serif;
}
main{
background:#121212;
width: 100%;
height: 100%;
max-width:750px;
}
nav {
position:sticky;
position: -webkit-sticky;
top:0;
z-index: 10;
}
form{
padding:1rem;
background:#121212;
}
input{
padding: 1rem;
border-radius:4px;
background-color:#212121;
width:100%;
border:0;
outline:0;
color:white;
font-size:1rem;
}
input[type="search"]::-webkit-search-cancel-button{
-webkit-appearance: none;
height: 1.5em;
width: 1.5em;
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJoLTUgdy01IiB2aWV3Qm94PSIwIDAgMjAgMjAiIGZpbGw9IiNmZWZlZmUiPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMCAxOGE4IDggMCAxMDAtMTYgOCA4IDAgMDAwIDE2ek04LjcwNyA3LjI5M2ExIDEgMCAwMC0xLjQxNCAxLjQxNEw4LjU4NiAxMGwtMS4yOTMgMS4yOTNhMSAxIDAgMTAxLjQxNCAxLjQxNEwxMCAxMS40MTRsMS4yOTMgMS4yOTNhMSAxIDAgMDAxLjQxNC0xLjQxNEwxMS40MTQgMTBsMS4yOTMtMS4yOTNhMSAxIDAgMDAtMS40MTQtMS40MTRMMTAgOC41ODYgOC43MDcgNy4yOTN6IiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIC8%2BCjwvc3ZnPg%3D%3D) no-repeat;
background-size: cover;
}
.hl{
color:cyan;
}
ul{
padding:0;
list-style-type:none;
}
li{
padding:1rem;
margin:1rem;
background-color:#212121;
border-radius:8px;
transition:150ms ease;
}
li:active{
transform:scale(0.97);
}
.hidden{
display:none !important;
}
.loader div {
width:4rem;
height:4rem;
border-radius: 100px;
border: 8px solid cyan;
border-right-color: transparent;
animation: rotate 1s ease infinite;
}
.loader {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap:1rem;
font-size: 1.3.rem;
height: 100%;
padding-top: 4rem;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<main>
<nav id="nav">
<form id="searchForm" onsubmit="return false">
<input type="search" placeholder="Search TLDs" id="search" />
</form>
</nav>
<output id="output"></output>
<div class="loader" id="loader">
<div></div>
<span>Loading...</span>
</div>
</main>
<script type="module">
import punycode from "https://unpkg.com/[email protected]/punycode.es6.js"
async function getTLDs(){
let res = await fetch("https://data.iana.org/TLD/tlds-alpha-by-domain.txt");
let txt = (await res.text()).split(/\r?\n/).slice(1).map(i => `.${i.toLowerCase()} ${(/xn--/gmi).test(i) ? `<span class="hl">(.${punycode.decode(i.slice(4))})</span>` : ""}`);
txt.pop()
return txt;
}
function search(str){
let ul = document.getElementById("tlds");
let lis = Array.from(ul.querySelectorAll("li"));
lis.forEach(l => {
if(l.textContent.includes(str)){
l.classList.remove("hidden");
}
else {
l.classList.add("hidden");
}
});
}
(async()=>{
let output = document.getElementById("output");
let ul = document.createElement("ul");
ul.id ="tlds";
let searchBox = document.getElementById("search");
let data = await getTLDs();
document.getElementById("loader").remove();
data.forEach(d => {
let li = document.createElement("li");
li.innerHTML = d;
ul.appendChild(li);
});
output.appendChild(ul);
searchBox.addEventListener("input",(e) => {
search(e.target.value)
})
})()
</script>
</body>
</html>