1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Called by the common.js module.
6 function attachListeners() {
7 document.getElementById('connectForm').addEventListener('submit', doConnect);
8 document.getElementById('sendForm').addEventListener('submit', doSend);
9 document.getElementById('closeButton').addEventListener('click', doClose);
12 // Called by the common.js module.
13 function moduleDidLoad() {
14 // The module is not hidden by default so we can easily see if the plugin
19 function doConnect(event) {
20 // Send a request message. See also websocket.cc for the request format.
21 var url = document.getElementById('url').value;
22 common.naclModule.postMessage('o;' + url);
23 event.preventDefault();
27 // Send a request message. See also websocket.cc for the request format.
28 var message = document.getElementById('message').value;
29 var type = document.getElementById('is_binary').checked ? 'b;' : 't;';
30 common.naclModule.postMessage(type + message);
31 event.preventDefault();
35 // Send a request message. See also websocket.cc for the request format.
36 common.naclModule.postMessage('c;');
39 function handleMessage(message) {
40 common.logMessage(message.data);