1 // Copyright (c) 2013 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.
6 return document
.getElementById(id
);
9 function postAngleMessage() {
10 var xAngle
= parseFloat($('xAngle').value
);
11 var yAngle
= parseFloat($('yAngle').value
);
12 common
.naclModule
.postMessage([xAngle
, yAngle
]);
15 // Add event listeners after the NaCl module has loaded. These listeners will
16 // forward messages to the NaCl module via postMessage()
17 function attachListeners() {
18 $('xAngle').addEventListener('change', postAngleMessage
);
19 $('yAngle').addEventListener('change', postAngleMessage
);
20 $('animateOff').addEventListener('click', function() {
21 $('animateOn').checked
= '';
22 common
.naclModule
.postMessage(false);
24 $('animateOn').addEventListener('click', function() {
25 $('animateOff').checked
= '';
26 common
.naclModule
.postMessage(true);
30 // Handle a message coming from the NaCl module.
31 function handleMessage(event
) {
32 if (!(event
.data
instanceof Array
))
34 if (event
.data
.length
!= 2)
37 var xAngle
= event
.data
[0];
38 var yAngle
= event
.data
[1];
39 $('xAngle').value
= xAngle
;
40 $('yAngle').value
= yAngle
;