From f3007671f230087d017036992844a04fdc812c22 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 27 Jul 2022 16:26:52 +0200 Subject: add app --- Year_3/Web/notifications/assets/notifications.js | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Year_3/Web/notifications/assets/notifications.js (limited to 'Year_3/Web/notifications/assets') diff --git a/Year_3/Web/notifications/assets/notifications.js b/Year_3/Web/notifications/assets/notifications.js new file mode 100644 index 0000000..97bf0e7 --- /dev/null +++ b/Year_3/Web/notifications/assets/notifications.js @@ -0,0 +1,25 @@ +socket.on("message", (message) => { + console.log(message); +}); + +const h1 = document.querySelector("h1"); +h1.addEventListener("click", () => { + socket.emit("new click"); +}); + +socket.on("clicked", (number) => { + const paragraph = document + .createElement("p") + .appendChild(document.createTextNode("Oh my god, you're number " + number)); + document.body.appendChild(paragraph); + document.body.appendChild(document.createElement("br")); +}); + +socket.on("new notification", () => { + const notifications = document.querySelector("#notifications"); + notifications.prepend( + document + .createElement("p") + .appendChild(document.createTextNode("New notification")) + ); +}); -- cgit v1.2.3-18-g5258