OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 function moduleDidLoad() { | 5 function moduleDidLoad() { |
6 } | 6 } |
7 | 7 |
8 function postThreadFunc(numThreads) { | 8 function postThreadFunc(numThreads) { |
9 return function () { | 9 return function () { |
10 common.naclModule.postMessage({'message' : 'set_threads', | 10 common.naclModule.postMessage({'message' : 'set_threads', |
(...skipping 19 matching lines...) Expand all Loading... |
30 function() { | 30 function() { |
31 var checked = document.getElementById('drawInteriors').checked; | 31 var checked = document.getElementById('drawInteriors').checked; |
32 common.naclModule.postMessage({'message' : 'draw_interiors', | 32 common.naclModule.postMessage({'message' : 'draw_interiors', |
33 'value' : checked}); | 33 'value' : checked}); |
34 }); | 34 }); |
35 var threads = [0, 1, 2, 4, 6, 8, 12, 16, 24, 32]; | 35 var threads = [0, 1, 2, 4, 6, 8, 12, 16, 24, 32]; |
36 for (var i = 0; i < threads.length; i++) { | 36 for (var i = 0; i < threads.length; i++) { |
37 document.getElementById('radio' + i).addEventListener('click', | 37 document.getElementById('radio' + i).addEventListener('click', |
38 postThreadFunc(threads[i])); | 38 postThreadFunc(threads[i])); |
39 } | 39 } |
40 document.getElementById('pointRange').addEventListener('change', | 40 document.getElementById('pointRange').addEventListener('input', |
41 function() { | 41 function() { |
42 var value = parseFloat(document.getElementById('pointRange').value); | 42 var value = parseFloat(document.getElementById('pointRange').value); |
43 common.naclModule.postMessage({'message' : 'set_points', | 43 common.naclModule.postMessage({'message' : 'set_points', |
44 'value' : value}); | 44 'value' : value}); |
45 document.getElementById('pointCount').textContent = value + ' points'; | 45 document.getElementById('pointCount').textContent = value + ' points'; |
46 }); | 46 }); |
47 } | 47 } |
48 | 48 |
49 // Handle a message coming from the NaCl module. | 49 // Handle a message coming from the NaCl module. |
50 // In the Voronoi example, the only message will be the benchmark result. | 50 // In the Voronoi example, the only message will be the benchmark result. |
51 function handleMessage(message_event) { | 51 function handleMessage(message_event) { |
52 if (message_event.data['message'] == 'benchmark_result') { | 52 if (message_event.data['message'] == 'benchmark_result') { |
53 var x = (Math.round(message_event.data['value'] * 1000) / 1000).toFixed(3); | 53 var x = (Math.round(message_event.data['value'] * 1000) / 1000).toFixed(3); |
54 document.getElementById('result').textContent = | 54 document.getElementById('result').textContent = |
55 'Result: ' + x + ' seconds'; | 55 'Result: ' + x + ' seconds'; |
56 common.updateStatus('SUCCESS') | 56 common.updateStatus('SUCCESS') |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
OLD | NEW |