-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchat_window.php
210 lines (177 loc) · 8.38 KB
/
chat_window.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
208
209
210
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="js/create_friendlist.js"></script>
<script type="text/javascript" src="js/load_chat.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/save_chat_to_database.js"></script>
<script type="text/javascript" src="js/refresh_chat.js"></script>
<script type="text/javascript" src="js/changeName.js"></script>
<script type="text/javascript" src="js/logout.js"></script>
<script type="text/javascript" src="js/sound.js"></script>
<script type="text/javascript" src="js/scroller_sound.js"></script>
<style>
body
{
background-image:url('images/chat_back.jpg');
}
#container
{
overflow:scroll;
}
</style>
</head>
<body onload="create_friendlist();scroll();">
<div id="current_user" style="position:absolute;margin-left:1000px;margin-top:20px;">
<span style="color:white">Currently Logged in as : </span>
<span style="font-size:20px;color:#d9534f"><?php session_start(); echo ucfirst(strtolower($_SESSION['name']));?></span>
</div>
<div style="width:700px ; height:100px; position:absolute;margin-left:130px;margin-top:20px;"><p style="color:white;font-family:cursive;font-size:40px;">messenger</p></div>
<div>
<span onclick="logout_menu()" style="float:right ;
margin-right:15px ;margin-top:17px; margin-bottom:10px;"><button style="font-size:18px;border-radius:100%" class="btn btn-danger"><?php echo strtoupper(substr($_SESSION['name'], 0 , 1));?></button></span>
<div id="logout_panel" class="panel panel-danger" style="visibility:hidden ; width:300px ; height:110px; position:absolute; margin-left:1060px; margin-top:65px; z-index:+1">
<div class="panel-body">
<div style="float:left;"><button style="border-radius:100%" class="btn btn-danger btn-lg"><span style="font-size:37px;"> <?php echo strtoupper(substr($_SESSION['name'], 0 , 1));?> </span></button></span></div>
<div style="float:left ; margin-left:15px;">
</br>
<span style="font-size:17px;color:#003300"><?php echo ucfirst(strtolower($_SESSION['name']));?></span></br>
<span style="font-size:15px;color:grey"><?php echo strtolower($_SESSION['email']);?></span>
</div>
</div>
<div class="panel-footer">
<table width="100%">
<tr><td><button class="btn btn-default btn-md" disabled="true" onclick="logout()">Edit Profile  <span class="glyphicon glyphicon-user"></span></button></td>
<td><button class="btn btn-default btn-md" onclick="logout()">Log Out  <span class="glyphicon glyphicon-off"></span></button></td></tr>
</table>
</div>
</div>
</div>
<!--div id="current" style='position:absolute; margin-top:90px;margin-left:600px;'><span style='color:red;'>Currently chatting to  <span id="username" style='color:white;font-size:16px;'><?php //if(isset($_SESSION['friend_name_lv'])) echo ucfirst(strtolower($_SESSION['friend_name_lv'])); else echo ' . . . . .';?></span></span></div-->
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-7" style="margin-top:120px;">
<div class="panel panel-info" style="position:fixed;">
<div class="panel-body">
<div style="height:45px ; width:732px ; background-color:#065E52; position:fixed ; z-index:+1">
<span style="float:left">
<div id="current" style="margin-top:5px ; margin-left:20px; "><button style="font-size:14px;border-radius:100%" class="btn btn-danger" id="first_letter"><?php if(isset($_SESSION['friend_name_lv'])) echo strtoupper(substr($_SESSION['friend_name_lv'], 0 , 1)); else echo "_" ;?></button></span>  <span id="username" style='color:white;font-size:15px;'><?php if(isset($_SESSION['friend_name_lv'])) echo ucfirst(strtolower($_SESSION['friend_name_lv'])); else echo 'no friend selected';?></span></div>
</span>
<span style="float:right">
<div id="chat_sound">
<!--p style="color:white">Notification sound</p-->
<a href="#"><span id="mute" class="glyphicon glyphicon-volume-up" style="font-size:30px;color:white;margin-top:5px;margin-right:20px;"></span></a>
</div>
</span>
</div>
<div id="chat_space" style="padding-left:30px;padding-right:30px;padding-top:60px;height:400px ; width:750px ; background-image:url('images/back.jpg') ;overflow-y:scroll;"> <!--#f15d58-->
<p id="display" style="color:red;font-family:sans-serif;font-size:14px;">loading chat for you ...</p>
<!--display chats here-->
</div>
</div>
<div class="panel-footer">
<div id="footer-container">
<div class="row">
<div class="col-md-10">
<div class="form-group">
<input id="message" type="text" class="form-control">
</div>
</div>
<div class="col-md-2">
<button onclick="save_chat_to_database(); scroll(); refresh_chat();" type="button" class="btn btn-success btn-block">send</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
</div>
<div class="col-md-3">
<div class="list-group" style="width:300px;position:fixed;margin-left:20px;margin-top:120px;">
<a href="#" class="list-group-item disabled">
<span class="glyphicon glyphicon-user" style="color:#065E52"></span>  
<span style="color:#065E52">Friend List</span>
</a>
<div id="friends">
<!--put friends here-->
</div>
</div>
</div>
</div>
<!--div id="chat_sound" style="position:absolute;margin-left:1200px;width:200px;height:100px;">
<!--p style="color:white">Notification sound</p-->
<!--a href="#"><span id="mute" class="glyphicon glyphicon-volume-up" style="font-size:50px;color:red;"></span></a>
</div-->
<script type="text/javascript">
setInterval (function() {
refresh_chat();
//scroll();
//alert("refreshing chat");
} , 1000);
function scroll()
{
$("#chat_space").animate({ scrollTop: $(document).height()+10000000}, 'slow');
scroller_sound();
}
var check=1;
function logout_menu()
{
if(check==1)
{
check=0;
document.getElementById("logout_panel").style.visibility = "hidden";
}
else
{
check=1;
document.getElementById("logout_panel").style.visibility = "visible";
setTimeout(function(){
document.getElementById("logout_panel").style.visibility = "hidden";
check=0;
}, 10000);
}
}
$("#mute").click(function() {
var myClass = $(this).attr("class");
if(myClass=="glyphicon glyphicon-volume-up")
{
$("#mute").removeClass("glyphicon glyphicon-volume-up").addClass("glyphicon glyphicon-volume-off");
sound1();
}
else
{
$("#mute").removeClass("glyphicon glyphicon-volume-off").addClass("glyphicon glyphicon-volume-up");
sound1();
}
});
var sound = new Audio();
sound.src = "sounds/message.mp3";
function play_sound()
{
sound.play();
}
function pause_sound()
{
sound.pause();
}
window.addEventListener("keydown", dealWithKeyboard, false);
function dealWithKeyboard(e)
{
if(e.keyCode == 13)
{
// check for focus in the text box
save_chat_to_database();
scroll();
refresh_chat();
}
}
</script>
<?php
$_SESSION['sound'] = 1;
?>
</body>
</html>