diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-07-27 16:26:52 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-07-27 16:26:52 +0200 |
commit | f3007671f230087d017036992844a04fdc812c22 (patch) | |
tree | 39a1e1a17ea8744bc40f34a8091aafeae06b4f99 /Year_3/Web/notifications/assets/notifications.js | |
parent | cf7e0630c77b8f0e9660e3e633e10ea3db116387 (diff) |
add app
Diffstat (limited to 'Year_3/Web/notifications/assets/notifications.js')
-rw-r--r-- | Year_3/Web/notifications/assets/notifications.js | 25 |
1 files changed, 25 insertions, 0 deletions
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")) + ); +}); |