github.com/safing/portbase@v0.19.5/api/testclient/root/index.html (about)

     1  <!DOCTYPE html>
     2  <html>
     3  <head>
     4  	<title></title>
     5  	<!-- <script src="https://cdn.jsdelivr.net/sockjs/1/sockjs.min.js"></script> -->
     6  </head>
     7  <body>
     8  	<script type="text/javascript">
     9  
    10  		var ws = new WebSocket('ws://127.0.0.1:18/api/database/v1')
    11  
    12  		ws.onopen = function () {
    13  	    console.log('open');
    14  		};
    15  
    16  		ws.onerror = function (error) {
    17  			console.log('error');
    18  		  console.log(error);
    19  		};
    20  
    21  		ws.onmessage = function (e) {
    22  			reader = new FileReader()
    23  			reader.onload = function(e) {
    24  				console.log(e.target.result)
    25        }
    26  			reader.readAsText(e.data)
    27  		};
    28  
    29  		function send(text) {
    30  			ws.send(text)
    31  		}
    32  
    33  		// var sock = new SockJS("http://localhost:8080/api/v1");
    34  		//
    35  		// sock.onopen = function() {
    36  		//     console.log('open');
    37  		// };
    38  		//
    39  		// sock.onmessage = function(e) {
    40  		//     console.log('message received: ', e.data);
    41  		// };
    42  		//
    43  		// sock.onclose = function(e) {
    44  		//     console.log('close', e);
    45  		// };
    46  	</script>
    47  	yeeee
    48  </body>
    49  </html>