-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
57 lines (53 loc) · 2.46 KB
/
index.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
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<?php require_once('src/MyApp/Db.php'); ?>
<html lang="ru">
<head>
<title>чат для тех кого заебали пробки</title>
<script src="statick/jquery-3.2.1.js"></script>
<link rel="stylesheet" href="statick/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="statick/bootstrap/dist/css/bootstrap-theme.css">
<link rel="stylesheet" href="statick/main.css">
<script src="statick/bootstrap/dist/js/bootstrap.js"></script>
<meta charset="utf-8"/>
</head>
<body>
<div class="panel panel-default">
<div class="panel-heading">
Добро пожаловать в чат посвящонный пробкам в Москве и области
</div>
<div class="panel-body pre-scrollable" id="container">
<?php $db = new \MyApp\Db() ?>
<?php foreach (array_reverse($db->getLastRecords()) as $message): ?>
<?php if ($message['id'] % 2 == 0): ?>
<div class="alert alert-success"><?php echo $message['message'] ?></div>
<?php else: ?>
<div class="alert alert-warning"><?php echo $message['message'] ?></div>
<?php endif; ?>
<?php endforeach; ?>
</div>
<div class="panel-heading">
<center><input id="mess" type="text" style="width: 80%"/>
<button type="button" id="send">Отправить</button>
</center>
</div>
</div>
</body>
<script>
var conn = new WebSocket('ws://sidimvprobke.com:49181');
$("#container").animate({ scrollTop: $('#container').prop("scrollHeight")}, 1000);
conn.onopen = function (e) {
$('#container').append("<div class='alert alert-info'>Вы подключились к чату заебали пробки точка ру, материться не воспрещаеться! Приятного общения.</div>");
};
conn.onmessage = function (e) {
$('#container').append("<div class='alert alert-success'>" + e.data + "</div>");
$("#container").animate({ scrollTop: $('#container').prop("scrollHeight")}, 1000);
};
$('#send').on('click', function () {
var message = $('#mess').val();
$('#mess').val('');
conn.send(message);
$('#container').append("<div class='alert alert-warning'>" + message + "</div>");
$("#container").animate({ scrollTop: $('#container').prop("scrollHeight")}, 1000);
});
</script>
</html>