-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailbox.inc.php
207 lines (191 loc) · 5.43 KB
/
mailbox.inc.php
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
$autocomplete_friends = array();
$q = ' SELECT name FROM dvoo_citizens WHERE scode <> "" ORDER BY name ASC ';
$r = $db->query($q);
foreach ( $r AS $o ) {
$autocomplete_friends[] = $o['name'];
}
?>
<div id="mailbox-content">
<h2><?php print t('YOUR_MAILBOX'); ?></h2>
<div id="mailbox-messages">
<h4><?php print t('YOUR_MESSAGES'); ?></h4>
</div>
<div id="mailbox-friendlist">
<h4><?php print t('YOUR_FRIENDS'); ?></h4>
<form type="POST" id="mailbox-invite-form" onsubmit="inviteFriend();return false;">
<input type="hidden" name="action" value="invite-request" />
<input type="hidden" name="scode" value="<?php print $key; ?>" />
<input type="text" name="invite-friend-name" id="invite-friend-name" value="" />
<input type="submit" id="invite-friend-submit" value="<?php print t('INVITE'); ?>" />
</form>
<div id="mailbox-invite-status"></div>
<div id="mailbox-friendlist-list">
</div>
</div>
<div id="mailbox-mainscreen">
</div>
<script type="text/javascript">
$(function() {
var availableItems = [ <?php print '"'.implode('","', $autocomplete_friends).'"'; ?> ];
$("#invite-friend-name").autocomplete({
source: availableItems,
minLength: 3
});
var flcl = $.ajax({
type: 'POST',
url: 'mailbox.contactlist.php',
data: 'u=<?php print $key; ?>',
success: function(msg) {
$('#mailbox-friendlist-list').html(msg);
}
});
var flml = $.ajax({
type: 'POST',
url: 'mailbox.message.php',
data: 'action=list&u=<?php print $key; ?>',
success: function(msg) {
$('#mailbox-messages').html(msg);
}
});
});
function inviteFriend() {
$("#invite-friend-submit").hide();
$("#mailbox-invite-status").html("<div class=\'loading\'></div>");
var ai = $.post(
"mailbox.invite.php",
$("#mailbox-invite-form").serialize(),
function(data){
$("#mailbox-invite-status").hide().html(data).slideDown(800).delay(5000).slideUp(400);
$("#invite-friend-submit").fadeIn(500);
var flcl = $.ajax({
type: 'POST',
url: 'mailbox.contactlist.php',
data: 'u=<?php print $key; ?>',
success: function(msg) {
$('#mailbox-friendlist-list').html(msg);
}
});
}
);
}
function inviteAction(a,f) {
$("#invite-friend-submit").hide();
$("#mailbox-invite-status").html("<div class=\'loading\'></div>");
var ia = $.post(
"mailbox.invite.php",
"action=invite-"+a+"&u=<?php print $key; ?>&f="+f,
function(data){
$("#mailbox-invite-status").hide().html(data).slideDown(800).delay(5000).slideUp(400);
$("#invite-friend-submit").fadeIn(500);
$("#mailbox-friendlist-list").html("<div class=\'loading\'></div>");
var flcl = $.ajax({
type: 'POST',
url: 'mailbox.contactlist.php',
data: 'u=<?php print $key; ?>',
success: function(msg) {
$('#mailbox-friendlist-list').html(msg);
}
});
}
);
}
function contactAction(a,f) {
var ia = $.post(
"mailbox.invite.php",
"action=contact-"+a+"&u=<?php print $key; ?>&f="+f,
function(data){
$("#mailbox-invite-status").hide().html(data).slideDown(800).delay(5000).slideUp(400);
$("#mailbox-friendlist-list").html("<div class=\'loading\'></div>");
var flcl = $.ajax({
type: 'POST',
url: 'mailbox.contactlist.php',
data: 'u=<?php print $key; ?>',
success: function(msg) {
$('#mailbox-friendlist-list').html(msg);
}
});
}
);
}
function mailAction(a,m) {
var ia = $.post(
"mailbox.message.php",
"action="+a+"&u=<?php print $key; ?>&m="+m,
/*function(data){
var iov = $('#io').val();
var flml = $.ajax({
type: 'POST',
url: 'mailbox.message.php',
data: 'action=list&u=<?php print $key; ?>&io='+iov,
success: function(msg) {
$('#mailbox-messages').html(msg);
}
});
}*/
function() {
$('#msg'+m).slideUp().remove();
}
);
}
function createMsg(f) {
var nm = $.post(
"mailbox.message.php",
"action=create&f="+f+"&u=<?php print $key; ?>",
function(data){
$("#mailbox-mainscreen").html(data);
$("#msg-subject").focus().select();
}
);
}
function answerMsg() {
$("#mailbox-msg-button").remove();
var am = $.post(
"mailbox.message.php",
$("#mailbox-message").serialize(),
function(data){
$("#mailbox-mainscreen").html(data);
$("#msg-subject").focus().select();
}
);
}
function sendMsg() {
$("#mailbox-msg-button").remove();
var sm = $.post(
"mailbox.message.php",
$("#mailbox-newmessage").serialize(),
function(data){
$("#mailbox-mainscreen").html(data);
}
);
}
function readMsg(m) {
var nm = $.post(
"mailbox.message.php",
"action=read&m="+m+"&u=<?php print $key; ?>",
function(data){
$("#mailbox-mainscreen").html(data);
var iov = $('#io').val();
var flml = $.ajax({
type: 'POST',
url: 'mailbox.message.php',
data: 'action=list&u=<?php print $key; ?>&io='+iov,
success: function(msg) {
$('#mailbox-messages').html(msg);
}
});
}
);
}
function togglePostbox(n) {
var flml = $.ajax({
type: 'POST',
url: 'mailbox.message.php',
data: 'action=list&u=<?php print $key; ?>&io='+n,
success: function(msg) {
$('#mailbox-messages').html(msg);
}
});
}
</script>
</div>