summaryrefslogtreecommitdiff
path: root/Year_3/Web/notifications/assets/notifications.js
diff options
context:
space:
mode:
Diffstat (limited to 'Year_3/Web/notifications/assets/notifications.js')
-rw-r--r--Year_3/Web/notifications/assets/notifications.js25
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"))
+ );
+});