-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.pug
29 lines (29 loc) · 1.19 KB
/
simple.pug
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
26
27
28
29
doctype html
html(lang="en")
head
title Simple #{config.name}
meta(charset="utf-8")
meta(http-equiv="x-ua-compatible",content="ie=edge")
meta(name="viewport",content="width=device-width,initial-scale=1.0")
script(src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js",integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=",crossorigin="anonymous")
script(src="https://cdn.jsdelivr.net/npm/[email protected]/dist/socket.io.min.js",integrity="sha256-XWbNjAL+l0aYPimukCxoI/339U3AEFXDR3lnrXADLxU=",crossorigin="anonymous")
body(style="font-family: sans-serif;")
p#status Offline
p
span#count 0
| /#{config.max_players}
p#players
script.
$(function () {
const socket = io({transports: ["websocket", "polling"]});
socket.emit("is online");
socket.emit("get players");
socket.on("online", () => $("#status").text("Online"));
socket.on("offline", () => $("#status").text("Offline"));
socket.on("get players", data => display(data));
socket.on("change", data => display(data));
function display(data) {
$("#count").text(data.length);
$("#players").text(data);
}
});