summaryrefslogtreecommitdiff
path: root/Year_3/Web/notifications/assets/notifications.js
blob: 97bf0e7360fe728d30d163afb6bc0f547e95b04d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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"))
    );
});