Skip to content

Commit a8ede42

Browse files
committed
updated
1 parent a8b4423 commit a8ede42

File tree

1 file changed

+58
-60
lines changed

1 file changed

+58
-60
lines changed

assets/spa.js

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function jsonToHTML(value, path, objectIsReallyArray) {
4242
const k = Object.keys(value).at(i);
4343

4444
const details = div.appendChild(document.createElement("details"));
45-
details.open = true;
45+
details.open = false;
4646

4747
const summary = jsonToHTML(true === objectIsReallyArray ? parseInt(k) : k);
4848
summary.classList.add("json-key");
@@ -284,82 +284,80 @@ if (doTest) button.click();
284284
const sendEmailTo = function(entity) {
285285
let lastTestedURL = rdapValidator.testedURL;
286286

287+
let email;
288+
287289
try {
288290
lastTestedURL = rdapValidator.lastTestedResponse.links.filter(l => "self" == l.rel && "application/rdap+json" == l.type).shift().href;
289291

292+
email = entity.vcardArray[1].filter(p => "EMAIL" === p[0].toUpperCase()).shift()[3];
293+
290294
} catch (e) {
291-
console.log(e);
295+
alert(`Unable to extract URL and/or email address: ${e}`);
292296

293297
}
294298

295-
try {
296-
const email = entity.vcardArray[1].filter(p => "EMAIL" === p[0].toUpperCase()).shift()[3];
297-
298-
const url = new URL("mailto:"+email);
299+
const url = new URL("mailto:"+email);
299300

300-
let subject, body;
301+
let subject, body;
301302

302-
if (rdapValidator.errors < 1) {
303-
subject = 'No issues with your RDAP server';
304-
body = [
305-
"Hey there, I tested your RDAP server using the RDAP Validator at this URL:",
306-
"",
307-
document.location.href,
308-
"",
309-
"And everything looks fine! Thanks for your care and attention.",
310-
];
303+
if (rdapValidator.errors < 1) {
304+
subject = 'No issues with your RDAP server';
305+
body = [
306+
"Hey there, I tested your RDAP server using the RDAP Validator at this URL:",
307+
"",
308+
document.location.href,
309+
"",
310+
"And everything looks fine! Thanks for your care and attention.",
311+
"",
312+
];
311313

312-
} else {
313-
subject = `I found ${self.errors} error(s) with your RDAP server`;
314-
315-
body = [
316-
"***NOTE TO SENDER: PLEASE BE POLITE!***",
317-
"",
318-
"Hey there, I found an issue with your RDAP server using the RDAP Validator at this URL:",
319-
"",
320-
document.location.href,
321-
"",
322-
`Tested URL: ${lastTestedURL}`,
323-
`Response Type: ${rdapValidator.responseTypes[rdapValidator.lastTestedResponseType]}`,
324-
`Server Type: ${rdapValidator.serverTypes[rdapValidator.lastTestedServerType]}`,
325-
"",
326-
"List of errors:",
327-
"",
328-
];
329-
330-
rdapValidator.log.forEach(function(msg) {
331-
if (false === msg[0]) {
332-
body.push(`Error: ${msg[1]}`);
333-
if ("$" !== msg[2]) body.push(`JSON Path: ${msg[2]}`);
334-
if (msg[3]) body.push(`Reference: ${msg[3]}`);
335-
body.push("");
336-
}
337-
});
338-
339-
body.push("Server response:", "");
314+
} else {
315+
subject = `I found ${self.errors} error(s) with your RDAP server`;
316+
317+
body = [
318+
"***NOTE TO SENDER: PLEASE BE POLITE!***",
319+
"",
320+
"Hey there, I found an issue with your RDAP server using the RDAP Validator at this URL:",
321+
"",
322+
document.location.href,
323+
"",
324+
`Tested URL: ${lastTestedURL}`,
325+
`Response Type: ${rdapValidator.responseTypes[rdapValidator.lastTestedResponseType]}`,
326+
`Server Type: ${rdapValidator.serverTypes[rdapValidator.lastTestedServerType]}`,
327+
"",
328+
"List of errors:",
329+
"",
330+
];
331+
332+
rdapValidator.log.forEach(function(msg) {
333+
if (false === msg[0]) {
334+
body.push(`Error: ${msg[1]}`);
335+
if ("$" !== msg[2]) body.push(`JSON Path: ${msg[2]}`);
336+
if (msg[3]) body.push(`Reference: ${msg[3]}`);
337+
body.push("");
338+
}
339+
});
340340

341-
Object.keys(rdapValidator.lastTestedResponseHeaders).forEach(function(k) {
342-
body.push(k + ": " + rdapValidator.lastTestedResponseHeaders[k]);
343-
});
344-
body.push("");
345-
body = body.concat(JSON.stringify(rdapValidator.lastTestedResponse, null, " ").split("\n"));
346-
}
341+
body.push("Server response:", "");
347342

348-
subject = escape(subject);
349-
body = escape(body.join("\n"));
343+
Object.keys(rdapValidator.lastTestedResponseHeaders).forEach(function(k) {
344+
body.push(k + ": " + rdapValidator.lastTestedResponseHeaders[k]);
345+
});
346+
body.push("");
347+
body = body.concat(JSON.stringify(rdapValidator.lastTestedResponse, null, " ").split("\n"));
350348

351-
url.search = `?subject=${subject}&body=${body}`;
349+
}
352350

353-
const iframe = document.createElement('iframe');
354-
iframe.setAttribute('src', url.toString());
355-
iframe.style.setProperty('display', 'none');
351+
subject = escape(subject);
352+
body = escape(body.join("\n"));
356353

357-
document.body.appendChild(iframe);
354+
url.search = `?subject=${subject}&body=${body}`;
358355

359-
} catch (e) {
360-
console.log(e);
356+
const iframe = document.createElement('iframe');
357+
iframe.setAttribute('src', url.toString());
358+
iframe.style.setProperty('display', 'none');
361359

362-
}
360+
document.body.appendChild(iframe);
363361
};
364362

365363
document.getElementById("report-button").addEventListener("click", function() {

0 commit comments

Comments
 (0)