From 78d6474f9e431de01810b4b8a62a753c82e4deba Mon Sep 17 00:00:00 2001 From: Gavsto Date: Fri, 19 Nov 2021 13:54:18 +0000 Subject: [PATCH 1/2] FIX: Fixed Domain Warning not removing class --- js/DomainFormChecker.js | 220 ++++++++++++++++++++-------------------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/js/DomainFormChecker.js b/js/DomainFormChecker.js index 4a7a49a3628b..934550812fbe 100644 --- a/js/DomainFormChecker.js +++ b/js/DomainFormChecker.js @@ -1,143 +1,143 @@ function ExecuteDomainAPICall() { - var form = $('#DomainForm'); - var postdata = getFormData(form); //ThisCreatesANiceSpinnerWhileWeWait - var loaderspinelement = document.getElementById("loaderspin"); - loaderspinelement.classList.remove("invisible"); - $.ajax({ - 'async': true, - 'global': false, - 'url': "api/ListDomainTests", - 'type': "post", - 'data': JSON.stringify(postdata), - 'contentType': "application/json", - 'success': function (data) { + var form = $('#DomainForm'); + var postdata = getFormData(form); //ThisCreatesANiceSpinnerWhileWeWait + var loaderspinelement = document.getElementById("loaderspin"); + loaderspinelement.classList.remove("invisible"); + $.ajax({ + 'async': true, + 'global': false, + 'url': "api/ListDomainTests", + 'type': "post", + 'data': JSON.stringify(postdata), + 'contentType': "application/json", + 'success': function (data) { - var loaderspinelement = document.getElementById("loaderspin"); - loaderspinelement.classList.add("invisible"); + var loaderspinelement = document.getElementById("loaderspin"); + loaderspinelement.classList.add("invisible"); - // Clear existing data - ClearExistingClasses(); + // Clear existing data + ClearExistingClasses(); - // Get the Background Colour for SPF - GenerateHTMLColour('spfCard', data[0].SPFFinalState) + // Get the Background Colour for SPF + GenerateHTMLColour('spfCard', data[0].SPFFinalState) - // Get the Background Colour for SPF Indicator - GenerateHTMLColour('spfindicator', data[0].SPFFinalState) + // Get the Background Colour for SPF Indicator + GenerateHTMLColour('spfindicator', data[0].SPFFinalState) - // Get the Background Font Colour for SPF - GenerateHTMLHeaderColour('spfHeader', data[0].SPFFinalState) + // Get the Background Font Colour for SPF + GenerateHTMLHeaderColour('spfHeader', data[0].SPFFinalState) - // Link the arrays with a break - var arrSPFFails = data[0].SPFResults.ValidationFails.join("
"); - var arrSPFWarns = data[0].SPFResults.ValidationWarns.join("
"); - var arrSPFPasses = data[0].SPFResults.ValidationPasses.join("
"); + // Link the arrays with a break + var arrSPFFails = data[0].SPFResults.ValidationFails.join("
"); + var arrSPFWarns = data[0].SPFResults.ValidationWarns.join("
"); + var arrSPFPasses = data[0].SPFResults.ValidationPasses.join("
"); - // Set the HTML for the SPF Records - $('#domainResultsSPFRecord').html(data[0].SPFResults.Record); - $('#domainResultsSPFPasses').html(GenerateHTMLResult(arrSPFPasses)); - $('#domainResultsSPFWarns').html(GenerateHTMLResult(arrSPFWarns)); - $('#domainResultsSPFFails').html(GenerateHTMLResult(arrSPFFails)); + // Set the HTML for the SPF Records + $('#domainResultsSPFRecord').html(data[0].SPFResults.Record); + $('#domainResultsSPFPasses').html(GenerateHTMLResult(arrSPFPasses)); + $('#domainResultsSPFWarns').html(GenerateHTMLResult(arrSPFWarns)); + $('#domainResultsSPFFails').html(GenerateHTMLResult(arrSPFFails)); - // Get the Background Colour for DMARC - GenerateHTMLColour('dmarcCard', data[0].DMARCFinalState) + // Get the Background Colour for DMARC + GenerateHTMLColour('dmarcCard', data[0].DMARCFinalState) - // Get the Background Colour for DMARC Indicator - GenerateHTMLColour('dmarcindicator', data[0].DMARCFinalState) + // Get the Background Colour for DMARC Indicator + GenerateHTMLColour('dmarcindicator', data[0].DMARCFinalState) - // Get the Background Font Colour for DMARC - console.log(data[0].DMARCFinalState) - GenerateHTMLHeaderColour('dmarcHeader', data[0].DMARCFinalState) + // Get the Background Font Colour for DMARC + console.log(data[0].DMARCFinalState) + GenerateHTMLHeaderColour('dmarcHeader', data[0].DMARCFinalState) - var arrDMARCFails = data[0].DMARCResults.ValidationFails.join("
"); - var arrDMARCWarns = data[0].DMARCResults.ValidationWarns.join("
"); - var arrDMARCPasses = data[0].DMARCResults.ValidationPasses.join("
"); + var arrDMARCFails = data[0].DMARCResults.ValidationFails.join("
"); + var arrDMARCWarns = data[0].DMARCResults.ValidationWarns.join("
"); + var arrDMARCPasses = data[0].DMARCResults.ValidationPasses.join("
"); - $('#domainResultsDMARCRecord').html(data[0].DMARCResults.Record); - $('#domainResultsDMARCPasses').html(GenerateHTMLResult(arrDMARCPasses)); - $('#domainResultsDMARCWarns').html(GenerateHTMLResult(arrDMARCWarns)); - $('#domainResultsDMARCFails').html(GenerateHTMLResult(arrDMARCFails)); + $('#domainResultsDMARCRecord').html(data[0].DMARCResults.Record); + $('#domainResultsDMARCPasses').html(GenerateHTMLResult(arrDMARCPasses)); + $('#domainResultsDMARCWarns').html(GenerateHTMLResult(arrDMARCWarns)); + $('#domainResultsDMARCFails').html(GenerateHTMLResult(arrDMARCFails)); - // Get the Background Colour for MX - GenerateHTMLColour('mxCard', data[0].MXFinalState) + // Get the Background Colour for MX + GenerateHTMLColour('mxCard', data[0].MXFinalState) - // Get the Background Colour for MX Indicator - GenerateHTMLColour('mxindicator', data[0].MXFinalState) + // Get the Background Colour for MX Indicator + GenerateHTMLColour('mxindicator', data[0].MXFinalState) - // Get the Background Font Colour for MX - console.log(data[0].MXFinalState) - GenerateHTMLHeaderColour('mxHeader', data[0].MXFinalState) + // Get the Background Font Colour for MX + console.log(data[0].MXFinalState) + GenerateHTMLHeaderColour('mxHeader', data[0].MXFinalState) - var arrMXFails = data[0].MXResults.ValidationFails.join("
"); - var arrMXWarns = data[0].MXResults.ValidationWarns.join("
"); - var arrMXPasses = data[0].MXResults.ValidationPasses.join("
"); + var arrMXFails = data[0].MXResults.ValidationFails.join("
"); + var arrMXWarns = data[0].MXResults.ValidationWarns.join("
"); + var arrMXPasses = data[0].MXResults.ValidationPasses.join("
"); - console.log(data[0]); - $('#domainResultsMXRecord').html(data[0].MXResults.Records.Hostname); - $('#domainResultsMXRecordPasses').html(GenerateHTMLResult(arrMXPasses)); - $('#domainResultsMXRecordFails').html(GenerateHTMLResult(arrMXFails)); - $('#domainResultsMXRecordWarns').html(GenerateHTMLResult(arrMXWarns)); - $('#domainResultsMXMailProvider').html('

Mail Provider: ' + data[0].MXResults.MailProvider.Name + '

'); + console.log(data[0]); + $('#domainResultsMXRecord').html(data[0].MXResults.Records.Hostname); + $('#domainResultsMXRecordPasses').html(GenerateHTMLResult(arrMXPasses)); + $('#domainResultsMXRecordFails').html(GenerateHTMLResult(arrMXFails)); + $('#domainResultsMXRecordWarns').html(GenerateHTMLResult(arrMXWarns)); + $('#domainResultsMXMailProvider').html('

Mail Provider: ' + data[0].MXResults.MailProvider.Name + '

'); - // Get the Background Colour for DNSSEC - GenerateHTMLColour('dnssecCard', data[0].DNSSECFinalState) + // Get the Background Colour for DNSSEC + GenerateHTMLColour('dnssecCard', data[0].DNSSECFinalState) - // Get the Background Colour for DNSSEC Indicator - GenerateHTMLColour('dnssecindicator', data[0].DNSSECFinalState) + // Get the Background Colour for DNSSEC Indicator + GenerateHTMLColour('dnssecindicator', data[0].DNSSECFinalState) - // Get the Background Font Colour for DNSSEC - console.log(data[0].DNSSECFinalState) - GenerateHTMLHeaderColour('dnssecHeader', data[0].DNSSECFinalState) + // Get the Background Font Colour for DNSSEC + console.log(data[0].DNSSECFinalState) + GenerateHTMLHeaderColour('dnssecHeader', data[0].DNSSECFinalState) - var arrDNSSECFails = data[0].DNSSECResults.ValidationFails.join("
"); - var arrDNSSECWarns = data[0].DNSSECResults.ValidationWarns.join("
"); - var arrDNSSECPasses = data[0].DNSSECResults.ValidationPasses.join("
"); - var arrDNSSECKeys = data[0].DNSSECResults.Keys.join("
"); + var arrDNSSECFails = data[0].DNSSECResults.ValidationFails.join("
"); + var arrDNSSECWarns = data[0].DNSSECResults.ValidationWarns.join("
"); + var arrDNSSECPasses = data[0].DNSSECResults.ValidationPasses.join("
"); + var arrDNSSECKeys = data[0].DNSSECResults.Keys.join("
"); - console.log(data[0]); - $('#domainResultsDNSSECRecord').html(arrDNSSECKeys); - $('#domainResultsDNSSECRecordPasses').html(GenerateHTMLResult(arrDNSSECPasses)); - $('#domainResultsDNSSECRecordFails').html(GenerateHTMLResult(arrDNSSECFails)); - $('#domainResultsDNSSECRecordWarns').html(GenerateHTMLResult(arrDNSSECWarns)); + console.log(data[0]); + $('#domainResultsDNSSECRecord').html(arrDNSSECKeys); + $('#domainResultsDNSSECRecordPasses').html(GenerateHTMLResult(arrDNSSECPasses)); + $('#domainResultsDNSSECRecordFails').html(GenerateHTMLResult(arrDNSSECFails)); + $('#domainResultsDNSSECRecordWarns').html(GenerateHTMLResult(arrDNSSECWarns)); - // Get the Background Colour for DKIM - GenerateHTMLColour('dkimCard', data[0].DKIMFinalState) + // Get the Background Colour for DKIM + GenerateHTMLColour('dkimCard', data[0].DKIMFinalState) - // Get the Background Colour for DKIM Indicator - GenerateHTMLColour('dkimindicator', data[0].DKIMFinalState) + // Get the Background Colour for DKIM Indicator + GenerateHTMLColour('dkimindicator', data[0].DKIMFinalState) - // Get the Background Font Colour for DKIM - console.log(data[0].DKIMFinalState) - GenerateHTMLHeaderColour('dkimHeader', data[0].DNSSECFinalState) + // Get the Background Font Colour for DKIM + console.log(data[0].DKIMFinalState) + GenerateHTMLHeaderColour('dkimHeader', data[0].DNSSECFinalState) - var arrDKIMFails = data[0].DKIMResults.ValidationFails.join("
"); - var arrDKIMWarns = data[0].DKIMResults.ValidationWarns.join("
"); - var arrDKIMPasses = data[0].DKIMResults.ValidationPasses.join("
"); + var arrDKIMFails = data[0].DKIMResults.ValidationFails.join("
"); + var arrDKIMWarns = data[0].DKIMResults.ValidationWarns.join("
"); + var arrDKIMPasses = data[0].DKIMResults.ValidationPasses.join("
"); - $('#domainResultsDKIMRecord').html(data[0].DKIMResults.Records[0].Record); - $('#domainResultsDKIMRecordPasses').html(GenerateHTMLResult(arrDKIMPasses)); - $('#domainResultsDKIMRecordFails').html(GenerateHTMLResult(arrDKIMFails)); - $('#domainResultsDKIMRecordWarns').html(GenerateHTMLResult(arrDKIMWarns)); + $('#domainResultsDKIMRecord').html(data[0].DKIMResults.Records[0].Record); + $('#domainResultsDKIMRecordPasses').html(GenerateHTMLResult(arrDKIMPasses)); + $('#domainResultsDKIMRecordFails').html(GenerateHTMLResult(arrDKIMFails)); + $('#domainResultsDKIMRecordWarns').html(GenerateHTMLResult(arrDKIMWarns)); - }, - 'error': function (xhr, ajaxOptions, thrownError) { - $('#domainResultsDiv').html('Failed to connect to API: ' + thrownError); - } - }); - } + }, + 'error': function (xhr, ajaxOptions, thrownError) { + $('#domainResultsDiv').html('Failed to connect to API: ' + thrownError); + } + }); +} function GenerateHTMLResult(result) { - if(result.includes('PASS')) { + if (result.includes('PASS')) { var final = result.replace(/PASS:/g, '') return final } - if(result.includes('WARN')) { + if (result.includes('WARN')) { var final = result.replace(/WARN:/g, '') return final } - if(result.includes('FAIL')) { + if (result.includes('FAIL')) { var final = result.replace(/FAIL:/g, '') return final } @@ -150,10 +150,10 @@ function ClearExistingClasses() { $('#domainResultsSPFWarns').html(''); $('#domainResultsSPFFails').html(''); var spfelement = document.getElementById("spfCard"); - spfelement.classList.remove("bg-success", "bg-warn", "bg-danger"); + spfelement.classList.remove("bg-success", "bg-warning", "bg-danger"); var spfindicator = document.getElementById("spfindicator"); - spfindicator.classList.remove("bg-success", "bg-warn", "bg-danger", "bg-dark"); + spfindicator.classList.remove("bg-success", "bg-warning", "bg-danger", "bg-dark"); // DMARC Clear $('#domainResultsDMARCRecord').html(''); @@ -161,10 +161,10 @@ function ClearExistingClasses() { $('#domainResultsDMARCWarns').html(''); $('#domainResultsDMARCFails').html(''); var dmarcelement = document.getElementById("dmarcCard"); - dmarcelement.classList.remove("bg-success", "bg-warn", "bg-danger"); + dmarcelement.classList.remove("bg-success", "bg-warning", "bg-danger"); var dmarcindicator = document.getElementById("dmarcindicator"); - dmarcindicator.classList.remove("bg-success", "bg-warn", "bg-danger", "bg-dark"); + dmarcindicator.classList.remove("bg-success", "bg-warning", "bg-danger", "bg-dark"); // MX Clear $('#domainResultsMXRecord').html(''); @@ -173,10 +173,10 @@ function ClearExistingClasses() { $('#domainResultsMXRecordWarns').html(''); $('#domainResultsMXMailProvider').html(''); var mxelement = document.getElementById("mxCard"); - mxelement.classList.remove("bg-success", "bg-warn", "bg-danger"); + mxelement.classList.remove("bg-success", "bg-warning", "bg-danger"); var mxindicator = document.getElementById("mxindicator"); - mxindicator.classList.remove("bg-success", "bg-warn", "bg-danger", "bg-dark"); + mxindicator.classList.remove("bg-success", "bg-warning", "bg-danger", "bg-dark"); // DNSSEC Clear $('#domainResultsDNSSECRecord').html(''); @@ -184,10 +184,10 @@ function ClearExistingClasses() { $('#domainResultsDNSSECRecordFails').html(''); $('#domainResultsDNSSECRecordWarns').html(''); var dnssecelement = document.getElementById("dnssecCard"); - dnssecelement.classList.remove("bg-success", "bg-warn", "bg-danger"); + dnssecelement.classList.remove("bg-success", "bg-warning", "bg-danger"); var dnssecindicator = document.getElementById("dnssecindicator"); - dnssecindicator.classList.remove("bg-success", "bg-warn", "bg-danger", "bg-dark"); + dnssecindicator.classList.remove("bg-success", "bg-warning", "bg-danger", "bg-dark"); // DKIM Clear $('#domainResultsDKIMRecord').html(''); @@ -195,10 +195,10 @@ function ClearExistingClasses() { $('#domainResultsDKIMRecordFails').html(''); $('#domainResultsDKIMRecordWarns').html(''); var dkimelement = document.getElementById("dkimCard"); - dkimelement.classList.remove("bg-success", "bg-warn", "bg-danger"); + dkimelement.classList.remove("bg-success", "bg-warning", "bg-danger"); var dkimindicator = document.getElementById("dkimindicator"); - dkimindicator.classList.remove("bg-success", "bg-warn", "bg-danger", "bg-dark"); + dkimindicator.classList.remove("bg-success", "bg-warning", "bg-danger", "bg-dark"); } function GenerateHTMLColour(id, data) { From 77ff3ea6f100c38350bffb37934ac14242b4b6f5 Mon Sep 17 00:00:00 2001 From: Gavsto Date: Fri, 19 Nov 2021 14:03:11 +0000 Subject: [PATCH 2/2] JDUPREY SUPER FIX: Form submission --- js/DomainFormChecker.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/DomainFormChecker.js b/js/DomainFormChecker.js index 934550812fbe..25cd0997f48e 100644 --- a/js/DomainFormChecker.js +++ b/js/DomainFormChecker.js @@ -1,3 +1,11 @@ +// block default form and execute API call instead +$(document).ready(function () { + $('#DomainForm').submit(function (e) { + e.preventDefault(); + ExecuteDomainAPICall(); + }); +}); + function ExecuteDomainAPICall() { var form = $('#DomainForm'); var postdata = getFormData(form); //ThisCreatesANiceSpinnerWhileWeWait