-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (43 loc) · 1.46 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Socket.IO chat</title>
</head>
<body>
<ul id="messages"></ul>
<div>
<label>Name</label> <br>
<input name="name" type="text" value="Van Anh">
</div>
<br>
<div>
<label>Title</label> <br>
<input name="title" autocomplete="off" value="Đã tải lên 1 file trong Create a Pacs.008 Foreign Currency "/>
</div>
<br>
<button id="send_notify">Submit</button>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script>
var socket = io();
$('#send_notify').on('click', function (e) {
let name = $('input[name="name"]').val();
let title = $('input[name="title"]').val();
let time = getCurrentTime();
socket.emit('chat message', title, name, time);
});
function getCurrentTime() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0'); // Tháng bắt đầu từ 0
const year = now.getFullYear();
// return `${hours}:${minutes}:${seconds} ${day}/${month}/${year}`;
return `${hours}:${minutes}:${seconds}`;
}
</script>
</body>
</html>