js.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const socket = io("http://socketchat.fs.a-level.com.ua/");
  2. socket.on("msg", (msg) => messenger(msg));
  3. send.onclick = function () {
  4. socket.emit("msg", { nick: nick.value, message: message.value });
  5. };
  6. function messenger(users) {
  7. var chat = document.getElementById("chat");
  8. var dataInput = document.createElement("p");
  9. chat.appendChild(dataInput);
  10. dataInput.style.padding = "8px";
  11. dataInput.style.margin = "2px 20px";
  12. dataInput.style.color = "white";
  13. dataInput.style.fontWeight = "bold";
  14. dataInput.innerText = users.nick + ": " + users.message;
  15. if (users.nick === "Emmanuil") {
  16. dataInput.style.display = "flex";
  17. dataInput.style.flexDirection = "row-reverse";
  18. }
  19. }
  20. emojis.onclick = function () {
  21. if ((message.value = emojis.innerText)) {
  22. var img1 = new Image();
  23. img1.src = smiles.bowtie;
  24. img1.alt = "alt";
  25. message.appendChild(img1)
  26. } else alert("by");
  27. };
  28. var smiles = {
  29. bowtie: "bowtie.png",
  30. smile: "graphics/emojis/smile.png",
  31. simple_smile: "graphics/emojis/simple_smile.png",
  32. laughing: "graphics/emojis/laughing.png",
  33. blush: "graphics/emojis/blush.png",
  34. smiley: "graphics/emojis/smiley.png",
  35. relaxed: "graphics/emojis/relaxed.png",
  36. // "smirk": "graphics/emojis/smirk.png",
  37. // "heart_eyes": "graphics/emojis/heart_eyes.png",
  38. // "kissing_heart": "graphics/emojis/kissing_heart.png",
  39. // "kissing_closed_eyes": "graphics/emojis/kissing_closed_eyes.png",
  40. // "flushed": "graphics/emojis/flushed.png",
  41. // "relieved": "graphics/emojis/relieved.png"
  42. };