blob: cbf90d624d23b1a2c8416daa51ee5f5d64a6125b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Called by the common.js module.
function attachListeners() {
document.getElementById('resetScore').addEventListener('click', resetScore);
}
function resetScore() {
common.naclModule.postMessage("resetScore");
}
// Handle a message coming from the NaCl module. The message payload is
// assumed to contain the current game score. Update the score text
// display with this value.
// Note that errors are also sent to this handler. A message starting
// with 'ERROR' is considered an error, all other strings are assumed
// to be scores.
function handleMessage(message_event) {
if (message_event.data.indexOf('ERROR') == 0) {
document.getElementById('errorLog').innerHTML = message_event.data;
} else {
document.getElementById('score').innerHTML = message_event.data;
}
}
|