1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-27 19:30:09 -07:00

Merge pull request #34 from Ionic/feature/debug-auth-data

Add debugging to auth data output.
This commit is contained in:
Andrew Van Tassel 2024-07-24 16:22:39 -06:00 committed by GitHub
commit 75349a7922
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 = '<br/>ASN Org: ' + MailHopsUtils.htmlEncode(route[i].asn.autonomous_system_organization);
asn += ' (<a href="https://dnschecker.org/asn-whois-lookup.php?query='+route[i].asn.autonomous_system_number+'" target="_blank" title="ASN Lookup">' + route[i].asn.autonomous_system_number + '</a>)'
}
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 += '<label class="tiny ui label ' + msg.message.auth[a].color + '"><img src="' + msg.message.auth[a].icon + '"/>' + msg.message.auth[a].type + ' ' + msg.message.auth[a].copy + '</label>';
// append child
items.push('<div class="item"><div class="content"><div class="header"><img src="'+ icon + '" /> ' + header + weather +' <label class="ui circular label icon" style="float: right;">'+ (i + 1) +'</label></div><div class="description">'+ description + asn + '</div></div></div>');
}
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 = '<label class="tiny ui label ' + msg.message.auth[a].color + '"><img src="' + msg.message.auth[a].icon + '"/>' + msg.message.auth[a].type + ' ' + msg.message.auth[a].copy + '</label>';
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 += '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link.substr(0,msg.message.auth[a].link.indexOf(','))+'" target="_blank">' + msg.message.auth[a].type + '</a>';
}
else {
auth += '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link+'" target="_blank">' + msg.message.auth[a].type + '</a>';
}
auth += add;
}
else if (msg.message.auth[a].link) {
var add = '';
if (-1 != msg.message.auth[a].link.indexOf(',')) {
add = '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link.substr(0,msg.message.auth[a].link.indexOf(','))+'" target="_blank">' + msg.message.auth[a].type + '</a>';
}
else {
add = '<a class="tiny ui label ' + msg.message.auth[a].color + '" href="'+msg.message.auth[a].link+'" target="_blank">' + msg.message.auth[a].type + '</a>';
}
if (debug) {
console.log("adding to auth (type link): '" + add + "'");
}
auth += add;
}
}
// append child
items.push('<div class="item"><div class="content"><div class="header"><img src="'+ icon + '" /> ' + header + weather +' <label class="ui circular label icon" style="float: right;">'+ (i + 1) +'</label></div><div class="description">'+ description + asn + '</div></div></div>');
}
// 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