Fix some bugs
This commit is contained in:
parent
932ddcd102
commit
bd6fe0340c
7
index.js
7
index.js
@ -34,7 +34,12 @@ io.on("connection", (client) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on("message", (data) => {
|
client.on("message", (data) => {
|
||||||
io.sockets.emit("new-message", {author: client.usernameDenis, message: data.message});
|
if(data.message.toLowerCase().includes("denis")) {
|
||||||
|
io.sockets.emit("new-message", {author: client.usernameDenis, message: data.message});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
client.emit("warning");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
lastUsername++;
|
lastUsername++;
|
||||||
|
@ -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();
|
||||||
|
}
|
@ -153,8 +153,9 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#messages {
|
#messages {
|
||||||
|
margin-top: 15vh;
|
||||||
padding-left: 5vw;
|
padding-left: 5vw;
|
||||||
height: 80vh;
|
height: 70vh;
|
||||||
width: 95vw;
|
width: 95vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user