Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 0.92 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function getModules() {
  2.     function constructPaths(root, moduleNames) {
  3.         var ret = [];
  4.  
  5.         moduleNames.each(function(lib) {
  6.             ret.push('src/' + root + '/' + lib);
  7.         });
  8.  
  9.         return ret;
  10.     }
  11.     var ret = ['src/conf'];
  12.     var modules = {
  13.         'libs': ['stuff', 'morestuff'],
  14.         'utils': ['misc', 'math']
  15.     };
  16.  
  17.     for(var moduleRoot in modules) {
  18.         var moduleNames = modules[moduleRoot];
  19.  
  20.         ret = ret.concat(constructPaths(moduleRoot, moduleNames));
  21.     }
  22.  
  23.     return ret;
  24. }
  25.  
  26. require(getModules(), function() {
  27.     console.log('done loading modules. time to rok');
  28.  
  29.     //$(document).onReady(function() { // RightJS one (won't work :( )
  30.     require.ready(function() {
  31.         console.log('document is ready');
  32.         console.log(document, document.body, $$('body')); // document.body is null??? document shows up, though
  33.  
  34.         initSomeSupport(); // fails here
  35.  
  36.         ...
  37.     });
  38. });
clone this paste RAW Paste Data