Ein Projekt das es ermöglicht Beerpong über das Internet von zwei unabhängigen positionen aus zu spielen. Entstehung im Rahmen einer Praktikumsaufgabe im Fach Interaktion.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

browser.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * This is the web browser implementation of `debug()`.
  3. *
  4. * Expose `debug()` as the module.
  5. */
  6. exports = module.exports = require('./debug');
  7. exports.log = log;
  8. exports.formatArgs = formatArgs;
  9. exports.save = save;
  10. exports.load = load;
  11. exports.useColors = useColors;
  12. /**
  13. * Colors.
  14. */
  15. exports.colors = [
  16. 'lightseagreen',
  17. 'forestgreen',
  18. 'goldenrod',
  19. 'dodgerblue',
  20. 'darkorchid',
  21. 'crimson'
  22. ];
  23. /**
  24. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  25. * and the Firebug extension (any Firefox version) are known
  26. * to support "%c" CSS customizations.
  27. *
  28. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  29. */
  30. function useColors() {
  31. // is webkit? http://stackoverflow.com/a/16459606/376773
  32. return ('WebkitAppearance' in document.documentElement.style) ||
  33. // is firebug? http://stackoverflow.com/a/398120/376773
  34. (window.console && (console.firebug || (console.exception && console.table))) ||
  35. // is firefox >= v31?
  36. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  37. (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
  38. }
  39. /**
  40. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  41. */
  42. exports.formatters.j = function(v) {
  43. return JSON.stringify(v);
  44. };
  45. /**
  46. * Colorize log arguments if enabled.
  47. *
  48. * @api public
  49. */
  50. function formatArgs() {
  51. var args = arguments;
  52. var useColors = this.useColors;
  53. args[0] = (useColors ? '%c' : '')
  54. + this.namespace
  55. + (useColors ? ' %c' : ' ')
  56. + args[0]
  57. + (useColors ? '%c ' : ' ')
  58. + '+' + exports.humanize(this.diff);
  59. if (!useColors) return args;
  60. var c = 'color: ' + this.color;
  61. args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
  62. // the final "%c" is somewhat tricky, because there could be other
  63. // arguments passed either before or after the %c, so we need to
  64. // figure out the correct index to insert the CSS into
  65. var index = 0;
  66. var lastC = 0;
  67. args[0].replace(/%[a-z%]/g, function(match) {
  68. if ('%%' === match) return;
  69. index++;
  70. if ('%c' === match) {
  71. // we only are interested in the *last* %c
  72. // (the user may have provided their own)
  73. lastC = index;
  74. }
  75. });
  76. args.splice(lastC, 0, c);
  77. return args;
  78. }
  79. /**
  80. * Invokes `console.log()` when available.
  81. * No-op when `console.log` is not a "function".
  82. *
  83. * @api public
  84. */
  85. function log() {
  86. // This hackery is required for IE8,
  87. // where the `console.log` function doesn't have 'apply'
  88. return 'object' == typeof console
  89. && 'function' == typeof console.log
  90. && Function.prototype.apply.call(console.log, console, arguments);
  91. }
  92. /**
  93. * Save `namespaces`.
  94. *
  95. * @param {String} namespaces
  96. * @api private
  97. */
  98. function save(namespaces) {
  99. try {
  100. if (null == namespaces) {
  101. localStorage.removeItem('debug');
  102. } else {
  103. localStorage.debug = namespaces;
  104. }
  105. } catch(e) {}
  106. }
  107. /**
  108. * Load `namespaces`.
  109. *
  110. * @return {String} returns the previously persisted debug modes
  111. * @api private
  112. */
  113. function load() {
  114. var r;
  115. try {
  116. r = localStorage.debug;
  117. } catch(e) {}
  118. return r;
  119. }
  120. /**
  121. * Enable namespaces listed in `localStorage.debug` initially.
  122. */
  123. exports.enable(load());