Skip to content

Commit

Permalink
htmx
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminbck committed Jun 23, 2024
1 parent f3851ad commit 6b5b70d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ <h1>Logs</h1>
<div id="Chat">Chat</div>

<h1>Server-Sent Events</h1>
<div id="sse-data"></div>
<div hx-ext="sse" sse-connect={ "https://melendriu.homepc.it:8888/events" } sse-swap="data"></div>

</main>

<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/htmx.org/dist/ext/sse.js"></script>
<script>
// Init TWA
Telegram.WebApp.ready();
Expand Down Expand Up @@ -103,17 +105,17 @@ <h1>Server-Sent Events</h1>
</script>

<script>
const eventSource = new EventSource('https://melendriu.homepc.it:8888/events');
const dataElement = document.getElementById('sse-data');

eventSource.onmessage = function(event) {
dataElement.innerHTML = event.data + '<br>';
};

eventSource.onerror = function(event) {
eventSource.close();
dataElement.innerHTML = 'Finished..<br>';
};
// const eventSource = new EventSource('https://melendriu.homepc.it:8888/events');
// const dataElement = document.getElementById('sse-data');
//
// eventSource.onmessage = function(event) {
// dataElement.innerHTML = event.data + '<br>';
// };
//
// eventSource.onerror = function(event) {
// eventSource.close();
// dataElement.innerHTML = 'Finished..<br>';
// };
</script>

</body>
Expand Down

0 comments on commit 6b5b70d

Please sign in to comment.