| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Javascript module pattern: | 5 // Javascript module pattern: |
| 6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces | 6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces |
| 7 // In essence, we define an anonymous function which is immediately called and | 7 // In essence, we define an anonymous function which is immediately called and |
| 8 // returns a new object. The new object contains only the exported definitions; | 8 // returns a new object. The new object contains only the exported definitions; |
| 9 // all other definitions in the anonymous function are inaccessible to external | 9 // all other definitions in the anonymous function are inaccessible to external |
| 10 // code. | 10 // code. |
| 11 var common = (function () { | 11 var common = (function () { |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Create the Native Client <embed> element as a child of the DOM element | 14 * Create the Native Client <embed> element as a child of the DOM element |
| 15 * named "listener". | 15 * named "listener". |
| 16 * | 16 * |
| 17 * @param {string} name The name of the example. | 17 * @param {string} name The name of the example. |
| 18 * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. | 18 * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. |
| 19 * @param {string} config The name of the configruation, "Debug" or "Release" |
| 19 * @param {number} width The width to create the plugin. | 20 * @param {number} width The width to create the plugin. |
| 20 * @param {number} height The height to create the plugin. | 21 * @param {number} height The height to create the plugin. |
| 21 */ | 22 */ |
| 22 function createNaClModule(name, tool, config, width, height) { | 23 function createNaClModule(name, tool, config, width, height) { |
| 23 var moduleEl = document.createElement('embed'); | 24 var moduleEl = document.createElement('embed'); |
| 24 moduleEl.setAttribute('name', 'nacl_module'); | 25 moduleEl.setAttribute('name', 'nacl_module'); |
| 25 moduleEl.setAttribute('id', 'nacl_module'); | 26 moduleEl.setAttribute('id', 'nacl_module'); |
| 26 moduleEl.setAttribute('width', width); | 27 moduleEl.setAttribute('width', width); |
| 27 moduleEl.setAttribute('height',height); | 28 moduleEl.setAttribute('height',height); |
| 28 moduleEl.setAttribute('src', tool + '/' + config + '/' + name + '.nmf'); | 29 moduleEl.setAttribute('src', tool + '/' + config + '/' + name + '.nmf'); |
| 29 moduleEl.setAttribute('type', 'application/x-nacl'); | 30 moduleEl.setAttribute('type', 'application/x-nacl'); |
| 31 if (tool == 'win' || tool == 'linux' || tool == 'mac') { |
| 32 mimetype = 'application/x-ppapi-' + config.toLowerCase(); |
| 33 moduleEl.setAttribute('type', mimetype); |
| 34 } |
| 30 | 35 |
| 31 // The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' | 36 // The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' |
| 32 // and a 'message' event listener attached. This wrapping method is used | 37 // and a 'message' event listener attached. This wrapping method is used |
| 33 // instead of attaching the event listeners directly to the <EMBED> element | 38 // instead of attaching the event listeners directly to the <EMBED> element |
| 34 // to ensure that the listeners are active before the NaCl module 'load' | 39 // to ensure that the listeners are active before the NaCl module 'load' |
| 35 // event fires. | 40 // event fires. |
| 36 var listenerDiv = document.getElementById('listener'); | 41 var listenerDiv = document.getElementById('listener'); |
| 37 listenerDiv.appendChild(moduleEl); | 42 listenerDiv.appendChild(moduleEl); |
| 38 } | 43 } |
| 39 | 44 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 naclModule: null, | 203 naclModule: null, |
| 199 | 204 |
| 200 onload: pageDidLoad, | 205 onload: pageDidLoad, |
| 201 attachDefaultListeners: attachDefaultListeners, | 206 attachDefaultListeners: attachDefaultListeners, |
| 202 createNaClModule: createNaClModule, | 207 createNaClModule: createNaClModule, |
| 203 hideModule: hideModule, | 208 hideModule: hideModule, |
| 204 updateStatus: updateStatus | 209 updateStatus: updateStatus |
| 205 }; | 210 }; |
| 206 | 211 |
| 207 }()); | 212 }()); |
| OLD | NEW |