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

Side by Side Diff: native_client_sdk/src/examples/hello_world_newlib/hello_world.html

Issue 10541180: Cleanup build system (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9 <meta http-equiv="Pragma" content="no-cache" />
10 <meta http-equiv="Expires" content="-1" />
11 <title>Hello, World!</title>
12 <script type="text/javascript">
13 naclModule = null; // Global application object.
14 statusText = 'NO-STATUSES';
15
16 function ExtractSearchParameter(name, def_value) {
17 var nameIndex = window.location.search.indexOf(name + "=");
18 if (nameIndex != -1) {
19 var value = location.search.substring(nameIndex + name.length + 1);
20 var endIndex = value.indexOf("&");
21 if (endIndex != -1)
22 value = value.substring(0, endIndex);
23 return value;
24 }
25 return def_value;
26 }
27
28 function createNaClModule(name, tool, width, height) {
29 var listenerDiv = document.getElementById('listener');
30 var naclModule = document.createElement('embed');
31 naclModule.setAttribute('name', 'nacl_module');
32 naclModule.setAttribute('id', 'file_io');
33 naclModule.setAttribute('width', width);
34 naclModule.setAttribute('height',height);
35 naclModule.setAttribute('src', tool + '/' + name + '.nmf');
36 naclModule.setAttribute('type', 'application/x-nacl');
37 listenerDiv.appendChild(naclModule);
38 }
39 // Indicate success when the NaCl module has loaded.
40 function moduleDidLoad() {
41 naclModule = document.getElementById('nacl_module');
42 updateStatus('SUCCESS');
43 }
44
45 // Handle a message coming from the NaCl module.
46 function handleMessage(message_event) {
47 alert(message_event.data);
48 }
49
50 // If the page loads before the Native Client module loads, then set the
51 // status message indicating that the module is still loading. Otherwise,
52 // do not change the status message.
53 function pageDidLoad() {
54 updateStatus('Page loaded.');
55 if (naclModule == null) {
56 tool = ExtractSearchParameter('tool', 'newlib');
57 updateStatus('Creating embed: ' + tool)
58 createNaClModule('hello_world', tool, 200, 200)
59 } else {
60 // It's possible that the Native Client module onload event fired
61 // before the page's onload event. In this case, the status message
62 // will reflect 'SUCCESS', but won't be displayed. This call will
63 // display the current message.
64 updateStatus('Waiting.');
65 }
66 }
67
68 // Set the global status message. If the element with id 'statusField'
69 // exists, then set its HTML to the status message as well.
70 // opt_message The message test. If this is null or undefined, then
71 // attempt to set the element with id 'statusField' to the value of
72 // |statusText|.
73 function updateStatus(opt_message) {
74 if (opt_message)
75 statusText = opt_message;
76 var statusField = document.getElementById('statusField');
77 if (statusField) {
78 statusField.innerHTML = statusText;
79 }
80 }
81 </script>
82 </head>
83 <body onload="pageDidLoad()">
84
85 <h1>Native Client Simple Module</h1>
86 <h2>Status: <code id="statusField">NO-STATUS</code></h2>
87 <!-- The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
88 and a 'message' event listener attached. This wrapping method is used
89 instead of attaching the event listeners directly to the <EMBED> element to
90 ensure that the listeners are active before the NaCl module 'load' event
91 fires. This also allows you to use PPB_Messaging.PostMessage() (in C) or
92 pp::Instance.PostMessage() (in C++) from within the initialization code in
93 your NaCl module.
94
95 The src points to a manifest file, which provides the Native Client plug-in
96 a mapping between architecture and NaCl Executable (NEXE).
97
98 We use a non-zero sized embed to give Chrome space to place the bad plug-in
99 graphic, if there is a problem.
100 -->
101 <div id="listener">
102 <script type="text/javascript">
103 var listener = document.getElementById('listener')
104 listener.addEventListener('load', moduleDidLoad, true);
105 listener.addEventListener('message', handleMessage, true);
106 </script>
107 </div>
108 </body>
109 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698