index.html 1.25 KB
Newer Older
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sidecar Basic Example</title>

  <link href="../common.css" rel="stylesheet">
</head>
<body>
  <div class="js-sidecar-status">... waiting for Sidecar</div>
  <button class="js-destroy-chat-button">Destroy Chat</button>
  <button class="js-create-chat-button">Create Chat</button>

  <script>
    ((window.gitter = {}).chat = {}).options = {
      disableDefaultChat: true
    };
  </script>
  <script src="../../dist/sidecar.js" async defer></script>

  <script>
    document.addEventListener('gitter-sidecar-ready', function(e) {
      var GitterChat = e.detail.Chat;
      document.querySelector('.js-sidecar-status').innerHTML = 'Sidecar ready';
26 27 28 29 30

      var chat;
      document.querySelector('.js-create-chat-button').addEventListener('click', function(e) {
        console.log('Create');
        chat = new GitterChat({
Eric Eastwood's avatar
Eric Eastwood committed
31
          room: 'gitterHQ/sidecar-demo'
32
        });
33 34 35 36 37 38 39 40 41 42 43 44
      });

      document.querySelector('.js-destroy-chat-button').addEventListener('click', function(e) {
        console.log('Destroy');
        chat.destroy();
      });
    });
  </script>
</body>
</html>