-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenter-api-key.html
More file actions
40 lines (35 loc) · 1.39 KB
/
Copy pathenter-api-key.html
File metadata and controls
40 lines (35 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<title>API Key</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>Please enter a valid API key.</div>
<form>
<input type="email" id="apiKey" name="apiKey"/>
<button id="submitApiKey">Submit</button>
</form>
<script>
let rootPath = "https://mysite.itvarsity.org/api/ContactBook/";
document.getElementById("submitApiKey").addEventListener('click', setApiKey);
function setApiKey(e){
e.preventDefault();
apiKey = document.getElementById("apiKey").value;
fetch(rootPath + "controller/api-key/?apiKey=" + apiKey)
.then(function (response) {
return response.text();
})
.then(function (data) {
if (data == "1") {
localStorage.setItem("apiKey", apiKey);
window.open("index.html", "_self");
} else {
alert(data + "Invalid API key entered!");
}
})
}
</script>
</body>
</html>