mirror of
https://github.com/tanrax/SSE-Fake.git
synced 2025-07-01 17:25:42 +02:00
The first commit
This commit is contained in:
24
static/js/index.js
Normal file
24
static/js/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
const notyf = new Notyf({
|
||||
position: {
|
||||
x: 'right',
|
||||
y: 'top',
|
||||
}
|
||||
});
|
||||
const sse = new EventSource("/events/");
|
||||
|
||||
sse.onmessage = function(event) {
|
||||
const data = JSON.parse(event.data);
|
||||
console.log(data);
|
||||
|
||||
switch (data.action) {
|
||||
case 'User connected':
|
||||
notyf.success(`Connected: ${data.name}`);
|
||||
break;
|
||||
case 'User disconnected':
|
||||
notyf.error(`Disconnected: ${data.name}`);
|
||||
break;
|
||||
case 'New message':
|
||||
notyf.success(`${data.name}: ${data.text.slice(0, 20)}...`);
|
||||
break;
|
||||
}
|
||||
}
|
8
static/js/prism.js
Normal file
8
static/js/prism.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user