1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

improving CoffeeScript in browser script activation, and updating docs

This commit is contained in:
Jeremy Ashkenas 2010-02-25 06:26:27 -05:00
parent 66a6568fe7
commit b32a60585b
5 changed files with 33 additions and 99 deletions

View file

@ -1,5 +1,5 @@
(function(){
var _a, _b, lexer, parser, path, tag;
var lexer, parser, path, process_scripts;
// Set up for both the browser and the server.
if ((typeof process !== "undefined" && process !== null)) {
process.mixin(require('nodes'));
@ -48,10 +48,21 @@
// Activate CoffeeScript in the browser by having it compile and eval
// all script tags with a content-type of text/coffeescript.
if ((typeof document !== "undefined" && document !== null) && document.getElementsByTagName) {
_a = document.getElementsByTagName('script');
for (_b = 0; _b < _a.length; _b++) {
tag = _a[_b];
tag.type === 'text/coffeescript' ? eval(exports.compile(tag.innerHTML)) : null;
process_scripts = function process_scripts() {
var _a, _b, _c, tag;
_a = []; _b = document.getElementsByTagName('script');
for (_c = 0; _c < _b.length; _c++) {
tag = _b[_c];
if (tag.type === 'text/coffeescript') {
_a.push(eval(exports.compile(tag.innerHTML)));
}
}
return _a;
};
if (window.addEventListener) {
window.addEventListener('load', process_scripts, false);
} else if (window.attachEvent) {
window.attachEvent('onload', process_scripts);
}
}
})();