simplify

parent 78c9e962
...@@ -106,12 +106,8 @@ function doQuery() { ...@@ -106,12 +106,8 @@ function doQuery() {
// and initiates an RDAP query // and initiates an RDAP query
function runQuery(url) { function runQuery(url) {
var type = document.getElementById('type'); var type = document.getElementById('type');
var i;
for (i = 0 ; i < type.options.length ; i++) { for (var i = 0 ; i < type.options.length ; i++) if ('url' == type.options[i].value) type.selectedIndex = i;
if ('url' == type.options[i].value) {
type.selectedIndex = i;
}
}
document.getElementById('object').value = url; document.getElementById('object').value = url;
doQuery(); doQuery();
} }
...@@ -126,11 +122,11 @@ function sendQuery(url) { ...@@ -126,11 +122,11 @@ function sendQuery(url) {
div.innerHTML = ''; div.innerHTML = '';
if (0 == url.indexOf('json://')) { if (0 == url.indexOf('json://')) {
// mock an XHR and run the callback // run the callback with a mock XHR
var xhr = {}; handleResponse({
xhr.status = 200; "status": 200,
xhr.responseText = url.substring(7); "responseText": url.substring(7)
handleResponse(xhr); });
} else { } else {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
...@@ -295,8 +291,7 @@ function showRawData(id) { ...@@ -295,8 +291,7 @@ function showRawData(id) {
function createList(list) { function createList(list) {
var ul = document.createElement('ul'); var ul = document.createElement('ul');
var i; for (var i = 0 ; i < list.length ; i++) {
for (i = 0 ; i < list.length ; i++) {
var li = document.createElement('li'); var li = document.createElement('li');
if (list[i] instanceof Node) { if (list[i] instanceof Node) {
li.appendChild(list[i]); li.appendChild(list[i]);
...@@ -326,8 +321,7 @@ function processEvents(events, table) { ...@@ -326,8 +321,7 @@ function processEvents(events, table) {
var stable = document.createElement('table'); var stable = document.createElement('table');
stable.style.className = 'event-table'; stable.style.className = 'event-table';
var i; for (var i = 0 ; i < events.length ; i++) {
for (i = 0 ; i < events.length ; i++) {
if (events[i].eventActor) { if (events[i].eventActor) {
text = events[i].eventDate + ' by ' + events[i].eventActor; text = events[i].eventDate + ' by ' + events[i].eventActor;
...@@ -345,8 +339,7 @@ function processEvents(events, table) { ...@@ -345,8 +339,7 @@ function processEvents(events, table) {
function processLinks(links, table) { function processLinks(links, table) {
var ul = document.createElement('ul'); var ul = document.createElement('ul');
var i; for (var i = 0 ; i < links.length ; i++) {
for (i = 0 ; i < links.length ; i++) {
li = document.createElement('li'); li = document.createElement('li');
var title = (links[i].title ? links[i].title : links[i].href); var title = (links[i].title ? links[i].title : links[i].href);
...@@ -366,9 +359,7 @@ function processLinks(links, table) { ...@@ -366,9 +359,7 @@ function processLinks(links, table) {
li.appendChild(link); li.appendChild(link);
if (links[i].rel) { if (links[i].rel) li.appendChild(document.createTextNode(' (' + links[i].rel + ')'));
li.appendChild(document.createTextNode(' (' + links[i].rel + ')'))
}
ul.appendChild(li); ul.appendChild(li);
} }
...@@ -380,10 +371,7 @@ function processLinks(links, table) { ...@@ -380,10 +371,7 @@ function processLinks(links, table) {
function processEntities(entities, table) { function processEntities(entities, table) {
var div = document.createElement('div'); var div = document.createElement('div');
var i; for (var i = 0 ; i < entities.length ; i++) div.appendChild(processObject(entities[i]));
for (i = 0 ; i < entities.length ; i++) {
div.appendChild(processObject(entities[i]));
}
addTableRow(table, 'Entities:', div); addTableRow(table, 'Entities:', div);
} }
...@@ -403,8 +391,7 @@ function processNotices(notices, table) { ...@@ -403,8 +391,7 @@ function processNotices(notices, table) {
function processRemarksOrNotices(things) { function processRemarksOrNotices(things) {
var div = document.createElement('div'); var div = document.createElement('div');
var i; for (var i = 0 ; i < things.length ; i++) {
for (i = 0 ; i < things.length ; i++) {
var tdiv = document.createElement('div'); var tdiv = document.createElement('div');
var title = document.createElement('strong'); var title = document.createElement('strong');
...@@ -447,10 +434,7 @@ function processDomain(object, table) { ...@@ -447,10 +434,7 @@ function processDomain(object, table) {
if (object.nameservers) { if (object.nameservers) {
var div = document.createElement('div'); var div = document.createElement('div');
var i; for (var i = 0 ; i < object.nameservers.length ; i++) div.appendChild(processObject(object.nameservers[i]));
for (i = 0 ; i < object.nameservers.length ; i++) {
div.appendChild(processObject(object.nameservers[i]));
}
addTableRow(table, 'Nameservers:', div); addTableRow(table, 'Nameservers:', div);
} }
...@@ -469,15 +453,13 @@ function processNameserver(object, table) { ...@@ -469,15 +453,13 @@ function processNameserver(object, table) {
if (object.ipAddresses) { if (object.ipAddresses) {
if (object.ipAddresses.v4) { if (object.ipAddresses.v4) {
var i; for (var i = 0 ; i < object.ipAddresses.v4.length ; i++) {
for (i = 0 ; i < object.ipAddresses.v4.length ; i++) {
addTableRow(table, 'IP Address:', createRDAPLink('https://rdap.org/ip/' + object.ipAddresses.v4[i], object.ipAddresses.v4[i])); addTableRow(table, 'IP Address:', createRDAPLink('https://rdap.org/ip/' + object.ipAddresses.v4[i], object.ipAddresses.v4[i]));
} }
} }
if (object.ipAddresses.v6) { if (object.ipAddresses.v6) {
var i; for (var i = 0 ; i < object.ipAddresses.v6.length ; i++) {
for (i = 0 ; i < object.ipAddresses.v6.length ; i++) {
addTableRow(table, 'IP Address:', createRDAPLink('https://rdap.org/ip/' + object.ipAddresses.v6[i], object.ipAddresses.v6[i])); addTableRow(table, 'IP Address:', createRDAPLink('https://rdap.org/ip/' + object.ipAddresses.v6[i], object.ipAddresses.v6[i]));
} }
} }
...@@ -492,15 +474,10 @@ function processEntity(object, table) { ...@@ -492,15 +474,10 @@ function processEntity(object, table) {
if (object.handle) addTableRow(table, 'Handle:', object.handle); if (object.handle) addTableRow(table, 'Handle:', object.handle);
if (object.publicIds) { if (object.publicIds) {
var i; for (var i = 0 ; i < object.publicIds.length ; i++) addTableRow(table, object.publicIds[i].type + ':', object.publicIds[i].identifier);
for (i = 0 ; i < object.publicIds.length ; i++) {
addTableRow(table, object.publicIds[i].type + ':', object.publicIds[i].identifier);
}
} }
if (object.roles) { if (object.roles) addTableRow(table, 'Roles:', createList(object.roles));
addTableRow(table, 'Roles:', createList(object.roles));
}
if (object.vcardArray && object.vcardArray[1]) { if (object.vcardArray && object.vcardArray[1]) {
var vtable = processVCardArray(object.vcardArray[1]); var vtable = processVCardArray(object.vcardArray[1]);
...@@ -514,8 +491,7 @@ function processEntity(object, table) { ...@@ -514,8 +491,7 @@ function processEntity(object, table) {
function processVCardArray(vcard) { function processVCardArray(vcard) {
var vtable = document.createElement('table'); var vtable = document.createElement('table');
var i; for (var i = 0 ; i < vcard.length ; i++) {
for (i = 0 ; i < vcard.length ; i++) {
var node = vcard[i]; var node = vcard[i];
var type = node[0]; var type = node[0];
...@@ -539,9 +515,7 @@ function processVCardArray(vcard) { ...@@ -539,9 +515,7 @@ function processVCardArray(vcard) {
if (node[1].type) { if (node[1].type) {
var j; var j;
for (j = 0 ; j < node[1].type ; j++) { for (j = 0 ; j < node[1].type ; j++) {
if ('fax' == node[1].type[j]) { if ('fax' == node[1].type[j]) type = 'Fax';
type = 'Fax';
}
} }
} }
...@@ -580,9 +554,7 @@ function processVCardArray(vcard) { ...@@ -580,9 +554,7 @@ function processVCardArray(vcard) {
value = link; value = link;
} }
if (value) { if (value) addTableRow(vtable, type + ':', value);
addTableRow(vtable, type + ':', value);
}
} }
return vtable; return vtable;
...@@ -600,20 +572,9 @@ function processIp(object, table) { ...@@ -600,20 +572,9 @@ function processIp(object, table) {
// given an object, return the "self" URL (if any) // given an object, return the "self" URL (if any)
function getSelfLink(object) { function getSelfLink(object) {
if (object.links) { if (object.links) for (var i = 0 ; i < object.links.length ; i++) if ('self' == object.links[i].rel) return object.links[i].href;
var i;
for (i = 0 ; i < object.links.length ; i++) {
if ('self' == object.links[i].rel) {
return object.links[i].href;
}
}
return null; return null;
} else {
return null;
}
} }
// create an RDAP link: a link pointing to an RDAP URL // create an RDAP link: a link pointing to an RDAP URL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment