new debug server outline
This commit is contained in:
15
web/index.html
Normal file
15
web/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<title>Centralex State</title>
|
||||
<!--INSERT HEAD CONTENT HERE-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<list id="list" />
|
||||
</body>
|
||||
|
||||
</html>
|
||||
3
web/main.css
Normal file
3
web/main.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.body {
|
||||
background-color: gray;
|
||||
}
|
||||
22
web/main.js
Normal file
22
web/main.js
Normal file
@@ -0,0 +1,22 @@
|
||||
window.onload = () => {
|
||||
const evtSource = new EventSource("/events");
|
||||
evtSource.addEventListener("change", event => {
|
||||
console.log(event);
|
||||
|
||||
const newElement = document.createElement("li");
|
||||
const eventList = document.getElementById("list");
|
||||
newElement.textContent = `change at ${+event.data}`;
|
||||
eventList.appendChild(newElement);
|
||||
|
||||
fetch("/data").then(res => res.json().then(res => console.log(res)));
|
||||
});
|
||||
|
||||
evtSource.addEventListener("ping", event => {
|
||||
console.log(event);
|
||||
|
||||
const newElement = document.createElement("li");
|
||||
const eventList = document.getElementById("list");
|
||||
newElement.textContent = `ping at ${+event.data}`;
|
||||
eventList.appendChild(newElement);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user