UNPKG

4.08 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.9.3
2(function() {
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; };
5
6 CoffeeScript = require('./coffee-script');
7
8 CoffeeScript.require = require;
9
10 compile = CoffeeScript.compile;
11
12 CoffeeScript["eval"] = function(code, options) {
13 if (options == null) {
14 options = {};
15 }
16 if (options.bare == null) {
17 options.bare = true;
18 }
19 return eval(compile(code, options));
20 };
21
22 CoffeeScript.run = function(code, options) {
23 if (options == null) {
24 options = {};
25 }
26 options.bare = true;
27 options.shiftLine = true;
28 return Function(compile(code, options))();
29 };
30
31 if (typeof window === "undefined" || window === null) {
32 return;
33 }
34
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, ref, v3SourceMap;
38 if (options == null) {
39 options = {};
40 }
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";
45 };
46 }
47
48 CoffeeScript.load = function(url, callback, options, hold) {
49 var xhr;
50 if (options == null) {
51 options = {};
52 }
53 if (hold == null) {
54 hold = false;
55 }
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');
61 }
62 xhr.onreadystatechange = function() {
63 var param, ref;
64 if (xhr.readyState === 4) {
65 if ((ref = xhr.status) === 0 || ref === 200) {
66 param = [xhr.responseText, options];
67 if (!hold) {
68 CoffeeScript.run.apply(CoffeeScript, param);
69 }
70 } else {
71 throw new Error("Could not load " + url);
72 }
73 if (callback) {
74 return callback(param);
75 }
76 }
77 };
78 return xhr.send(null);
79 };
80
81 runScripts = function() {
82 var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts;
83 scripts = window.document.getElementsByTagName('script');
84 coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
85 coffees = (function() {
86 var j, len, ref, results;
87 results = [];
88 for (j = 0, len = scripts.length; j < len; j++) {
89 s = scripts[j];
90 if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) {
91 results.push(s);
92 }
93 }
94 return results;
95 })();
96 index = 0;
97 execute = function() {
98 var param;
99 param = coffees[index];
100 if (param instanceof Array) {
101 CoffeeScript.run.apply(CoffeeScript, param);
102 index++;
103 return execute();
104 }
105 };
106 fn = function(script, i) {
107 var options, source;
108 options = {
109 literate: script.type === coffeetypes[1]
110 };
111 source = script.src || script.getAttribute('data-src');
112 if (source) {
113 return CoffeeScript.load(source, function(param) {
114 coffees[i] = param;
115 return execute();
116 }, options, true);
117 } else {
118 options.sourceFiles = ['embedded'];
119 return coffees[i] = [script.innerHTML, options];
120 }
121 };
122 for (i = j = 0, len = coffees.length; j < len; i = ++j) {
123 script = coffees[i];
124 fn(script, i);
125 }
126 return execute();
127 };
128
129 if (window.addEventListener) {
130 window.addEventListener('DOMContentLoaded', runScripts, false);
131 } else {
132 window.attachEvent('onload', runScripts);
133 }
134
135}).call(this);