Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

78 Zeilen
2.2KB

  1. <head>
  2. <title>Demo static index</title>
  3. <link rel="stylesheet" type="text/css" href="css/index.css">
  4. </head>
  5. <body>
  6. <h1> Static Html Site </h1>
  7. <hr>
  8. <div class="center">
  9. <p >
  10. This is a static website located on /
  11. </p>
  12. <ol>
  13. <li>
  14. <a href="css/index.css"> css/index.css </a>
  15. </li>
  16. <li>
  17. static url <a href="spa1/"> /spa1 </a> &#x2192; "./html/test/"
  18. </li>
  19. <li>
  20. static url <a href="spa2/">/spa2 </a> &#x2192; "./html/test/"
  21. </li>
  22. <li>
  23. static url <a href="test/">/test </a> &#x2192; "./html/test/"
  24. </li>
  25. <script>
  26. let host = window.location.hostname;
  27. let protocol = window.location.protocol;
  28. let socket = null;
  29. if ( protocol.toLowerCase() == 'http:' ){
  30. socket = new WebSocket("ws://" + host + ":" + location.port + "/api1/ws");
  31. }else{ // https
  32. socket = new WebSocket("wss://" + host + ":" + location.port + "/api1/ws");
  33. }
  34. console.log("Attempting Connection...");
  35. socket.onopen = () => {
  36. console.log("Successfully Connected");
  37. socket.send("Hi From the Client!");
  38. socket.send("send dummy string for 500 times"); //this is a special command server will respond;
  39. };
  40. socket.onclose = event => {
  41. console.log("Socket Closed Connection: ", event);
  42. socket.send("Client Closed!")
  43. };
  44. socket.onerror = error => {
  45. console.log("Socket Error: ", error);
  46. };
  47. socket.onmessage = e => {
  48. if(typeof e.data != "string" ) {
  49. console.log("invalid data received ", e)
  50. }else{
  51. let server_message = e.data;
  52. console.log("server said: ", server_message)
  53. document.getElementById("socketOutPut").innerHTML= server_message;
  54. }
  55. }
  56. </script>
  57. </ol>
  58. <p id="socketOutPut"></p>
  59. </div>
  60. <!--<script type="text/javascript">-->
  61. <!-- setTimeout(function(){-->
  62. <!-- location.reload();-->
  63. <!-- },1000)-->
  64. <!--</script>-->
  65. </body>