mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 15:41:30 -07:00
js: Simpler and more robust startup procedure
Previously, we initialised all of the JavaScript event handlers as soon at the DOM was loaded, and then called main() ourselves once the Emscripten runtime was ready. This was slightly dangerous since it depended on none of those event handlers' being called before main(). In practice this was difficult because most of the elements the event handlers were attached to were invisible, but it did limit what event handlers could safely be used. Now, the event handlers are initialised from main(). This makes things work in a sufficiently conventional way that we can just let the Emscripten run-time call main() in its usual way, rather than involving ourselves in the minutiae of Emscripten's startup.
This commit is contained in:
17
emcclib.js
17
emcclib.js
@ -16,6 +16,23 @@
|
||||
*/
|
||||
|
||||
mergeInto(LibraryManager.library, {
|
||||
/*
|
||||
* void js_init_puzzle(void);
|
||||
*
|
||||
* Called at the start of main() to set up event handlers.
|
||||
*/
|
||||
js_init_puzzle: function() {
|
||||
initPuzzle();
|
||||
},
|
||||
/*
|
||||
* void js_post_init(void);
|
||||
*
|
||||
* Called at the end of main() once the initial puzzle has been
|
||||
* started.
|
||||
*/
|
||||
js_post_init: function() {
|
||||
post_init();
|
||||
},
|
||||
/*
|
||||
* void js_debug(const char *message);
|
||||
*
|
||||
|
Reference in New Issue
Block a user