browser.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Generated by CoffeeScript 1.12.6
  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)) {
  29. compile = function(code, options) {
  30. if (options == null) {
  31. options = {};
  32. }
  33. options.inlineMap = true;
  34. return CoffeeScript.compile(code, options);
  35. };
  36. }
  37. CoffeeScript.load = function(url, callback, options, hold) {
  38. var xhr;
  39. if (options == null) {
  40. options = {};
  41. }
  42. if (hold == null) {
  43. hold = false;
  44. }
  45. options.sourceFiles = [url];
  46. xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new window.XMLHttpRequest();
  47. xhr.open('GET', url, true);
  48. if ('overrideMimeType' in xhr) {
  49. xhr.overrideMimeType('text/plain');
  50. }
  51. xhr.onreadystatechange = function() {
  52. var param, ref;
  53. if (xhr.readyState === 4) {
  54. if ((ref = xhr.status) === 0 || ref === 200) {
  55. param = [xhr.responseText, options];
  56. if (!hold) {
  57. CoffeeScript.run.apply(CoffeeScript, param);
  58. }
  59. } else {
  60. throw new Error("Could not load " + url);
  61. }
  62. if (callback) {
  63. return callback(param);
  64. }
  65. }
  66. };
  67. return xhr.send(null);
  68. };
  69. runScripts = function() {
  70. var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts;
  71. scripts = window.document.getElementsByTagName('script');
  72. coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
  73. coffees = (function() {
  74. var j, len, ref, results;
  75. results = [];
  76. for (j = 0, len = scripts.length; j < len; j++) {
  77. s = scripts[j];
  78. if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) {
  79. results.push(s);
  80. }
  81. }
  82. return results;
  83. })();
  84. index = 0;
  85. execute = function() {
  86. var param;
  87. param = coffees[index];
  88. if (param instanceof Array) {
  89. CoffeeScript.run.apply(CoffeeScript, param);
  90. index++;
  91. return execute();
  92. }
  93. };
  94. fn = function(script, i) {
  95. var options, source;
  96. options = {
  97. literate: script.type === coffeetypes[1]
  98. };
  99. source = script.src || script.getAttribute('data-src');
  100. if (source) {
  101. return CoffeeScript.load(source, function(param) {
  102. coffees[i] = param;
  103. return execute();
  104. }, options, true);
  105. } else {
  106. options.sourceFiles = ['embedded'];
  107. return coffees[i] = [script.innerHTML, options];
  108. }
  109. };
  110. for (i = j = 0, len = coffees.length; j < len; i = ++j) {
  111. script = coffees[i];
  112. fn(script, i);
  113. }
  114. return execute();
  115. };
  116. if (window.addEventListener) {
  117. window.addEventListener('DOMContentLoaded', runScripts, false);
  118. } else {
  119. window.attachEvent('onload', runScripts);
  120. }
  121. }).call(this);