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. 4 5// Called by the common.js module. 6function attachListeners() { 7 document.querySelector('form').addEventListener('submit', askBall); 8 document.getElementById('reverse').addEventListener('click', reverseString); 9} 10 11// Called by the common.js module. 12function moduleDidLoad() { 13 // The module is not hidden by default so we can easily see if the plugin 14 // failed to load. 15 common.hideModule(); 16} 17 18function 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(); 25} 26 27function 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); 33} 34