| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Called by the common.js module. | 5 // Called by the common.js module. |
| 6 function attachListeners() { | 6 function attachListeners() { |
| 7 document.querySelector('form').addEventListener('submit', askBall); | 7 document.querySelector('form').addEventListener('submit', askBall); |
| 8 document.getElementById('reverse').addEventListener('click', reverseString); | 8 document.getElementById('reverse').addEventListener('click', reverseString); |
| 9 } | 9 } |
| 10 | 10 |
| 11 // Called by the common.js module. | 11 // Called by the common.js module. |
| 12 function moduleDidLoad() { | 12 function moduleDidLoad() { |
| 13 // The module is not hidden by default so we can easily see if the plugin | 13 // The module is not hidden by default so we can easily see if the plugin |
| 14 // failed to load. | 14 // failed to load. |
| 15 common.hideModule(); | 15 common.hideModule(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 function askBall(event) { | 18 function askBall(event) { |
| 19 var questionEl = document.getElementById('question'); | 19 var questionEl = document.getElementById('question'); |
| 20 var query = questionEl.value; | 20 var query = questionEl.value; |
| 21 questionEl.value = ''; | 21 questionEl.value = ''; |
| 22 document.getElementById('log').innerHTML += 'You asked:' + query + '<br>'; | 22 common.logMessage('You asked: ' + query + '\n'); |
| 23 common.naclModule.postMessage('eightball'); | 23 common.naclModule.postMessage('eightball'); |
| 24 event.preventDefault(); | 24 event.preventDefault(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 function reverseString(event) { | 27 function reverseString(event) { |
| 28 var questionEl = document.getElementById('question'); | 28 var questionEl = document.getElementById('question'); |
| 29 var query = questionEl.value; | 29 var query = questionEl.value; |
| 30 questionEl.value = ''; | 30 questionEl.value = ''; |
| 31 | 31 common.logMessage('Reversing: ' + query + '\n'); |
| 32 document.getElementById('log').innerHTML += 'Reversing:' + query + '<br>'; | |
| 33 common.naclModule.postMessage('reverse:' + query); | 32 common.naclModule.postMessage('reverse:' + query); |
| 34 } | 33 } |
| OLD | NEW |