0
0

🚸 add domain validity checker (#3)

* 💫 loading animation

* 📦 compile vanilla html/css

* 📦 compile jhtml

* 🍱 upload favicon

* 🍱 add favicon
✏️ fix typo scRipt

* 📦 compile html

* 💬 change title

* 📦 compile html

* 📦 compile jhtml

* 🚸 add domain validity checker

* 🩹 utf8 warning

* 📦 compile html

* 📦 compile jhtml
This commit is contained in:
thetek 2021-04-03 14:12:19 +02:00 committed by GitHub
parent 3230fd266a
commit 08f45e9bd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 191 additions and 63 deletions

View File

@ -8,6 +8,8 @@ echo "<title>dnswatch</title>
<link rel=\"stylesheet\" href=\"index.css\">
<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;700&amp;display=swap\">
<link rel=\"shortcut icon\" type=\"image/png\" href=\"favicon.png\">
<meta content=\"text/html;charset=utf-8\" http-equiv=\"Content-Type\">
<meta content=\"utf-8\" http-equiv=\"encoding\">
<script src=\"index.js\"></script>
<script src=\"https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js\"></script>" | cat - html/index.html > temp
mv temp html/index.html

View File

@ -45,6 +45,9 @@ input, button {
font-size: 4rem;
font-weight: 200;
}
#title h1 span {
color: #4c5666;
}
#search {
text-align: center;
@ -119,6 +122,15 @@ input, button {
color: #61afef;
margin-left: 0.5rem;
}
#search #invaliddomain {
color: #e06c75;
display: none;
margin-top: 1rem;
visibility: hidden;
}
#search #invaliddomain .feather {
vertical-align: -0.3rem;
}
#results table {
margin-left: 25vw;

View File

@ -1 +1 @@
{"version":3,"sourceRoot":"","sources":["../raw/index.sass"],"names":[],"mappings":"AASA;EACC;;;AAED;EACC,kBAZS;EAaT,OAXS;EAYT,aATS;EAUT;EACA;EACA;;;AAED;EACC,aAfS;;;AAiBV;EACC;EACA;EACA;;AACA;EACC,kBA3BQ;EA4BR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;;AAEH;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAEF;EACC;;AAEC;EACC;EACA;;AACD;EACC;EACA;EACA;EACA,OAxDO;EAyDP;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACF;EACC;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;EACA;;AACA;EACC;EACA,OA/EK;;AAgFP;EACC;EACA;EACA;EACA;;AACA;EACC;EACA;;AAEJ;EACC;EACA;EACA;;AAED;EACC;EACA;EACA;;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;;AACD;EACC,OA5GO;EA6GP;;;AAGF;EACC;EACA;EACA;;AACA;EACC;;AACA;EACC;;AACA;EACC,OAvHK;;AAwHN;EACC,OAxHK;;AAyHN;EACC,OA7HK;;AA8HP;EACC;EACA;;AACD;EACC;EACA;;AACD;EACC;;AACA;EACC,OApIK;;AAqIN;EACC,OAzIK;;AA0IP;EACC;EACA;;AACA;EACC,kBA/IK;EAgJL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACD;EACC;EACA;EACA;;;AAEN;EACC;IACC;;EACD;IACC","file":"index.css"}
{"version":3,"sourceRoot":"","sources":["../raw/index.sass"],"names":[],"mappings":"AASA;EACC;;;AAED;EACC,kBAZS;EAaT,OAXS;EAYT,aATS;EAUT;EACA;EACA;;;AAED;EACC,aAfS;;;AAiBV;EACC;EACA;EACA;;AACA;EACC,kBA3BQ;EA4BR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;;AAEH;EACC;EACA;EACA;;AACA;EACC;EACA;;AACA;EACC;;;AAEH;EACC;;AAEC;EACC;EACA;;AACD;EACC;EACA;EACA;EACA,OA1DO;EA2DP;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACF;EACC;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;EACA;;AACA;EACC;EACA,OAjFK;;AAkFP;EACC;EACA;EACA;EACA;;AACA;EACC;EACA;;AAEJ;EACC;EACA;EACA;;AAED;EACC;EACA;EACA;;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;;AACD;EACC,OA9GO;EA+GP;;AAEF;EACC,OA/GQ;EAgHR;EACA;EACA;;AACA;EACC;;;AAGF;EACC;EACA;EACA;;AACA;EACC;;AACA;EACC;;AACA;EACC,OAjIK;;AAkIN;EACC,OAlIK;;AAmIN;EACC,OAvIK;;AAwIP;EACC;EACA;;AACD;EACC;EACA;;AACD;EACC;;AACA;EACC,OA9IK;;AA+IN;EACC,OAnJK;;AAoJP;EACC;EACA;;AACA;EACC,kBAzJK;EA0JL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACD;EACC;EACA;EACA;;;AAEN;EACC;IACC;;EACD;IACC","file":"index.css"}

View File

@ -2,6 +2,8 @@
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;700&amp;display=swap">
<link rel="shortcut icon" type="image/png" href="favicon.png">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<div id="header"><button><i data-feather="globe"></i></button><button><i data-feather="sun"></i></button></div><div id="title"><h1>dnswatch</h1></div><div id="search"><div id="searchbar"><div class="buttonspacer"></div><input id="dnswatch-search" type="text" placeholder="Search..."/><button id="dnswatch-search-submit"><i data-feather="search"></i></button><button id="help"><i data-feather="help-circle"></i></button></div><small>Try "gnu.org", "wikipedia.com", "s.to" or your own website!</small><div id="loadani"><div id="spinner"></div><span>loading...</span></div></div><div id="results"></div><script src="feather.js"></script>
<div id="header"><button><i data-feather="globe"></i></button><button><i data-feather="sun"></i></button></div><div id="title"><h1>dns-watch<span>.org</span></h1></div><div id="search"><div id="searchbar"><div class="buttonspacer"></div><input id="dnswatch-search" type="text" placeholder="Search..." autofocus="autofocus"/><button id="dnswatch-search-submit"><i data-feather="search"></i></button><button id="help"><i data-feather="help-circle"></i></button></div><small>Try "gnu.org", "wikipedia.com", "s.to" or your own website!</small><div id="loadani"><div id="spinner"></div><span>loading...</span></div><div id="invaliddomain"><i data-feather="x"></i><span>invalid domain.</span></div></div><div id="results"></div><script src="feather.js"></script>

View File

@ -1,11 +1,23 @@
function dnswatch_search() {
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// test if domain is invalid
if (!is_valid_domain(domain)) {
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
return;
}
document.getElementById('invaliddomain').style.visibility = 'hidden';
document.getElementById('invaliddomain').style.display = 'none';
// activate spinner
document.getElementById('loadani').style.visibility = 'visible';
document.getElementById('loadani').style.display = 'block';
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// send api request
var request = new XMLHttpRequest();
request.open('POST', 'https://dns-watch.org/search', true);
@ -16,6 +28,8 @@ function dnswatch_search() {
var response = JSON.parse(this.response);
console.log(response);
// TODO: CLEAN UP THIS MESS OF TABLE GENERATION CODE
if (response['type'] == 'success') { // success
var table = '<table>\n';
@ -71,22 +85,30 @@ function dnswatch_search() {
} else { // no success
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
if (response['error'] == 'malformed_domain') { // invalid domain - should not happen, but just in case i guess
var table = '<table></table>';
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
} else {
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
}
}
@ -104,6 +126,13 @@ function dnswatch_search() {
function is_valid_domain(str) {
let regex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/;
return regex.test(str);
}
// add event triggers
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('dnswatch-search-submit').addEventListener('click', (event) => {

View File

@ -46,6 +46,9 @@ input, button {
font-size: 4rem;
font-weight: 200;
}
#title h1 span {
color: #4c5666;
}
#search {
text-align: center;
@ -120,6 +123,15 @@ input, button {
color: #61afef;
margin-left: 0.5rem;
}
#search #invaliddomain {
color: #e06c75;
display: none;
margin-top: 1rem;
visibility: hidden;
}
#search #invaliddomain .feather {
vertical-align: -0.3rem;
}
#results table {
margin-left: 25vw;

View File

@ -1 +1 @@
{"version":3,"sourceRoot":"","sources":["../raw/index.sass"],"names":[],"mappings":"AASA;EACC;;;AAED;EACC,kBAZS;EAaT,OAXS;EAYT,aATS;EAUT;EACA;EACA;;;AAED;EACC,aAfS;;;AAiBV;EACC;EACA;EACA;;AACA;EACC,kBA3BQ;EA4BR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;;AAEH;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAEF;EACC;;AAEC;EACC;EACA;;AACD;EACC;EACA;EACA;EACA,OAxDO;EAyDP;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACF;EACC;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;EACA;;AACA;EACC;EACA,OA/EK;;AAgFP;EACC;EACA;EACA;EACA;;AACA;EACC;EACA;;AAEJ;EACC;EACA;EACA;;AAED;EACC;EACA;EACA;;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;;AACD;EACC,OA5GO;EA6GP;;;AAGF;EACC;EACA;EACA;;AACA;EACC;;AACA;EACC;;AACA;EACC,OAvHK;;AAwHN;EACC,OAxHK;;AAyHN;EACC,OA7HK;;AA8HP;EACC;EACA;;AACD;EACC;EACA;;AACD;EACC;;AACA;EACC,OApIK;;AAqIN;EACC,OAzIK;;AA0IP;EACC;EACA;;AACA;EACC,kBA/IK;EAgJL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACD;EACC;EACA;EACA;;;AAEN;EACC;IACC;;EACD;IACC","file":"index.css"}
{"version":3,"sourceRoot":"","sources":["../raw/index.sass"],"names":[],"mappings":"AASA;EACC;;;AAED;EACC,kBAZS;EAaT,OAXS;EAYT,aATS;EAUT;EACA;EACA;;;AAED;EACC,aAfS;;;AAiBV;EACC;EACA;EACA;;AACA;EACC,kBA3BQ;EA4BR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;;AAEH;EACC;EACA;EACA;;AACA;EACC;EACA;;AACA;EACC;;;AAEH;EACC;;AAEC;EACC;EACA;;AACD;EACC;EACA;EACA;EACA,OA1DO;EA2DP;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACF;EACC;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;EACA;;AACA;EACC;EACA,OAjFK;;AAkFP;EACC;EACA;EACA;EACA;;AACA;EACC;EACA;;AAEJ;EACC;EACA;EACA;;AAED;EACC;EACA;EACA;;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;;AACD;EACC,OA9GO;EA+GP;;AAEF;EACC,OA/GQ;EAgHR;EACA;EACA;;AACA;EACC;;;AAGF;EACC;EACA;EACA;;AACA;EACC;;AACA;EACC;;AACA;EACC,OAjIK;;AAkIN;EACC,OAlIK;;AAmIN;EACC,OAvIK;;AAwIP;EACC;EACA;;AACD;EACC;EACA;;AACD;EACC;;AACA;EACC,OA9IK;;AA+IN;EACC,OAnJK;;AAoJP;EACC;EACA;;AACA;EACC,kBAzJK;EA0JL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACC;EACA;;AACD;EACC;EACA;EACA;;;AAEN;EACC;IACC;;EACD;IACC","file":"index.css"}

View File

@ -1,12 +1,24 @@
*stop()
function dnswatch_search() {
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// test if domain is invalid
if (!is_valid_domain(domain)) {
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
return;
}
document.getElementById('invaliddomain').style.visibility = 'hidden';
document.getElementById('invaliddomain').style.display = 'none';
// activate spinner
document.getElementById('loadani').style.visibility = 'visible';
document.getElementById('loadani').style.display = 'block';
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// send api request
var request = new XMLHttpRequest();
request.open('POST', 'https://dns-watch.org/search', true);
@ -17,6 +29,8 @@ function dnswatch_search() {
var response = JSON.parse(this.response);
console.log(response);
// TODO: CLEAN UP THIS MESS OF TABLE GENERATION CODE
if (response['type'] == 'success') { // success
var table = '<table>\n';
@ -72,22 +86,30 @@ function dnswatch_search() {
} else { // no success
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
if (response['error'] == 'malformed_domain') { // invalid domain - should not happen, but just in case i guess
var table = '<table></table>';
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
} else {
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
}
}
@ -105,6 +127,13 @@ function dnswatch_search() {
function is_valid_domain(str) {
let regex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/;
return regex.test(str);
}
// add event triggers
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('dnswatch-search-submit').addEventListener('click', (event) => {

View File

@ -5,4 +5,4 @@
*js("///index.js")
*js("https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js")
*postjs("///feather.js")
<div id="header"><button><i data-feather="globe"></i></button><button><i data-feather="sun"></i></button></div><div id="title"><h1>dnswatch</h1></div><div id="search"><div id="searchbar"><div class="buttonspacer"></div><input id="dnswatch-search" type="text" placeholder="Search..."/><button id="dnswatch-search-submit"><i data-feather="search"></i></button><button id="help"><i data-feather="help-circle"></i></button></div><small>Try "gnu.org", "wikipedia.com", "s.to" or your own website!</small><div id="loadani"><div id="spinner"></div><span>loading...</span></div></div><div id="results"></div>
<div id="header"><button><i data-feather="globe"></i></button><button><i data-feather="sun"></i></button></div><div id="title"><h1>dns-watch<span>.org</span></h1></div><div id="search"><div id="searchbar"><div class="buttonspacer"></div><input id="dnswatch-search" type="text" placeholder="Search..." autofocus="autofocus"/><button id="dnswatch-search-submit"><i data-feather="search"></i></button><button id="help"><i data-feather="help-circle"></i></button></div><small>Try "gnu.org", "wikipedia.com", "s.to" or your own website!</small><div id="loadani"><div id="spinner"></div><span>loading...</span></div><div id="invaliddomain"><i data-feather="x"></i><span>invalid domain.</span></div></div><div id="results"></div>

View File

@ -1,11 +1,23 @@
function dnswatch_search() {
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// test if domain is invalid
if (!is_valid_domain(domain)) {
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
return;
}
document.getElementById('invaliddomain').style.visibility = 'hidden';
document.getElementById('invaliddomain').style.display = 'none';
// activate spinner
document.getElementById('loadani').style.visibility = 'visible';
document.getElementById('loadani').style.display = 'block';
// get domain
var domain = document.getElementById('dnswatch-search').value.toLowerCase();
// send api request
var request = new XMLHttpRequest();
request.open('POST', 'https://dns-watch.org/search', true);
@ -16,6 +28,8 @@ function dnswatch_search() {
var response = JSON.parse(this.response);
console.log(response);
// TODO: CLEAN UP THIS MESS OF TABLE GENERATION CODE
if (response['type'] == 'success') { // success
var table = '<table>\n';
@ -71,22 +85,30 @@ function dnswatch_search() {
} else { // no success
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
if (response['error'] == 'malformed_domain') { // invalid domain - should not happen, but just in case i guess
var table = '<table></table>';
document.getElementById('results').innerHTML = '<table></table>';
feather.replace();
document.getElementById('invaliddomain').style.visibility = 'visible';
document.getElementById('invaliddomain').style.display = 'block';
} else {
var table = '<table>\n';
table += '<tr>\n';
// status
table += '<td class="status cross">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// provider icon
table += '<td class="icon">\n';
table += '<i data-feather="x"></i>\n';
table += '</td>\n';
// name and address
table += `<td class="name">ERROR: ${ response["error"] }</td>\n`;
table += '<td class="desc ref"></td>\n';
table += '<td class="help"></td>\n';
table += '</tr>\n';
table += '</table>';
}
}
@ -104,6 +126,13 @@ function dnswatch_search() {
function is_valid_domain(str) {
let regex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/;
return regex.test(str);
}
// add event triggers
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('dnswatch-search-submit').addEventListener('click', (event) => {

View File

@ -3,17 +3,20 @@
button: i( data-feather='sun' )
#title
h1 dnswatch
h1 dns-watch<span>.org</span>
#search
#searchbar
.buttonspacer
input#dnswatch-search( type='text' placeholder='Search...' )
input#dnswatch-search( type='text' placeholder='Search...' autofocus )
button#dnswatch-search-submit: i( data-feather='search' )
button#help: i( data-feather='help-circle' )
small Try "gnu.org", "wikipedia.com", "s.to" or your own website!
#loadani
#spinner
span loading...
#invaliddomain
i( data-feather='x' )
span invalid domain.
#results

View File

@ -46,6 +46,8 @@ input, button
h1
font-size: 4rem
font-weight: 200
span
color: darken($c-fg, 50%)
#search
text-align: center
@ -111,6 +113,14 @@ input, button
color: $c-blue
margin-left: .5rem
#invaliddomain
color: $c-red
display: none
margin-top: 1rem
visibility: hidden
.feather
vertical-align: -.3rem
#results
table
margin-left: 25vw