Fix some bugs

This commit is contained in:
Quentin ANIERE 2022-04-12 13:29:46 +02:00
parent 932ddcd102
commit bd6fe0340c
3 changed files with 41 additions and 2 deletions

View File

@ -34,7 +34,12 @@ io.on("connection", (client) => {
}); });
client.on("message", (data) => { client.on("message", (data) => {
if(data.message.toLowerCase().includes("denis")) {
io.sockets.emit("new-message", {author: client.usernameDenis, message: data.message}); io.sockets.emit("new-message", {author: client.usernameDenis, message: data.message});
} else {
client.emit("warning");
}
}); });
lastUsername++; lastUsername++;

View File

@ -6,6 +6,7 @@ function addMessage(author, message) {
li.innerHTML = "<b>" + author + ": </b>"; li.innerHTML = "<b>" + author + ": </b>";
li.innerText += message; li.innerText += message;
document.getElementById("messages").appendChild(li); document.getElementById("messages").appendChild(li);
document.getElementById("messages").scrollTop = document.getElementById("messages").scrollHeight;
} }
function sendMessage() { function sendMessage() {
@ -31,6 +32,10 @@ document.addEventListener("DOMContentLoaded", () => {
addMessage(data.author, data.message); addMessage(data.author, data.message);
}); });
socket.on("warning", () => {
addMessage("Rappel", "Vous devez parler uniquement de denis !");
});
} catch(error) { } catch(error) {
document.getElementById("value").innerText = "Serveur injoingnable !"; document.getElementById("value").innerText = "Serveur injoingnable !";
@ -63,3 +68,31 @@ document.getElementById("message-input").addEventListener("keyup", (event) => {
sendMessage(); sendMessage();
} }
}); });
const addMaximumScaleToMetaViewport = () => {
const el = document.querySelector('meta[name=viewport]');
if (el !== null) {
let content = el.getAttribute('content');
let re = /maximum\-scale=[0-9\.]+/g;
if (re.test(content)) {
content = content.replace(re, 'maximum-scale=1.0');
} else {
content = [content, 'maximum-scale=1.0'].join(', ')
}
el.setAttribute('content', content);
}
};
const disableIosTextFieldZoom = addMaximumScaleToMetaViewport;
// https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
const checkIsIOS = () =>
/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (checkIsIOS()) {
disableIosTextFieldZoom();
}

View File

@ -153,8 +153,9 @@ body {
} }
#messages { #messages {
margin-top: 15vh;
padding-left: 5vw; padding-left: 5vw;
height: 80vh; height: 70vh;
width: 95vw; width: 95vw;
} }