From aeaaf3a8e99944ba00efcc896c3e2ba751a856ac Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 18 Jun 2019 10:32:29 +0200 Subject: [PATCH] Fixed bug with setting cookie --- website/javascript/cookies.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/website/javascript/cookies.js b/website/javascript/cookies.js index 7ccfee0..9bc7709 100644 --- a/website/javascript/cookies.js +++ b/website/javascript/cookies.js @@ -38,13 +38,16 @@ function saveCookies() { function insertAPIKeyFromCookie() { getCookies(); key = cookies["apikey"]; - document.getElementById("apikey").value = key; - checkAPIkey() + if (key != null && key != undefined) { + document.getElementById("apikey").value = key; + checkAPIkey(); + } + } function saveAPIkey() { - key = APIkey() - setCookie("apikey",key) + key = APIkey(); + setCookie("apikey",key); } @@ -57,6 +60,7 @@ function checkAPIkey() { if (this.readyState == 4 && (this.status == 204 || this.status == 205)) { document.getElementById("apikey").style.backgroundColor = "lawngreen" apikeycorrect = true + saveAPIkey(); } else { document.getElementById("apikey").style.backgroundColor = "red" @@ -71,9 +75,6 @@ function checkAPIkey() { document.getElementById("apikey").style.backgroundColor = "red" apikeycorrect = false } - if (apikeycorrect) { - saveAPIkey(); - } } function APIkey() {