-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.php
158 lines (119 loc) · 3.78 KB
/
message.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
<?php
session_start();
include 'db.php';
$user_to = $_REQUEST["user_to"];
$username;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Profile</title>
<link rel="stylesheet" href="http://localhost/socialhub/css/message_sect.css">
<link rel="stylesheet" href="http://localhost/socialhub/css/header.css">
<link rel="stylesheet" href="http://localhost/socialhub/css/profile.css">
<style>
body {
background: rgba(209, 204, 204, 0.281) !important;
}
</style>
</head>
<body>
<?php
include 'header.php';
?>
<div class="message_sect_part">
<div class="right sect">
<h4><?php $user_query = $db->query("SELECT * from `users` where `username` = '$user_to'");
$user_row = $user_query->fetchAll(PDO::FETCH_OBJ);
$count_user = $user_query->rowCount();
$user_name = $user_row[0]->{"fname"}.' '.$user_row[0]->{"lname"};
echo $user_name;?></h4>
<div class="msg_sect_right">
<div class="msg_thread">
</div>
<div class="message_post">
<textarea id="msg_content" cols="30" rows="10" placeholder="Enter a message..."></textarea>
<button class="send">Send <i class="fa fa-send"></i></button>
</div>
</div> </div>
</section>
<?php
$usr = $username
?>
<script>
$(document).ready(function () {
var search = document.querySelector('button.search');
$('.msg_thread').animate({scrollTop:$('.msg_thread')[0].scrollHeight},200);
search.addEventListener("click",function()
{
location.redirect("search.php");
});
get_message();
setInterval(() => {
get_message();
get_message_head();
}, 500);
var user = "<?php echo $usr; ?>";
var user_to = "<?php echo $user_to; ?>";
// var user_to = "samy_das3003";
function get_message()
{
// $('.msg_sect_right').animate({scrollTop:$('.msg_sect_right')[0].scrollHeight},200);
$.ajax({
url: "message_thread.php",
type: "GET",
data: "user ="+user+"&user_to="+user_to+"&seen=0",
cache:false,
success: function(data) {
$('.msg_thread').html(data);
// location.reload();
}
});
}
var sent = document.querySelector('button.send');
sent.addEventListener("click",function()
{
var msg1 = $("#msg_content").val();
if(msg1!="")
{
get_messages();
}
});
function get_messages()
{
$('.msg_thread').animate({scrollTop:$('.msg_thread')[0].scrollHeight},200);
// msg_array=new Array("Hello","How are you?","What's Up?","Good Morning","Good Night","I'm fine","It's nice to meet you","Call You Later","I will reply in a minute");
// var rand =Math.floor(Math.random(0)*msg_array.length-2);
// msg = msg_array[rand];
var msg = $("#msg_content").val();
$.ajax({
url: "message_fun.php",
type: "POST",
data: "user ="+user+"&user_to="+user_to+"&msg="+msg,
cache:false,
success: function(data) {
$('.msg_thread').html(data);
// location.reload();
}
});
}
function get_message_head()
{
$.ajax({
url: "message_head.php",
type: "POST",
data: "user ="+user+"&user_to="+user_to,
cache:false,
success: function(data) {
$('.message_left').html(data);
// location.reload();
}
});
}
});
</script>
</body>
</html>