1 // Generated by CoffeeScript 1.8.0
3 var CoffeeScript, compile, runScripts,
4 __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
6 CoffeeScript = require('./coffee-script');
8 CoffeeScript.require = require;
10 compile = CoffeeScript.compile;
12 CoffeeScript["eval"] = function(code, options) {
13 if (options == null) {
16 if (options.bare == null) {
19 return eval(compile(code, options));
22 CoffeeScript.run = function(code, options) {
23 if (options == null) {
27 options.shiftLine = true;
28 return Function(compile(code, options))();
31 if (typeof window === "undefined" || window === null) {
35 if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
36 compile = function(code, options) {
37 var js, v3SourceMap, _ref;
38 if (options == null) {
41 options.sourceMap = true;
42 options.inline = true;
43 _ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap;
44 return "" + js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript";
48 CoffeeScript.load = function(url, callback, options, hold) {
50 if (options == null) {
56 options.sourceFiles = [url];
57 xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new window.XMLHttpRequest();
58 xhr.open('GET', url, true);
59 if ('overrideMimeType' in xhr) {
60 xhr.overrideMimeType('text/plain');
62 xhr.onreadystatechange = function() {
64 if (xhr.readyState === 4) {
65 if ((_ref = xhr.status) === 0 || _ref === 200) {
66 param = [xhr.responseText, options];
68 CoffeeScript.run.apply(CoffeeScript, param);
71 throw new Error("Could not load " + url);
74 return callback(param);
78 return xhr.send(null);
81 runScripts = function() {
82 var coffees, coffeetypes, execute, i, index, s, script, scripts, _fn, _i, _len;
83 scripts = window.document.getElementsByTagName('script');
84 coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
85 coffees = (function() {
86 var _i, _len, _ref, _results;
88 for (_i = 0, _len = scripts.length; _i < _len; _i++) {
90 if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) {
97 execute = function() {
99 param = coffees[index];
100 if (param instanceof Array) {
101 CoffeeScript.run.apply(CoffeeScript, param);
106 _fn = function(script, i) {
109 literate: script.type === coffeetypes[1]
112 return CoffeeScript.load(script.src, function(param) {
117 options.sourceFiles = ['embedded'];
118 return coffees[i] = [script.innerHTML, options];
121 for (i = _i = 0, _len = coffees.length; _i < _len; i = ++_i) {
128 if (window.addEventListener) {
129 window.addEventListener('DOMContentLoaded', runScripts, false);
131 window.attachEvent('onload', runScripts);