From bd6fe0340cc35fd5efd94d902e9eeb9e3f93462a Mon Sep 17 00:00:00 2001 From: Quentin ANIERE Date: Tue, 12 Apr 2022 13:29:46 +0200 Subject: [PATCH] Fix some bugs --- index.js | 7 ++++++- src/script.js | 33 +++++++++++++++++++++++++++++++++ src/style.css | 3 ++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 119f9df..1a27f9c 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,12 @@ io.on("connection", (client) => { }); 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++; diff --git a/src/script.js b/src/script.js index b3f38ae..6ec8b5b 100644 --- a/src/script.js +++ b/src/script.js @@ -6,6 +6,7 @@ function addMessage(author, message) { li.innerHTML = "" + author + ": "; li.innerText += message; document.getElementById("messages").appendChild(li); + document.getElementById("messages").scrollTop = document.getElementById("messages").scrollHeight; } function sendMessage() { @@ -31,6 +32,10 @@ document.addEventListener("DOMContentLoaded", () => { addMessage(data.author, data.message); }); + socket.on("warning", () => { + addMessage("Rappel", "Vous devez parler uniquement de denis !"); + }); + } catch(error) { document.getElementById("value").innerText = "Serveur injoingnable !"; @@ -63,3 +68,31 @@ document.getElementById("message-input").addEventListener("keyup", (event) => { 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(); + } \ No newline at end of file diff --git a/src/style.css b/src/style.css index 811d49b..9f12fde 100644 --- a/src/style.css +++ b/src/style.css @@ -153,8 +153,9 @@ body { } #messages { + margin-top: 15vh; padding-left: 5vw; - height: 80vh; + height: 70vh; width: 95vw; }