diff --git a/js/mailhops_details.js b/js/mailhops_details.js index be6dafb..63f9e48 100644 --- a/js/mailhops_details.js +++ b/js/mailhops_details.js @@ -47,15 +47,17 @@ function updateContent(msg, noauth) { document.getElementById('hop-message').classList.add('warning'); document.getElementById('mh-map-button').style.display = 'none'; document.getElementById('hop-message-header').innerHTML = msg.message.error; - return; } - document.getElementById('hop-message').classList.remove('warning'); - document.getElementById('mh-map-button').style.display = 'inline-block'; + else { + document.getElementById('hop-message').classList.remove('warning'); + document.getElementById('mh-map-button').style.display = 'inline-block'; + } const route = msg.response.route || []; const sender = msg.message.sender || null; const unit = msg.options.unit || "mi"; const theme = msg.options.theme || "light"; + const debug = msg.options.debug || false; let client = null; let items = []; @@ -128,30 +130,43 @@ function updateContent(msg, noauth) { asn = '
ASN Org: ' + MailHopsUtils.htmlEncode(route[i].asn.autonomous_system_organization); asn += ' (' + route[i].asn.autonomous_system_number + ')' } - - var auth = ''; - if (!noauth && msg.message.auth.length) { - for (var a = 0; a < msg.message.auth.length; a++){ - if (msg.message.auth[a].icon) { - auth += ''; + + // append child + items.push('
' + header + weather +'
'+ description + asn + '
'); + } + + var auth = ''; + if (!noauth && msg.message.auth.length) { + for (var a = 0; a < msg.message.auth.length; a++){ + if (msg.message.auth[a].icon) { + var add = ''; + if (debug) { + console.log("adding to auth (type icon): '" + add + "'"); } - else if (msg.message.auth[a].link) { - if (-1 !== msg.message.auth[a].link.indexOf(',')) { - auth += '' + msg.message.auth[a].type + ''; - } - else { - auth += '' + msg.message.auth[a].type + ''; - } + auth += add; + } + else if (msg.message.auth[a].link) { + var add = ''; + if (-1 != msg.message.auth[a].link.indexOf(',')) { + add = '' + msg.message.auth[a].type + ''; } + else { + add = '' + msg.message.auth[a].type + ''; + } + if (debug) { + console.log("adding to auth (type link): '" + add + "'"); + } + auth += add; } } - // append child - items.push('
' + header + weather +'
'+ description + asn + '
'); } + // header - document.getElementById('hop-message-header').innerHTML = `${route.length} Hops`; - if (sender && client) { - document.getElementById('hop-message-header').innerHTML += ' over '+MailHopsUtils.getDistance(sender, client, unit) + ' ' + unit; + if (!msg.message.error) { + document.getElementById('hop-message-header').innerHTML = `${route.length} Hops`; + if (sender && client) { + document.getElementById('hop-message-header').innerHTML += ' over '+MailHopsUtils.getDistance(sender, client, unit) + ' ' + unit; + } } // hop list