-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathtest.html
More file actions
72 lines (64 loc) · 2.38 KB
/
test.html
File metadata and controls
72 lines (64 loc) · 2.38 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
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
<html>
<head>
<title>Friends Javascript Tester</title>
<script>
function printFriendsList(userid)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
var xml_doc = xmlhttp.responseXML;
var friends_list = xml_doc.getElementsByTagName('friend');
if (friends_list.length> 0)
{
var friendshtml = "<table id='requeststable' class='requesttable' border='1' >";
for(var i = 0; i < friends_list.length; i += 1)
{
var userid = friends_list[i].getElementsByTagName('userid')[0].textContent;
var fname = friends_list[i].getElementsByTagName('fname')[0].textContent;
var lname = friends_list[i].getElementsByTagName('lname')[0].textContent;
var friendsstatus = parseInt(friends_list[i].getElementsByTagName('friendsstatus')[0].textContent);
friendshtml += "<tr><td><a href='profile.php?id=" + userid + "' 'alt='" + fname + " " + lname + "\'s Profile'>" + fname + " " + lname + "</a></td><td>";
switch(friendsstatus)
{
case -1:
friendshtml += "My Profile <img src='check.png' width='12' height='13' />";
break;
case 0:
friendshtml += "<button type=\"button\" style=\"font: 24px;\" onclick=\"window.location = 'addfriend.php?id=" + userid + "';\">+1 Friend</button>";
break;
case 1:
friendshtml += "<img src='check.png' width='12' height='13' />Friends";
break;
case 2:
friendshtml += "Friend request pending!";
break;
case 3:
friendshtml += "This user wants to be friends. <button type='button' onclick=\"window.location = 'addfriend.php?id=" + userid + "';\">Approve</button> <button type='button' onclick=\"window.location = 'denyrequest.php?id=" + userid + "';\">Deny</button>";
break;
default:
friendshtml += "we;ve got a problem";
}
friendshtml += "</td></tr>";
}
friendshtml += "</table>";
document.getElementById('friendslist').innerHTML = friendshtml;
}
` else
{
document.getElementById('friendslist').innerHTML = "<h1>No Friends :(</h1>";
}
}
}
xmlhttp.open("GET","getfriends.php?id=" + userid, true)
xmlhttp.send()
}
</script>
</head>
<body>
<span id="friendslist"></span>
<input type="button" value="Get Friends" onclick="printFriendsList(8)" />
</body>
</html>