browser.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Generated by CoffeeScript 1.10.0
  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. CoffeeScript = require('./coffee-script');
  6. CoffeeScript.require = require;
  7. compile = CoffeeScript.compile;
  8. CoffeeScript["eval"] = function(code, options) {
  9. if (options == null) {
  10. options = {};
  11. }
  12. if (options.bare == null) {
  13. options.bare = true;
  14. }
  15. return eval(compile(code, options));
  16. };
  17. CoffeeScript.run = function(code, options) {
  18. if (options == null) {
  19. options = {};
  20. }
  21. options.bare = true;
  22. options.shiftLine = true;
  23. return Function(compile(code, options))();
  24. };
  25. if (typeof window === "undefined" || window === null) {
  26. return;
  27. }
  28. if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
  29. compile = function(code, options) {
  30. var js, ref, v3SourceMap;
  31. if (options == null) {
  32. options = {};
  33. }
  34. options.sourceMap = true;
  35. options.inline = true;
  36. ref = CoffeeScript.compile(code, options), js = ref.js, v3SourceMap = ref.v3SourceMap;
  37. return js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript";
  38. };
  39. }
  40. CoffeeScript.load = function(url, callback, options, hold) {
  41. var xhr;
  42. if (options == null) {
  43. options = {};
  44. }
  45. if (hold == null) {
  46. hold = false;
  47. }
  48. options.sourceFiles = [url];
  49. xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new window.XMLHttpRequest();
  50. xhr.open('GET', url, true);
  51. if ('overrideMimeType' in xhr) {
  52. xhr.overrideMimeType('text/plain');
  53. }
  54. xhr.onreadystatechange = function() {
  55. var param, ref;
  56. if (xhr.readyState === 4) {
  57. if ((ref = xhr.status) === 0 || ref === 200) {
  58. param = [xhr.responseText, options];
  59. if (!hold) {
  60. CoffeeScript.run.apply(CoffeeScript, param);
  61. }
  62. } else {
  63. throw new Error("Could not load " + url);
  64. }
  65. if (callback) {
  66. return callback(param);
  67. }
  68. }
  69. };
  70. return xhr.send(null);
  71. };
  72. runScripts = function() {
  73. var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts;
  74. scripts = window.document.getElementsByTagName('script');
  75. coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
  76. coffees = (function() {
  77. var j, len, ref, results;
  78. results = [];
  79. for (j = 0, len = scripts.length; j < len; j++) {
  80. s = scripts[j];
  81. if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) {
  82. results.push(s);
  83. }
  84. }
  85. return results;
  86. })();
  87. index = 0;
  88. execute = function() {
  89. var param;
  90. param = coffees[index];
  91. if (param instanceof Array) {
  92. CoffeeScript.run.apply(CoffeeScript, param);
  93. index++;
  94. return execute();
  95. }
  96. };
  97. fn = function(script, i) {
  98. var options, source;
  99. options = {
  100. literate: script.type === coffeetypes[1]
  101. };
  102. source = script.src || script.getAttribute('data-src');
  103. if (source) {
  104. return CoffeeScript.load(source, function(param) {
  105. coffees[i] = param;
  106. return execute();
  107. }, options, true);
  108. } else {
  109. options.sourceFiles = ['embedded'];
  110. return coffees[i] = [script.innerHTML, options];
  111. }
  112. };
  113. for (i = j = 0, len = coffees.length; j < len; i = ++j) {
  114. script = coffees[i];
  115. fn(script, i);
  116. }
  117. return execute();
  118. };
  119. if (window.addEventListener) {
  120. window.addEventListener('DOMContentLoaded', runScripts, false);
  121. } else {
  122. window.attachEvent('onload', runScripts);
  123. }
  124. }).call(this);