From 615974e961fb4ec596fbdf534870f83da301aea4 Mon Sep 17 00:00:00 2001 From: masslightsquared Date: Tue, 7 Feb 2023 13:14:18 -0500 Subject: [PATCH] updated authapi.js --- application/static/src/authapi.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/application/static/src/authapi.js b/application/static/src/authapi.js index d13d8aa..ab634ef 100644 --- a/application/static/src/authapi.js +++ b/application/static/src/authapi.js @@ -1,15 +1,19 @@ function resetApiKey() { - document.getElementById('modal').classList.toggle('hidden') + const modal = document.getElementById("modal"); + modal.classList.toggle("hidden"); } +const apiKeyForm = document.getElementById("api-key-form"); +if (apiKeyForm) { + apiKeyForm.addEventListener("submit", function(event) { + event.preventDefault(); -var el2 = document.getElementById('api-key-form'); -if (el2) { - el2.addEventListener("submit", function (event) { - event.preventDefault() - var apiKey = document.getElementById("api-key-input").value; - document.getElementById('modal').classList.toggle('hidden') - localStorage.setItem('apiKey', apiKey) - document.getElementById('api-key-input').value = '' - }); + const apiKeyInput = document.getElementById("api-key-input"); + const apiKey = apiKeyInput.value; + + localStorage.setItem("apiKey", apiKey); + + apiKeyInput.value = ""; + modal.classList.toggle("hidden"); + }); }