mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 13:31:06 +00:00
Import Test Cases
These three test cases demonstrate SSE using a remote service.
This commit is contained in:
parent
411e8fd09e
commit
9b28ddc129
@ -42,6 +42,15 @@
|
||||
<li>
|
||||
<a href="manual/scroll-test-eventHandler.html">Scroll Test 2 - Event Handler</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="manual/sse.html">SSE - Multiple Event Sources - Single Event Name</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="manual/sse-multichannel.html">SSE - Single Event Source - Multiple Event Names</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="manual/sse-settle.html">SSE - Settling</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>Mocha Test Suite</h2>
|
||||
|
41
test/manual/sse-multichannel.html
Normal file
41
test/manual/sse-multichannel.html
Normal file
@ -0,0 +1,41 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../src/htmx.js"></script>
|
||||
<script>
|
||||
htmx.createEventSource = function(url){
|
||||
return new EventSource(url, {withCredentials:false})
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
*{
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 10px;
|
||||
border: solid 1px gray;
|
||||
margin-bottom: 20px;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight:bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="page" hx-sse="connect http://sseplaceholder.openfollow.org/posts.html?types=Event1%2cEvent2%2cEvent3%2cEvent4">
|
||||
<h3>Multiple Listeners. message only</h3>
|
||||
<div class="container" hx-sse="swap on Event1">Waiting for Posts in Event1 channel...</div>
|
||||
<div class="container" hx-sse="swap on Event2">Waiting for Posts in Event2 channel...</div>
|
||||
<div class="container" hx-sse="swap on Event3">Waiting for Posts in Event3 channel...</div>
|
||||
<div class="container" hx-sse="swap on Event4">Waiting for Posts in Event4 channel...</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
49
test/manual/sse-settle.html
Normal file
49
test/manual/sse-settle.html
Normal file
@ -0,0 +1,49 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../src/htmx.js"></script>
|
||||
<script>
|
||||
htmx.createEventSource = function(url){
|
||||
return new EventSource(url, {withCredentials:false})
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
*{
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 10px;
|
||||
border: solid 1px gray;
|
||||
margin-bottom: 20px;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
.htmx-settling {
|
||||
border:solid 3px red!important;
|
||||
padding:8px!important;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight:bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="page">
|
||||
<h3>Settling Options</h3>
|
||||
<div hx-sse="connect http://sseplaceholder.openfollow.org/comments.html">
|
||||
<div class="container" hx-sse="swap on message" hx-swap="innerHTML settle:100ms">Waiting for Comments...</div>
|
||||
<div class="container" hx-sse="swap on message" hx-swap="innerHTML settle:200ms">Waiting for Comments...</div>
|
||||
<div class="container" hx-sse="swap on message" hx-swap="innerHTML settle:300ms">Waiting for Comments...</div>
|
||||
<div class="container" hx-sse="swap on message" hx-swap="innerHTML settle:400ms">Waiting for Comments...</div>
|
||||
<div class="container" hx-sse="swap on message" hx-swap="innerHTML settle:500ms">Waiting for Comments...</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
43
test/manual/sse.html
Normal file
43
test/manual/sse.html
Normal file
@ -0,0 +1,43 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../src/htmx.js"></script>
|
||||
<script>
|
||||
// "withCredentials:false" is necessary to circumvent CORS restrictions
|
||||
htmx.createEventSource = function(url){
|
||||
return new EventSource(url, {withCredentials:false})
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
*{
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 10px;
|
||||
border: solid 1px gray;
|
||||
margin-bottom: 20px;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight:bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="page">
|
||||
<h3>Multiple Listeners. message only</h3>
|
||||
<div class="container" hx-sse="connect http://sseplaceholder.openfollow.org/posts.html, swap on message">Waiting for Posts...</div>
|
||||
<div class="container" hx-sse="connect http://sseplaceholder.openfollow.org/comments.html, swap on message">Waiting for Comments...</div>
|
||||
<div class="container" hx-sse="connect http://sseplaceholder.openfollow.org/albums.html, swap on message">Waiting for Albums...</div>
|
||||
<div class="container" hx-sse="connect http://sseplaceholder.openfollow.org/todos.html, swap on message">Waiting for ToDos...</div>
|
||||
<div class="container" hx-sse="connect http://sseplaceholder.openfollow.org/users.html, swap on message">Waiting for Users...</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user