Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: native_client_sdk/src/examples/input_events/example.js

Issue 13488007: [NaCl SDK] Make the SDK examples buildable as a packaged app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license headers Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/input_events/example.dsc ('k') | native_client_sdk/src/examples/input_events/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698