-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainProject.html
More file actions
175 lines (144 loc) · 5.24 KB
/
mainProject.html
File metadata and controls
175 lines (144 loc) · 5.24 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AJAX Messaging Project</title>
<style>
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
#controlPanel {
background-color: #F0F000;
height: 100%;
float: left;
width: 20%;
}
#reportArea {
background-color: #00F0F0;
height: 100%;
width: 100%;
}
.panelTitle {
padding: 0;
margin: 0;
color: red;
text-align: center;
}
/* NOTE: This, combined with the mods to the input[type=text] CSS, make the
fields of the form all line up on the right border (0px from the right)
*/
#checkMessagesToPanel, #checkMessagesFromPanel, #newUserPanel, #newMessagePanel, #getUsersPanel {
border: 2px solid black;
position: relative;
}
/* This, with the relative positioning of the panels (see above) is
one way to get the inputs to line up all nicely and flush against
the right hand side of the panels.
Position absolute positions elements relative to their nearest
positioned ancestor so this is putting items 0px from the right
hand side of the panel divs...lines them up nicely.
*/
input[type=text] {
width: 100px;
position: absolute;
right: 0px;
}
</style>
</head>
<body>
<div id="controlPanel">
<div id="checkMessagesToPanel">
<p class="panelTitle">Check Messages To A User</p>
<form action="javascript:getMessagesTo();" method="get">
Username: <input type="text" name="user" id="getMessagesToUser">
<br>
<input type="submit" value="Click here to submit">
</form>
</div>
<div id="checkMessagesFromPanel">
<p class="panelTitle">Messages From Panel</p>
<form action="javascript:getMessagesFrom();" method="get">
Username: <input type="text" name="user" id="getMessagesFromUser">
<br>
<input type="submit" value="Click here to submit">
</form>
</div>
<div id="newMessagePanel">
<p class="panelTitle">New Message Panel</p>
<form action="javascript:sendMessage();" method="get">
Your username: <input type="text" name="sender" id="sendMessageSender">
<br>
To (username): <input type="text" name="to" id="sendMessageTo">
<br>
Subject: <input type="text" name="subject" id="sendMessageSubject">
<br>
Body: <input type="textarea" name="body" id="sendMessageBody">
<br>
<input type="submit" value="Click here to submit">
</form>
</div>
<div id="newUserPanel">
<p class="panelTitle">New User Panel</p>
<form action="javascript:addUser();" method="get">
Username: <input type="text" name="username" id="addUserUsername">
<br>
Password: <input type="text" name="password" id="addUserPassword">
<br>
Email: <input type="text" name="email" id="addUserEmail">
<br>
First Name: <input type="text" name="firstName" id="addUserFirstName">
<br>
Last Name: <input type="text" name="lastName" id="addUserLastName">
<br>
<input type="submit" value="Click here to submit">
<br>
</form>
</div>
<div id="getUsersPanel">
<p class="panelTitle">Get Users Panel</p>
<form action="javascript:getUsers();" method="get">
<input type="submit" value ="Click here to get Users">
</form>
</div>
</div>
<div id="reportArea">
This div is where the content from your AJAX requests will show up.
</div>
<script>
function processPage(responseText){
document.getElementById("reportArea").innerHTML = responseText;
}
function getMessagesTo(){
var url = 'getMessagesTo.php?user=' + document.getElementById("getMessagesToUser").value;
httpGetAsync(url, processPage);
}
function getMessagesFrom(){
var url = 'getMessagesFrom.php?user=' + document.getElementById("getMessagesFromUser").value;
httpGetAsync(url, processPage);
}
function getUsers(){
var url = 'getUsers.php';
httpGetAsync(url, processPage);
}
function addUser(){
var url = 'addUser.php?username=' + document.getElementById("addUserUsername").value + '&password=' + document.getElementById("addUserPassword").value + '&email=' + document.getElementById("addUserEmail").value + '&firstName=' + document.getElementById("addUserFirstName").value + '&lastName=' + document.getElementById("addUserLastName").value;
httpGetAsync(url, processPage);
}
function sendMessage(){
var url = 'sendMessage.php?sender=' + document.getElementById("sendMessageSender").value + '&to=' + document.getElementById("sendMessageTo").value + '&subject=' + document.getElementById("sendMessageSubject").value + '&body=' + document.getElementById("sendMessageBody").value;
httpGetAsync(url, processPage);
}
function httpGetAsync(theUrl, callbackFunctionWhenPageLoaded) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callbackFunctionWhenPageLoaded(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
}
</script>
</body>
</html>