Skip to content

Instantly share code, notes, and snippets.

@JohnnyJumper
Created February 4, 2021 06:23
Show Gist options
  • Save JohnnyJumper/4d4c5f655d9b7698cf92d0e039b5e7fa to your computer and use it in GitHub Desktop.
Save JohnnyJumper/4d4c5f655d9b7698cf92d0e039b5e7fa to your computer and use it in GitHub Desktop.
function cleanDOM(parent) {
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
}
function displayResolution(resolution) {
const {ownerAddress, resolverAddress, records} = resolution;
const mainContainer = document.getElementById('records');
cleanDOM(mainContainer);
const ownerRecord = document.createElement('span');
ownerRecord.innerHTML = `ownerAddress: ${ownerAddress}`;
const resolverRecord = document.createElement('span');
resolverRecord.innerHTML = `resolverAddress: ${resolverAddress}`;
mainContainer.appendChild(ownerRecord);
mainContainer.appendChild(resolverRecord);
Object.entries(records).map(([key, value]) => {
const recordSpan = document.createElement('span');
if (!value) {
recordSpan.style.color = 'red';
value = `No ${key} found`;
}
recordSpan.innerHTML = `${key} : ${value}`;
mainContainer.appendChild(recordSpan);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment