2022-09-27 01:58:32 +00:00
|
|
|
(function() {
|
|
|
|
var locked = false,
|
|
|
|
input = document.getElementById('lookup-input'),
|
|
|
|
submit = document.getElementById('lookup-submit'),
|
2022-09-29 22:27:07 +00:00
|
|
|
result = document.getElementById('lookup-result'),
|
|
|
|
tabs = document.getElementById('lookup-tabs');
|
2022-09-27 01:58:32 +00:00
|
|
|
|
|
|
|
var lock = function() {
|
|
|
|
if(locked)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
document.body.classList.add('whois-locked');
|
|
|
|
input.disabled = true;
|
|
|
|
locked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var unlock = function() {
|
|
|
|
if(!locked)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
document.body.classList.remove('whois-locked');
|
|
|
|
input.disabled = false;
|
|
|
|
locked = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var lookup = function(target) {
|
|
|
|
if(!lock())
|
|
|
|
return;
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest;
|
|
|
|
xhr.addEventListener('load', function() {
|
|
|
|
var resp = JSON.parse(xhr.responseText);
|
|
|
|
|
2022-09-29 22:27:07 +00:00
|
|
|
if(resp.error)
|
2022-09-27 01:58:32 +00:00
|
|
|
alert(resp.text);
|
|
|
|
|
2022-09-29 22:27:07 +00:00
|
|
|
tabs.innerHTML = '';
|
|
|
|
if(resp.result && resp.result.responses) {
|
|
|
|
for(var i = 0; i < resp.result.responses.length; ++i) {
|
|
|
|
(function(response) {
|
|
|
|
var tab = document.createElement('a'),
|
|
|
|
tabHeader = document.createElement('div'),
|
|
|
|
tabServer = document.createElement('div');
|
|
|
|
|
|
|
|
tab.href = 'javascript:;';
|
|
|
|
tab.className = 'whois-result-tab';
|
|
|
|
if(i === 0) tab.className += ' whois-result-tab-active';
|
|
|
|
|
|
|
|
tab.onclick = function() {
|
|
|
|
var active = document.querySelector('.whois-result-tab-active');
|
|
|
|
if(active) active.classList.remove('whois-result-tab-active');
|
|
|
|
tab.classList.add('whois-result-tab-active');
|
|
|
|
result.textContent = response.lines.join("\r\n").trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
tabHeader.className = 'whois-result-tab-header';
|
|
|
|
tabHeader.textContent = i === 0 ? 'Result' : ('Hop #' + (resp.result.responses.length - i).toString());
|
|
|
|
|
|
|
|
tabServer.className = 'whois-result-tab-server';
|
|
|
|
tabServer.textContent = response.server;
|
|
|
|
console.log(response);
|
|
|
|
|
|
|
|
tab.appendChild(tabHeader);
|
|
|
|
tab.appendChild(tabServer);
|
|
|
|
tabs.appendChild(tab);
|
|
|
|
})(resp.result.responses[i]);
|
2022-09-27 01:58:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-29 22:27:07 +00:00
|
|
|
if(tabs.firstChild)
|
|
|
|
tabs.firstChild.click();
|
|
|
|
|
2022-09-27 01:58:32 +00:00
|
|
|
unlock();
|
|
|
|
});
|
|
|
|
xhr.open('GET', '/whois/lookup?target=' + encodeURIComponent(target));
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
var readHash = function() {
|
|
|
|
if(location.hash.length < 2) {
|
|
|
|
result.textContent = 'Enter a domain or IP address!';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var target = decodeURIComponent(location.hash.substring(1));
|
|
|
|
if(input.value !== target)
|
|
|
|
input.value = target;
|
|
|
|
lookup(target);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('hashchange', function(ev) {
|
|
|
|
readHash();
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
submit.addEventListener('click', function(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
location.hash = encodeURIComponent(input.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
readHash();
|
|
|
|
})();
|