Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: native_client_sdk/src/getting_started/part1/hello_tutorial.html

Issue 23661005: [NaCl SDK] Add a very simple getting_started example at top-level. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3
4 <!--
5 Copyright (c) 2012 The Native Client Authors. All rights reserved.
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
8 -->
9
10 <head>
11
12 <title>hello_tutorial</title>
13
14 <script type="text/javascript">
15 HelloTutorialModule = null; // Global application object.
16 statusText = 'NO-STATUS';
17
18 // Indicate load success.
19 function moduleDidLoad() {
20 HelloTutorialModule = document.getElementById('hello_tutorial');
21 updateStatus('SUCCESS');
22 }
23
24 // The 'message' event handler. This handler is fired when the NaCl module
25 // posts a message to the browser by calling PPB_Messaging.PostMessage()
26 // (in C) or pp::Instance.PostMessage() (in C++). This implementation
27 // simply displays the content of the message in an alert panel.
28 function handleMessage(message_event) {
29 alert(message_event.data);
30 }
31
32 // If the page loads before the Native Client module loads, then set the
33 // status message indicating that the module is still loading. Otherwise,
34 // do not change the status message.
35 function pageDidLoad() {
36 if (HelloTutorialModule == null) {
37 updateStatus('LOADING...');
38 } else {
39 // It's possible that the Native Client module onload event fired
40 // before the page's onload event. In this case, the status message
41 // will reflect 'SUCCESS', but won't be displayed. This call will
42 // display the current message.
43 updateStatus();
44 }
45 }
46
47 // Set the global status message. If the element with id 'statusField'
48 // exists, then set its HTML to the status message as well.
49 // opt_message The message test. If this is null or undefined, then
50 // attempt to set the element with id 'statusField' to the value of
51 // |statusText|.
52 function updateStatus(opt_message) {
53 if (opt_message)
54 statusText = opt_message;
55 var statusField = document.getElementById('status_field');
56 if (statusField) {
57 statusField.innerHTML = statusText;
58 }
59 }
60 </script>
61 </head>
62 <body onload="pageDidLoad()">
63
64 <h1>Native Client Module HelloTutorial</h1>
65 <p>
66 <!-- TODO(eliben): PNaCl-ize:
67 Load the published .nexe. This includes the 'nacl' attribute which
68 shows how to load multi-architecture modules. Each entry in the "nexes"
69 object in the .nmf manifest file is a key-value pair: the key is the
70 instruction set architecture ('x86-32', 'x86-64', etc.); the value is a URL
71 for the desired NaCl module.
72 To load the debug versions of your .nexes, set the 'nacl' attribute to the
73 _dbg.nmf version of the manifest file.
noelallen1 2013/09/09 04:32:00 We aren't building dbg in part1
binji 2013/09/09 18:43:46 Done.
74
75 Note: Since this NaCl module does not use any real-estate in the browser,
76 it's width and height are set to 0.
77
78 Note: The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
79 and a 'message' event listener attached. This wrapping method is used
80 instead of attaching the event listeners directly to the <EMBED> element to
81 ensure that the listeners are active before the NaCl module 'load' event
82 fires. This also allows you to use PPB_Messaging.PostMessage() (in C) or
83 pp::Instance.PostMessage() (in C++) from within the initialization code in
84 your NaCl module.
85 -->
86 <div id="listener">
87 <script type="text/javascript">
88 var listener = document.getElementById('listener');
89 listener.addEventListener('load', moduleDidLoad, true);
90 listener.addEventListener('message', handleMessage, true);
91 </script>
92
93 <embed name="nacl_module"
94 id="hello_tutorial"
95 width=0 height=0
96 src="hello_tutorial.nmf"
97 type="application/x-pnacl" />
98 </div>
99 </p>
100
101 <h2>Status</h2>
102 <div id="status_field">NO-STATUS</div>
103 </body>
104 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698