1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Fixed bug with setting cookie

This commit is contained in:
Krateng 2019-06-18 10:32:29 +02:00
parent 90b510bc0a
commit aeaaf3a8e9

View File

@ -38,13 +38,16 @@ function saveCookies() {
function insertAPIKeyFromCookie() { function insertAPIKeyFromCookie() {
getCookies(); getCookies();
key = cookies["apikey"]; key = cookies["apikey"];
document.getElementById("apikey").value = key; if (key != null && key != undefined) {
checkAPIkey() document.getElementById("apikey").value = key;
checkAPIkey();
}
} }
function saveAPIkey() { function saveAPIkey() {
key = APIkey() key = APIkey();
setCookie("apikey",key) setCookie("apikey",key);
} }
@ -57,6 +60,7 @@ function checkAPIkey() {
if (this.readyState == 4 && (this.status == 204 || this.status == 205)) { if (this.readyState == 4 && (this.status == 204 || this.status == 205)) {
document.getElementById("apikey").style.backgroundColor = "lawngreen" document.getElementById("apikey").style.backgroundColor = "lawngreen"
apikeycorrect = true apikeycorrect = true
saveAPIkey();
} }
else { else {
document.getElementById("apikey").style.backgroundColor = "red" document.getElementById("apikey").style.backgroundColor = "red"
@ -71,9 +75,6 @@ function checkAPIkey() {
document.getElementById("apikey").style.backgroundColor = "red" document.getElementById("apikey").style.backgroundColor = "red"
apikeycorrect = false apikeycorrect = false
} }
if (apikeycorrect) {
saveAPIkey();
}
} }
function APIkey() { function APIkey() {