diff --git a/src/main/resources/templates/simple_fingerprint_ui.html b/src/main/resources/templates/simple_fingerprint_ui.html index a84fd87568fff5412371467670997fc8adfae0a6..7d8b0b08e8677e93d4abb12d1a3a0240e93aa162 100644 --- a/src/main/resources/templates/simple_fingerprint_ui.html +++ b/src/main/resources/templates/simple_fingerprint_ui.html @@ -252,37 +252,41 @@ // set up accordion $('#accordion').on('hidden.bs.collapse', toggleIcon); $('#accordion').on('shown.bs.collapse', toggleIcon); - // bind to ECA status lookup submit - document.getElementById("eclipse-eca-lookup-form").addEventListener("submit", function (e) { - // don't submit the form as we will handle it w/ ajax - e.preventDefault(); - // grab the constants from the form and perform a check - const inputVal = $(e.target).find('#email-input').val(); - const $submitButton = $(e.target).find('button'); - // disable the button so that requests won't be spammed - $submitButton.attr("disabled", "disabled"); - // use ajax to check the ECA status of the user - $.ajax({ - url: `/git/eca/lookup`, - data: { - email: inputVal - }, - success: function (data) { - toast(`There is a valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'success'); - }, - error: function (xhr) { - console.log(xhr.status); - if (xhr.status == '403') { - toast(`There is no valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'danger'); - } else { - toast(`No Eclipse Foundation account found for <em>${escapeHTML(inputVal)}</em>`, 'warning'); - } - }, - complete: function () { - $submitButton.removeAttr("disabled"); - } - }); - }); + + // bind to ECA status lookup submit if present + var lookupForm = document.getElementById("eclipse-eca-lookup-form"); + if (lookupForm !== null) { + lookupForm.addEventListener("submit", function (e) { + // don't submit the form as we will handle it w/ ajax + e.preventDefault(); + // grab the constants from the form and perform a check + const inputVal = $(e.target).find('#email-input').val(); + const $submitButton = $(e.target).find('button'); + // disable the button so that requests won't be spammed + $submitButton.attr("disabled", "disabled"); + // use ajax to check the ECA status of the user + $.ajax({ + url: `/git/eca/lookup`, + data: { + email: inputVal + }, + success: function (data) { + toast(`There is a valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'success'); + }, + error: function (xhr) { + console.log(xhr.status); + if (xhr.status == '403') { + toast(`There is no valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'danger'); + } else { + toast(`No Eclipse Foundation account found for <em>${escapeHTML(inputVal)}</em>`, 'warning'); + } + }, + complete: function () { + $submitButton.removeAttr("disabled"); + } + }); + }); + } // Revalidation button binding const revalidationForm = document.getElementById("git-eca-hook-revalidation");