| 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 // Set to true when the Document is loaded IFF "test=true" is in the query | 5 // Set to true when the Document is loaded IFF "test=true" is in the query |
| 6 // string. | 6 // string. |
| 7 var isTest = false; | 7 var isTest = false; |
| 8 | 8 |
| 9 // Set to true when loading a "Release" NaCl module, false when loading a | 9 // Set to true when loading a "Release" NaCl module, false when loading a |
| 10 // "Debug" NaCl module. | 10 // "Debug" NaCl module. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 * "moduleDidLoad" function. | 231 * "moduleDidLoad" function. |
| 232 * | 232 * |
| 233 */ | 233 */ |
| 234 function hideModule() { | 234 function hideModule() { |
| 235 // Setting common.naclModule.style.display = "None" doesn't work; the | 235 // Setting common.naclModule.style.display = "None" doesn't work; the |
| 236 // module will no longer be able to receive postMessages. | 236 // module will no longer be able to receive postMessages. |
| 237 common.naclModule.style.height = '0'; | 237 common.naclModule.style.height = '0'; |
| 238 } | 238 } |
| 239 | 239 |
| 240 /** | 240 /** |
| 241 * Remove the NaCl module from the page. |
| 242 */ |
| 243 function removeModule() { |
| 244 common.naclModule.parentNode.removeChild(common.naclModule); |
| 245 common.naclModule = null; |
| 246 } |
| 247 |
| 248 /** |
| 241 * Return true when |s| starts with the string |prefix|. | 249 * Return true when |s| starts with the string |prefix|. |
| 242 * | 250 * |
| 243 * @param {string} s The string to search. | 251 * @param {string} s The string to search. |
| 244 * @param {string} prefix The prefix to search for in |s|. | 252 * @param {string} prefix The prefix to search for in |s|. |
| 245 */ | 253 */ |
| 246 function startsWith(s, prefix) { | 254 function startsWith(s, prefix) { |
| 247 // indexOf would search the entire string, lastIndexOf(p, 0) only checks at | 255 // indexOf would search the entire string, lastIndexOf(p, 0) only checks at |
| 248 // the first index. See: http://stackoverflow.com/a/4579228 | 256 // the first index. See: http://stackoverflow.com/a/4579228 |
| 249 return s.lastIndexOf(prefix, 0) === 0; | 257 return s.lastIndexOf(prefix, 0) === 0; |
| 250 } | 258 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 377 |
| 370 // The symbols to export. | 378 // The symbols to export. |
| 371 return { | 379 return { |
| 372 /** A reference to the NaCl module, once it is loaded. */ | 380 /** A reference to the NaCl module, once it is loaded. */ |
| 373 naclModule: null, | 381 naclModule: null, |
| 374 | 382 |
| 375 attachDefaultListeners: attachDefaultListeners, | 383 attachDefaultListeners: attachDefaultListeners, |
| 376 domContentLoaded: domContentLoaded, | 384 domContentLoaded: domContentLoaded, |
| 377 createNaClModule: createNaClModule, | 385 createNaClModule: createNaClModule, |
| 378 hideModule: hideModule, | 386 hideModule: hideModule, |
| 387 removeModule: removeModule, |
| 379 logMessage: logMessage, | 388 logMessage: logMessage, |
| 380 updateStatus: updateStatus | 389 updateStatus: updateStatus |
| 381 }; | 390 }; |
| 382 | 391 |
| 383 }()); | 392 }()); |
| 384 | 393 |
| 385 // Listen for the DOM content to be loaded. This event is fired when parsing of | 394 // Listen for the DOM content to be loaded. This event is fired when parsing of |
| 386 // the page's document has finished. | 395 // the page's document has finished. |
| 387 document.addEventListener('DOMContentLoaded', function() { | 396 document.addEventListener('DOMContentLoaded', function() { |
| 388 var body = document.body; | 397 var body = document.body; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); | 439 var path = pathFormat.replace('{tc}', tc).replace('{config}', config); |
| 431 | 440 |
| 432 isTest = searchVars.test === 'true'; | 441 isTest = searchVars.test === 'true'; |
| 433 isRelease = path.toLowerCase().indexOf('release') != -1; | 442 isRelease = path.toLowerCase().indexOf('release') != -1; |
| 434 | 443 |
| 435 loadFunction(body.dataset.name, tc, path, body.dataset.width, | 444 loadFunction(body.dataset.name, tc, path, body.dataset.width, |
| 436 body.dataset.height, attrs); | 445 body.dataset.height, attrs); |
| 437 } | 446 } |
| 438 } | 447 } |
| 439 }); | 448 }); |
| OLD | NEW |