index.html 2.25 KB
Newer Older
jose's avatar
jose committed
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="../../src/xterm.css" />
    <link rel="stylesheet" href="../../demo/style.css" />
    <script src="../../src/xterm.js"></script>
    <script src="attach.js"></script>
    <style>
        body {
            color: #111;
        }
        
        h1, h2 {
            color: #444;
            border-bottom: 1px solid #ddd;
            text-align: left;
        }
        
        form {
            margin-bottom: 32px;
        }
        
        input, button {
            line-height: 22px;
            font-size: 16px;
            display: inline-block;
            border-radius: 2px;
            border: 1px solid #ccc;
        }
        
        input {
            height: 22px;
            padding-left: 4px;
            padding-right: 4px;
        }
        
        button {
            height: 28px;
            background-color: #ccc;
            cursor: pointer;
            color: #333;
        }
        
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
    </style>
  </head>
  <body>
      <div class="container">
          
    <h1>
        xterm.js: socket attach
    </h1>
          <p>
              Attach the terminal to a WebSocket terminal stream with ease. Perfect for attaching to your
              Docker containers.
          </p>
          <h2>
              Socket information
          </h2>
    <form id="socket-form">
      <input id="socket-url"
             type="text"
             placeholder="Enter socket url (e.g. ws://mysock)"
             autofocus />
      <button>
        Attach
      </button>
    </form>
    <div id="terminal-container"></div>
          
      </div>
    <script>
      var term = new Terminal(),
          container = document.getElementById('terminal-container'),
          socketUrl = document.getElementById('socket-url'),
          socketForm = document.getElementById('socket-form');
      
      socketForm.addEventListener('submit', function (ev) {
        ev.preventDefault();
        var url = socketUrl.value,
            sock = new WebSocket(url);
        sock.addEventListener('open', function () {
          term.attach(sock);
        });
      });
      
      term.open(container);
    </script>
  </body>
</html>