|
@@ -0,0 +1,53 @@
|
|
1
|
+<!DOCTYPE html>
|
|
2
|
+<html>
|
|
3
|
+<head>
|
|
4
|
+ <title>WebSocket Example</title>
|
|
5
|
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.3/socket.io.js"></script>
|
|
6
|
+ <script type="text/javascript">
|
|
7
|
+ var socket = io.connect('http://' + document.domain + ':' + location.port);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+ function sendMessage() {
|
|
11
|
+ var message = document.getElementById('message').value;
|
|
12
|
+ socket.emit('message', message);
|
|
13
|
+ }
|
|
14
|
+
|
|
15
|
+ socket.on('connect', function () {
|
|
16
|
+ console.log('Connected to the server');
|
|
17
|
+ socket.emit('message', "run_fn");
|
|
18
|
+ });
|
|
19
|
+
|
|
20
|
+ socket.on('response', function (data) {
|
|
21
|
+ console.log('Server says: ' + data);
|
|
22
|
+ });
|
|
23
|
+
|
|
24
|
+ clog=console.log
|
|
25
|
+ function rec_q_to_tab(data_str,a,b,c,d){
|
|
26
|
+ clog({that:this},arguments)
|
|
27
|
+ var data = JSON.parse(data_str)
|
|
28
|
+
|
|
29
|
+ clog(data)
|
|
30
|
+ lines = data.file_content.split("\n")
|
|
31
|
+ proc_data = {arr:[]}
|
|
32
|
+ for (line of lines){
|
|
33
|
+ if (!line){
|
|
34
|
+ clog("NOT LINE",line)
|
|
35
|
+ continue
|
|
36
|
+ }
|
|
37
|
+ // clog()
|
|
38
|
+ proc_data.arr.push(JSON.parse(line))
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+ }
|
|
43
|
+ socket.on('q_to_tab_q', rec_q_to_tab)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+ </script>
|
|
47
|
+</head>
|
|
48
|
+<body>
|
|
49
|
+ <h1>WebSocket Example</h1>
|
|
50
|
+ <input type="text" id="message" placeholder="Type a message">
|
|
51
|
+ <button onclick="sendMessage()">Send</button>
|
|
52
|
+</body>
|
|
53
|
+</html>
|