-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (74 loc) · 3.21 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
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
<!DOCTYPE html>
<html lang="fr">
<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>The Chatbox</title>
<link rel="stylesheet" href="./css/style.css" type="text/css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="js/client.js" type="text/javascript"></script>
<script src="./socket.io/socket.io.js" type="text/javascript"></script>
</head>
<body>
<audio id="notif" src="./sound/new-message.mp3" type="audio/mpeg"></audio>
<div class="login">
<h1>The ChatBox</h1>
<p class="invalid"></p>
<form action="" id="loginform">
<input type="text" id="pseudo" placeholder="Pseudo">
<!-- <input class=""type="submit" id="submit" value="Connexion"> -->
</form>
<button onclick="FadeOutLogin();" id="submitPseudo">Connection</button>
</div>
<div class="chat" id="chat">
<div id="chatbox" class="chatbox"></div>
<div class="bar">
<form id="message-form">
<textarea name="message" class="text-container" maxlength="4000" id="message"></textarea>
<input id="submit-message" class="send-container" type="submit" value="Envoyer">
</form>
<!-- <textarea name="message" maxlength="4000" class="text-container" id="message"></textarea> -->
<!-- <button class="send-container" onclick="newMessage()">Envoyer</button> -->
</div>
</div>
<script src="./socket.io/socket.io.js" type="text/javascript"></script>
<script type="text/javascript">
var socket = io.connect();
const textarea = document.getElementById("message");
textarea.addEventListener("input", function (e) {
console.log(this.style.height);
var chat = document.getElementById("chat");
var height = document.getElementById("chat").style.height;
if (this.scrollHeight < 350) {
this.style.height = (this.scrollHeight - 100) + "px";
chat.style.height = (this.scrollHeight + 425) + "px";
} else if (this.scrollHeight < 1) {
this.removeAttribute("style");
chat.removeAttribute("style");
} else {
return;
}
if (this.scrollHeight > 90) {
this.style.overflowY = "scroll";
this.style.borderTopRightRadius = "0px";
this.style.borderBottomRightRadius = "0px";
} else {
this.style.overflowY = "hidden";
this.style.borderTopRightRadius = "10px";
this.style.borderBottomRightRadius = "10px";
}
});
const pageAccessedByReload = (
(window.performance && window.performance === 1) ||
window.performance
.getEntriesByType('navigation')
.map((nav) => nav.type)
.includes('reload')
);
if (pageAccessedByReload) {
sessionStorage.clear();
}
</script>
</body>
</html>