diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-07-22 20:52:43 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-07-22 20:52:43 -0700 |
commit | bfc0bd5a11bbf0a1c2bdf484ff2bfa26c87fdf74 (patch) | |
tree | a9e00b07f0841ab56dd5b77c05d1c8a79ca6db4c /src | |
parent | 35811b1c50cc92085c7f69847bc00b4da649cf93 (diff) |
allow defining preload plugins from outside
Diffstat (limited to 'src')
-rw-r--r-- | src/library_browser.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index fc58e7da..538f93b2 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -6,8 +6,7 @@ mergeInto(LibraryManager.library, { $Browser__postset: 'Module["requestFullScreen"] = function() { Browser.requestFullScreen() };\n' + // exports 'Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) };\n' + 'Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() };\n' + - 'Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() };\n' + - 'Module["preloadPlugins"] = Browser.preloadPlugins;\n', + 'Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() };\n', $Browser: { mainLoop: { scheduler: null, @@ -56,7 +55,16 @@ mergeInto(LibraryManager.library, { Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : console.log("warning: cannot build blobs")); Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : console.log("warning: cannot create object URLs"); - // preload plugins + // Support for plugins that can process preloaded files. You can add more of these to + // your app by creating and appending to Module.preloadPlugins. + // + // Each plugin is asked if it can handle a file based on the file's name. If it can, + // it is given the file's raw data. When it is done, it calls a callback with the file's + // (possibly modified) data. For example, a plugin might decompress a file, or it + // might create some side data structure for use later (like an Image element, etc.). + + if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; + var imagePlugin = {}; imagePlugin['canHandle'] = function(name) { return name.substr(-4) in { '.jpg': 1, '.png': 1, '.bmp': 1 }; @@ -286,15 +294,6 @@ mergeInto(LibraryManager.library, { }); addRunDependency('al ' + url); }, - - // A list of plugins that can process preloaded files. You can add more of these to - // your app by appending to Module.preloadPlugins. - // - // Each plugin is asked if it can handle a file based on the file's name. If it can, - // it is given the file's raw data. When it is done, it calls a callback with the file's - // (possibly modified) data. For example, a plugin might decompress a file, or it - // might create some side data structure for use later (like an Image element, etc.). - preloadPlugins: [], }, emscripten_async_wget: function(url, file, onload, onerror) { |