| 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 var kMaxArraySize = 20; | |
| 6 var messageArray = new Array(); | |
| 7 | |
| 8 // Called by the common.js module. | 5 // Called by the common.js module. |
| 9 function moduleDidLoad() { | 6 function moduleDidLoad() { |
| 10 common.naclModule.style.backgroundColor = 'gray'; | 7 common.naclModule.style.backgroundColor = 'gray'; |
| 11 } | 8 } |
| 12 | 9 |
| 13 // Called by the common.js module. | 10 // Called by the common.js module. |
| 14 function attachListeners() { | 11 function attachListeners() { |
| 15 document.getElementById('killButton').addEventListener('click', cancelQueue); | 12 document.getElementById('killButton').addEventListener('click', cancelQueue); |
| 16 } | 13 } |
| 17 | 14 |
| 18 // Called by the common.js module. | 15 // Called by the common.js module. |
| 19 function handleMessage(message) { | 16 function handleMessage(message) { |
| 20 // Show last |kMaxArraySize| events in html. | 17 common.logMessage(message.data); |
| 21 messageArray.push(message.data); | |
| 22 if (messageArray.length > kMaxArraySize) { | |
| 23 messageArray.shift(); | |
| 24 } | |
| 25 var newData = messageArray.join('<BR>'); | |
| 26 document.getElementById('eventString').innerHTML = newData; | |
| 27 // Print event to console. | |
| 28 console.log(message.data); | |
| 29 } | 18 } |
| 30 | 19 |
| 31 function cancelQueue() { | 20 function cancelQueue() { |
| 32 if (common.naclModule == null) { | 21 if (common.naclModule == null) { |
| 33 console.log('Module is not loaded.'); | 22 console.log('Module is not loaded.'); |
| 34 return; | 23 return; |
| 35 } | 24 } |
| 36 common.naclModule.postMessage('CANCEL'); | 25 common.naclModule.postMessage('CANCEL'); |
| 37 } | 26 } |
| OLD | NEW |