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.querySelector('form').addEventListener('submit', askBall);
8 document.getElementById('reverse').addEventListener('click', reverseString);
11 // Called by the common.js module.
12 function moduleDidLoad() {
13 // The module is not hidden by default so we can easily see if the plugin
18 function askBall(event) {
19 var questionEl = document.getElementById('question');
20 var query = questionEl.value;
21 questionEl.value = '';
22 common.logMessage('You asked: ' + query);
23 common.naclModule.postMessage('eightball');
24 event.preventDefault();
27 function reverseString(event) {
28 var questionEl = document.getElementById('question');
29 var query = questionEl.value;
30 questionEl.value = '';
31 common.logMessage('Reversing: ' + query);
32 common.naclModule.postMessage('reverse:' + query);