-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.html
251 lines (231 loc) · 7.85 KB
/
home.html
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Offline Video | Voice chat | Home</title>
<link rel="stylesheet" href="./index.css">
<script src="./js/jquery-1.12.4.js"></script>
<style>
.text-white{
color: #fff;
}
.friend{
margin:8px 0;
background-color: #aaa;
width:max-content;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.me{
display: flex;
justify-content: flex-end;
}
.me .msg{
margin:8px 0;
max-width:50%;
min-width: min-content;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
word-wrap: break-word;
background-color: blueviolet;
}
.message-control {
border: none;
outline: none;
padding: 10px;
max-width: 100%;
min-width: 100%;
max-height: 60px;
min-height: 60px;
}
.sidebar {
width: 400px;
height: 100vh;
background-color: gray;
}
#close_sidebar{
display: none;
}
#open_sidebar{
display: none;
}
.topheader > div {
margin-right: 15px;
}
@media screen and (max-width: 500px) {
#close_sidebar{
display: block;
cursor: pointer;
color: #fff;
font-size: x-large;
}
#open_sidebar{
display: block;
cursor: pointer;
font-size: x-large;
}
.sidebar {
width: 0px;
min-width: 0;
overflow: hidden;
height: 100vh;
background-color: gray;
transition:all .3s ease-in;
}
.open-sidebar{
min-width:100% !important;
overflow: visible;
}
}
</style>
</head>
<body>
<div class="r-app h-100v bg-gray-400">
<div class="row">
<div class="sidebar">
<div class="hr-row justify-between px-2">
<h3 class="text-center text-white my-2" id="uname"></h3>
<div id="close_sidebar">×</div>
</div>
<div class="d-col v-scroll h-full">
<div class="friendbar my-2 p-2 text-white">
Jonas
</div>
<div class="friendbar my-2 p-2 text-white">
Khaleed
</div>
<div class="friendbar my-2 p-2 text-white">
Lezni
</div>
<div class="friendbar my-2 p-2 text-white">
Croatia
</div>
<div class="friendbar my-2 p-2 text-white">
James
</div>
</div>
</div>
<div class="main d-col w-full h-100v">
<div class="d-col h-full v-scroll centered">
<h3>Click on any friend to start chat</h3>
</div>
</div>
</div>
</div>
<script>
let data = [],name;
window.location.search.split('&').forEach(elem => {
data.push(elem.split('=')[1]);
});
name = data[1].replace('%20',' ')
$('#uname').text(name);
class chat {
constructor() {
this.videoStream;
this.audioStream;
this.answerCall;
this.rejectCall;
this.caller;
this.me;
this.CurrentFriend;
}
getVideoStream(){
if(navigator.mediaDevices) {
this.videoStream = navigator.mediaDevices.getUserMedia({
video:true,
audio:true
})
}
return this;
}
userName(name) {
this.me = name;
return this;
}
callFriend(){
}
}
const myChat = new chat();
myChat.userName(name);
// friends Select
let frnds = document.querySelectorAll('.friendbar');
for(let i=0;i<frnds.length;i++) {
frnds[i].onclick = e => {
for(let j=0;j<frnds.length;j++){
if(j == i) {
myChat.CurrentFriend = e.target.innerText;
e.target.classList.toggle('bg-primary');
dispFriendChat();
}else{
frnds[j].classList.remove('bg-primary');
}
}
}
}
function dispFriendChat() {
$('.main').get(0).innerHTML =
`
<div class="p-2 row justify-between">
<div class="topheader hr-row">
<div id="open_sidebar">☰</div>
<div class="">Voice</div>
<div class="">Video</div>
<div class="">Share</div>
</div>
<div class="">
<h3>${myChat.CurrentFriend}</h3>
</div>
</div>
<div class="d-col h-full v-scroll">
<div class="message_area flex-1" id="message_area">
<div class="friend p-2">
Hello how are you doing
</div>
</div>
<div class="inputs">
<form class="form-inline" id="messageform">
<div class="form-group flex-1">
<textarea type="text" id="message" class="message-control" placeholder="Type here"></textarea>
</div>
<div class="form-group">
<button type="submit" id="btn" class="btn btn-login">Send</button>
</div>
</form>
</div>
</div>
`;
// Start Messaging
let marea = $('#message_area');
let message;
$('#messageform').on('submit',(e) => {
e.preventDefault();
message = $('#message').val();
if(message == ''){
$('#message').focus()
}else{
marea.append(
`<div class="me">
<div class="msg p-2 text-white">
${message}
</div>
</div>`
);
$('#message').val('')
$('#message').focus()
}
});
// End Messaging
}
// friends Select
// Sidebar
$('#close_sidebar').on('click',(e) => {
$('.sidebar').toggleClass('open-sidebar')
});
$('#open_sidebar').on('click',(e) => {
$('.sidebar').toggleClass('open-sidebar')
});
// Sidebar
</script>
</body>
</html>