Back to the homepage
Previous page
Next page
Created 2014-02-22 by Yann Guidon
Version 2014-02-23

ygwm/init.js

This file doesn't do much but prepares a crucial aspect of the whole YGWM system. The next files will mostly be "modules" that will be registered by INIT() into INIT_list[].

INIT_list=[]; // cookies, menu, winlist, test_asm, OpcodeTable, asmwin, DOC_GEN, DEF_ASM, template...

function INIT(o){
  INIT_list.push(o); // add the new module to the list
}

The list will be scanned later by body_start.js. Each module entry point will be executed to provide new services. The entry points are:
* INIT_func() will be called to setup this module as a "second stage" in body_start.js.
* start() will be called when the corresponding "key" is called.
* win.trigger() sends data to the module, maybe forcing a refresh or a change in behaviour (it's usually given the "parameters" following the # after the key name)
So a template for a module looks like this:

INIT(my_module={

  my_trigger: function() {
    // change some data, reconfigure stuff...
  }

  start: function() {
    // create a window and populate it
    my_module.win.trigger=my_module.my_trigger;
  }  

  INIT_func: function(){
    // add to the menu, things like that
  }
});

This template is the underlying structure of most of the modules that will be loaded after this file. Later, we'll see a more complete template file.

Each module will be added in the same order as the files are included. A post_init feature is also available for certain modules that need to make a second stage of initialisation.