-
Notifications
You must be signed in to change notification settings - Fork 0
/
UD.html
96 lines (84 loc) · 3.32 KB
/
UD.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<title>Manage User Accounts </title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script type="text/javascript" src="UD.js"></script>
<script>
document.addEventListener('keydown', function(event)
{
var code = event.keyCode || event.which;
if (code === 9) {
e=valueOf("email")
if (e.indexOf('@') == -1)
{
str=("Please enter a valid Email address.");
alert(str.replace(/['"]+/g, ''))
// <!-- window.location.reload() -->
}
var xhr = new XMLHttpRequest();
URL="http://129.213.63.76:30080/update/"+e+"/"
xhr.open("GET", URL );
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function() {
if (this.readyState == 4 && this.status==201)
{
}
else if(this.readyState == 4 && this.status==400)
{
alert(this.responseText.replace(/['"]+/g, ''));
}
}
}
});
</script>
</head>
<body>
<form method="post" target="_blank" >
<h1>Manage User Accounts</h1>
<br>
<br>
Enter your Email address:<br>
<!-- <select name="email_addresses" id="email_addresses">
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://158.101.105.177:8000/api/v1/users/");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function() {
if (this.readyState == 4 && this.status==201)
{
var dict = JSON.parse(this.responseText)
var select = document.getElementById("email_addresses");
var el = document.createElement("option");
el.text = '';
el.value = '';
select.add(el);
for (var user of dict)
{
var el = document.createElement("option");
el.text = user.email;
el.value = user.email;
select.add(el);
}
}
else if(this.readyState == 4 && this.status==400)
{
alert(this.responseText);
}
}
</script>
</select> -->
<input type="text" name="email" ><br>
<br>
<br>
<br>
<div>
<button onclick="UpdateData()" type="button" = "update" style='margin-left:20px'>Update</button> <button style='margin-left:105px' type="button" onclick="ClearData()" name="delete">Delete</button> <button style='margin-left:130px' onclick="GetData()" name="Retrieve">List Users</button>
</div>
</form>
</body>
</html>