Ingen beskrivning

browser.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Generated by CoffeeScript 1.3.3
  2. (function() {
  3. var CoffeeScript, runScripts;
  4. CoffeeScript = require('./coffee-script');
  5. CoffeeScript.require = require;
  6. CoffeeScript["eval"] = function(code, options) {
  7. var _ref;
  8. if (options == null) {
  9. options = {};
  10. }
  11. if ((_ref = options.bare) == null) {
  12. options.bare = true;
  13. }
  14. return eval(CoffeeScript.compile(code, options));
  15. };
  16. CoffeeScript.run = function(code, options) {
  17. if (options == null) {
  18. options = {};
  19. }
  20. options.bare = true;
  21. return Function(CoffeeScript.compile(code, options))();
  22. };
  23. if (typeof window === "undefined" || window === null) {
  24. return;
  25. }
  26. CoffeeScript.load = function(url, callback) {
  27. var xhr;
  28. xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
  29. xhr.open('GET', url, true);
  30. if ('overrideMimeType' in xhr) {
  31. xhr.overrideMimeType('text/plain');
  32. }
  33. xhr.onreadystatechange = function() {
  34. var _ref;
  35. if (xhr.readyState === 4) {
  36. if ((_ref = xhr.status) === 0 || _ref === 200) {
  37. CoffeeScript.run(xhr.responseText);
  38. } else {
  39. throw new Error("Could not load " + url);
  40. }
  41. if (callback) {
  42. return callback();
  43. }
  44. }
  45. };
  46. return xhr.send(null);
  47. };
  48. runScripts = function() {
  49. var coffees, execute, index, length, s, scripts;
  50. scripts = document.getElementsByTagName('script');
  51. coffees = (function() {
  52. var _i, _len, _results;
  53. _results = [];
  54. for (_i = 0, _len = scripts.length; _i < _len; _i++) {
  55. s = scripts[_i];
  56. if (s.type === 'text/coffeescript') {
  57. _results.push(s);
  58. }
  59. }
  60. return _results;
  61. })();
  62. index = 0;
  63. length = coffees.length;
  64. (execute = function() {
  65. var script;
  66. script = coffees[index++];
  67. if ((script != null ? script.type : void 0) === 'text/coffeescript') {
  68. if (script.src) {
  69. return CoffeeScript.load(script.src, execute);
  70. } else {
  71. CoffeeScript.run(script.innerHTML);
  72. return execute();
  73. }
  74. }
  75. })();
  76. return null;
  77. };
  78. if (window.addEventListener) {
  79. addEventListener('DOMContentLoaded', runScripts, false);
  80. } else {
  81. attachEvent('onload', runScripts);
  82. }
  83. }).call(this);