2019-03-24 18:04:44 +03:00
|
|
|
apikeycorrect = false;
|
|
|
|
|
2019-06-17 13:18:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
/// API KEY
|
|
|
|
function insertAPIKeyFromCookie() {
|
2019-06-24 16:02:38 +03:00
|
|
|
element = document.getElementById("apikey")
|
|
|
|
if (element != null && element != undefined) {
|
2019-11-20 23:10:50 +03:00
|
|
|
var key = neo.getCookie("apikey");
|
2019-06-24 16:02:38 +03:00
|
|
|
if (key != null && key != undefined) {
|
|
|
|
element.value = key;
|
|
|
|
checkAPIkey();
|
|
|
|
}
|
2019-06-18 11:32:29 +03:00
|
|
|
}
|
|
|
|
|
2019-06-24 16:02:38 +03:00
|
|
|
|
2019-06-17 13:18:19 +03:00
|
|
|
}
|
|
|
|
|
2019-06-24 16:02:38 +03:00
|
|
|
window.addEventListener("load",insertAPIKeyFromCookie);
|
|
|
|
|
|
|
|
|
2019-03-24 18:04:44 +03:00
|
|
|
function saveAPIkey() {
|
2019-06-18 11:32:29 +03:00
|
|
|
key = APIkey();
|
2019-11-20 23:10:50 +03:00
|
|
|
neo.setCookie("apikey",key,false);
|
2019-03-24 18:04:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-20 07:19:02 +03:00
|
|
|
function checkAPIkey(extrafunc=null) {
|
2019-06-17 13:18:19 +03:00
|
|
|
|
|
|
|
url = "/api/test?key=" + APIkey()
|
2019-03-24 18:04:44 +03:00
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.onreadystatechange = function() {
|
|
|
|
if (this.readyState == 4 && (this.status == 204 || this.status == 205)) {
|
|
|
|
document.getElementById("apikey").style.backgroundColor = "lawngreen"
|
|
|
|
apikeycorrect = true
|
2019-06-18 11:32:29 +03:00
|
|
|
saveAPIkey();
|
2019-03-24 18:04:44 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById("apikey").style.backgroundColor = "red"
|
|
|
|
apikeycorrect = false
|
|
|
|
}
|
2019-11-20 07:19:02 +03:00
|
|
|
|
|
|
|
if (extrafunc != null) {
|
|
|
|
extrafunc();
|
|
|
|
}
|
|
|
|
|
2019-03-24 18:04:44 +03:00
|
|
|
};
|
|
|
|
try {
|
|
|
|
xhttp.open("GET",url,true);
|
|
|
|
xhttp.send();
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
document.getElementById("apikey").style.backgroundColor = "red"
|
|
|
|
apikeycorrect = false
|
2019-11-20 07:19:02 +03:00
|
|
|
if (extrafunc != null) {
|
|
|
|
extrafunc();
|
|
|
|
}
|
2019-03-24 18:04:44 +03:00
|
|
|
}
|
|
|
|
}
|
2019-05-14 13:50:31 +03:00
|
|
|
|
|
|
|
function APIkey() {
|
|
|
|
return document.getElementById("apikey").value;
|
|
|
|
}
|