Mercurial > repos > tabletprog
diff scripttags.js @ 126:a2d2d8e09291
Merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 05 Aug 2013 23:37:17 -0700 |
parents | da7f585bf626 |
children |
line wrap: on
line diff
--- a/scripttags.js Mon Aug 05 23:36:18 2013 -0700 +++ b/scripttags.js Mon Aug 05 23:37:17 2013 -0700 @@ -2,8 +2,12 @@ function compileAndRun(src) { var ast = parser.parse(src); - var js = ast.toJSModule(); - mainModule = eval(js)(); + asyncProcessTopLevelJS(toplevel, function() { + var js = makeJSProg(ast); + eval(js); + }); + /*.toJSModule(); + mainModule = eval(js); if (mainModule.strue) { each(mainModule.strue, function(key, val) { if(val instanceof Function) { @@ -13,18 +17,25 @@ } }); } - mainModule.main(); + mainModule.main();*/ } onReady(function() { - var tags = qall('script[type="text/tabletprog"]'); - for (var i = 0; i < tags.length; ++i) { - if (tags[i].src) { - get(tags[i].src, function(req) { - compileAndRun(req.responseText); - }); - } else { - compileAndRun(tags[i].innerHTML); + toplevel.onReady( function() { + var tags = qall('script[type="text/tabletprog"]'); + + for (var i = 0; i < tags.length; ++i) { + if (tags[i].src) { + (function() { + var src = tags[i].src; + get(src, function(req) { + console.log('Compiling ' + src); + compileAndRun(req.responseText); + }); + })(); + } else { + compileAndRun(tags[i].innerHTML); + } } - } + }); });