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.
7 function moduleLoad() {
15 function moduleLoadError() {
16 updateStatus('Load failed.');
19 function moduleLoadProgress(event
) {
20 $('progress').style
.display
= 'block';
22 var loadPercent
= 0.0;
23 var bar
= $('progress-bar');
25 if (event
.lengthComputable
&& event
.total
> 0) {
26 loadPercent
= event
.loaded
/ event
.total
* 100.0;
28 // The total length is not yet known.
31 bar
.style
.width
= loadPercent
+ "%";
34 function moduleCrash(event
) {
35 if (naclModule
.exitStatus
== -1) {
36 updateStatus('CRASHED');
38 updateStatus('EXITED [' + naclModule
.exitStatus
+ ']');
42 function updateStatus(opt_message
) {
43 var statusField
= $('statusField');
45 statusField
.style
.display
= 'block';
46 statusField
.textContent
= opt_message
;
50 function hideStatus() {
51 $('loading-cover').style
.display
= 'none';
54 function pageDidLoad() {
55 updateStatus('Loading...');
56 console
.log('started');
58 aM
= new NaClAM('NaClAM');
61 var embedWrap
= $('listener');
62 embedWrap
.addEventListener('load', moduleLoad
, true);
63 embedWrap
.addEventListener('error', moduleLoadError
, true);
64 embedWrap
.addEventListener('progress', moduleLoadProgress
, true);
65 embedWrap
.addEventListener('crash', moduleCrash
, true);
67 var revision
= 236779;
68 var url
= '//storage.googleapis.com/gonacl/demos/publish/' +
69 revision
+ '/bullet/NaClAMBullet.nmf';
71 var embed
= document
.createElement('embed');
72 embed
.setAttribute('name', 'NaClAM');
73 embed
.setAttribute('id', 'NaClAM');
74 embed
.setAttribute('width', '0');
75 embed
.setAttribute('height', '0');
76 embed
.setAttribute('type', 'application/x-pnacl');
77 embed
.setAttribute('src', url
);
78 embedWrap
.appendChild(embed
);
82 window
.addEventListener("load", pageDidLoad
, false);