Project

General

Profile

Statistics
| Branch: | Revision:

gdp-if / websocket-subscriber / test / test.html @ master

History | View | Annotate | Download (3.4 KB)

1 c388167f Nitesh Mor
<!DOCTYPE html>
2
<html lang="en">
3
  <head>
4
    <meta charset="utf-8">
5
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
    <meta name="viewport" content="width=device-width, initial-scale=1">
7
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
    <meta name="description" content="">
9
    <meta name="author" content="">
10
11
    <link rel="icon" href="static/favicon.ico">
12
13
    <title>GDP WebSocket Gateway test app</title>
14
15
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
16
    <!--[if lt IE 9]>
17
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
18
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
19
    <![endif]-->
20
21
22
    <!-- libraries -->
23
24
    <!-- libraries -->
25
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
26
    <link href="starter-template.css" rel="stylesheet">
27
28
    <script type="text/javascript">
29
        var socket = null;
30
        var cur_msg = "";
31

32
        function show_output(message) {
33
            cur_msg = cur_msg + "<br><br>" +  message;
34
            document.getElementById("dashboard_div").innerHTML = cur_msg;
35
        }
36

37
        window.onload = function() {
38
            socket = new WebSocket("ws://127.0.0.1:9007");
39
            socket.onopen = function() {
40
                show_output("Connected");
41
            }
42
            socket.onmessage = function(x) {
43
                show_output(x.data);
44
            }
45
            socket.onclose = function() {
46
                show_output("Disconnected");
47
            }
48
        }
49

50
        function sendRequest(form) {
51

52
            var logname = form.logname.value;
53
            var startrec = 0;
54
            var numrecs = 5
55
            var message = {"logname": logname,
56
                           "startrec": startrec,
57
                           "numrec": numrecs};
58
            var message_str = JSON.stringify(message);
59
            show_output("Sending " + message_str);
60
            socket.send(message_str);
61
        }
62
    </script>
63
64
  </head>
65
66
67
  <body>
68
69
    <nav class="navbar navbar-inverse navbar-fixed-top">
70
      <div class="container">
71
        <div class="navbar-header">
72
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
73
            <span class="sr-only">Toggle navigation</span>
74
            <span class="icon-bar"></span>
75
            <span class="icon-bar"></span>
76
            <span class="icon-bar"></span>
77
          </button>
78
          <a class="navbar-brand" href="/">GDP WebSocket test app</a>
79
        </div>
80
      </div>
81
    </nav>
82
83
84
    <div class="container">
85
      <div class="starter-template">
86
            <p class="lead"> Testing WebSocket Gateway ("ws://127.0.0.1:9007")</p>
87
 
88
        <div class="row">
89
            <form name="arg_picker" class="form-inline">
90
                <label class="col-md-1 control-label">Logname</label>
91
                <input class="col-md-3 form-control" type="text" name="logname" id="logname">
92
93
                <div class="col-md-1">
94
                    <input class="btn btn-default" type="button" value="Send" onClick='sendRequest(this.form)'>
95
                </div>
96
            </form>
97
        </div>  <!-- row-->
98
99
        <div id="dashboard_div" width="100%"></div>
100
      </div>
101
    </div><!-- /.container -->
102
103
104
  </body>