File: echo.html

package info (click to toggle)
rabbitmq-server 3.3.5-1.1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 12,004 kB
  • sloc: erlang: 78,203; python: 3,187; xml: 2,843; makefile: 903; sh: 831; java: 660; perl: 64; ruby: 63
file content (72 lines) | stat: -rw-r--r-- 2,063 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html><head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
  </script>
  <script src="http://cdn.sockjs.org/sockjs-0.2.min.js">
  </script>
  <style>
      .box {
          border: 1px dashed black;
          border-radius: 4px;
          -moz-border-radius: 4px;
          width: 400px;
          display: block;
          height: 300px;
          float: left;
      }
      #output {
          border-color: grey;
          overflow:auto;
      }
      #input {
          vertical-align: text-top;
          -moz-outline-style: none;
          outline-style: none;
          outline-width: 0px;
          outline-color: -moz-use-text-color;
      }
      body {
          background-color: #F0F0F0;
      }
  </style>
</head><body lang="en">
    <h2>SockJS-erlang Echo example</h2>
    <form id="form">
      <input id="input" autocomplete="off" class="box"
             value="type something here" />
    </form>
    <div id="output" class="box"></div>
    <script>
      function log(m) {
          $('#output').append($("<code>").text(m));
          $('#output').append($("<br>"));
          $('#output').scrollTop($('#output').scrollTop()+10000);
      }

      var sockjs_url = '/echo';
      var sockjs = new SockJS(sockjs_url);
      sockjs.onopen = function() {
          log(' [*] Connected (using: '+sockjs.protocol+')');
      };
      sockjs.onclose = function(e) {
          log(' [*] Disconnected ('+e.status + ' ' + e.reason+ ')');
      };
      sockjs.onmessage = function(e) {
          log(' [ ] received: ' + JSON.stringify(e.data));
      };

      $('#input').focus();
      $('#form').submit(function() {
          var val = $('#input').val();
          $('#input').val('');
          var l = ' [ ] sending: ' + JSON.stringify(val);
          if (sockjs.readyState !== SockJS.OPEN) {
              l += ' (error, connection not established)';
          } else {
              sockjs.send(val);
          }
          log(l);
          return false;
      });
    </script>
</body></html>