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 = '
';
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';
// send api request
var request = new XMLHttpRequest();
request.open('POST', 'https://dns-watch.org/lookup', true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var response = JSON.parse(this.response);
if (response['type'] == 'success') { // success
var table = '
`
}
function get_status_color(status) {
if (status === true) return 'check'
if (status === false) return 'cross'
return 'offline'
}
function get_status_icon(status) {
if (status === true) return 'check'
if (status === false) return 'x'
return 'wifi-off'
}
function get_blocked_text(cause) {
if (cause == 'cuii') return 'blocked by cuii'
if (cause !== null) return `bocked: ${cause}`
return ''
}
function show_modal(type) {
let msg;
switch (type) {
case 'search':
msg = 'dns-watch.org is a service that allows you to see how (mainly German) Internet Service Providers (ISPs) deal with Internet censorship. More Information In order to test a website for availability, enter the domain into the search bar and press Enter. Try out these examples if you are unsure: gnu.org, wikipedia.org, s.to';
break;
case 'reference':
msg = 'In order to validate the DNS responses, we use references. These references are from trustworthy DNS providers, such as Cloudflare or UncensoredDNS. The responses of the DNS providers that should be tested (located in the bottom table) will be compared to the results from the references.'
break;
case 'blocked-cuii':
msg = 'This ISP (and all others with the same error message) blocked the request on behalf of CUII. CUII is a German institution that censors parts of the Internet because of so-called copyright claims. For more information about the CUII, read our Why? page.'
break;
case 'random':
msg = 'This domain uses randomized responses. Some websites return different IP addresses for load balancing. Therefore, dns-watch.org can\'t compare the results of these DNS responses and will only check for common blocking patterns.'
break;
default:
msg = `It seems like something happend that shouldn\'t have happened! Dialog message type: ${ type }`
break;
}
document.getElementById('modal-message').innerHTML = msg
document.getElementById('modal').style.display = 'block'
}
function close_modal() {
document.getElementById('modal').style.display = 'none'
}
// add event triggers
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('dnswatch-search-submit').addEventListener('click', (event) => {
dnswatch_search();
});
document.getElementById('dnswatch-search').addEventListener('keyup', (event) => {
if (event.keyCode === 13) {
event.preventDefault();
dnswatch_search();
}
});
window.onclick = function (event) {
if (event.target == document.getElementById('modal'))
close_modal()
}
});