File: ticker.html

package info (click to toggle)
ruby-faye 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,792 kB
  • sloc: javascript: 14,833; ruby: 5,068; makefile: 30
file content (34 lines) | stat: -rw-r--r-- 774 bytes parent folder | download
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
<!doctype html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Ticker</title>
    <script src="/bayeux/client.js"></script>
  </head>
  <body>

    <p id="transport"></p>
    <h1 id="ticker"></h1>

    <script>
      var client    = new Faye.Client('/bayeux'),
          ticker    = document.getElementById('ticker'),
          transport = document.getElementById('transport');

      client.addExtension({
        outgoing: function(message, callback) {
          if (message.channel === '/meta/connect') {
            transport.innerHTML = message.connectionType;
          }
          callback(message);
        }
      });

      client.subscribe('/chat/tick', function(message) {
        ticker.innerHTML = message.n;
      });
    </script>

  </body>
</html>