Hopital en PLS

This commit is contained in:
Xamora
2023-11-22 15:50:42 +01:00
parent 267eeab896
commit 6e624dad34
11 changed files with 68 additions and 35 deletions

Binary file not shown.

View File

@ -2,6 +2,7 @@ import Dashboard from "./views/Dashboard.js";
import Posts from "./views/Posts.js";
import PostView from "./views/PostView.js";
import Settings from "./views/Settings.js";
import GeneralChat from "./views/GeneralChat.js";
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
@ -24,7 +25,8 @@ const router = async () => {
{ path: "/", view: Dashboard },
{ path: "/posts", view: Posts },
{ path: "/posts/:id", view: PostView },
{ path: "/settings", view: Settings }
{ path: "/settings", view: Settings },
{ path: "/generalchat", view: GeneralChat },
];
// Test each route for potential match
@ -60,4 +62,4 @@ document.addEventListener("DOMContentLoaded", () => {
});
router();
});
});

View File

@ -10,4 +10,4 @@ export default class {
async getHtml() {
return "";
}
}
}

View File

@ -17,4 +17,4 @@ export default class extends AbstractView {
</p>
`;
}
}
}

View File

@ -0,0 +1,22 @@
import AbstractView from "./AbstractView.js";
export default class extends AbstractView {
constructor(params) {
super(params);
this.setTitle("General Chat");
let url = `ws://${window.location.host}/ws/socket-server/`
const chatSocket = new WebSocket(url)
chatSocket.onmessage = function(e) {
let data = JSON.parse(e.data)
console.log('Data:', data)
}
}
async getHtml() {
return `
<h1>General Chat</h1>
`;
}
}