example.js revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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// Start up the paint timer when the NaCl module has loaded.
6function moduleDidLoad() {
7  setInterval(postPaintMessage, 5);
8}
9
10function postPaintMessage() {
11  common.naclModule.postMessage('paint');
12}
13
14// Handle a message coming from the NaCl module.  The message payload is
15// assumed to contain the current estimated value of Pi.  Update the Pi
16// text display with this value.
17function handleMessage(message_event) {
18  document.getElementById('pi').value = message_event.data;
19}
20