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.

match.js 818B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Expose `Layer`.
  3. */
  4. module.exports = Match;
  5. function Match(layer, path, params) {
  6. this.layer = layer;
  7. this.params = {};
  8. this.path = path || '';
  9. if (!params) {
  10. return this;
  11. }
  12. var keys = layer.keys;
  13. var n = 0;
  14. var prop;
  15. var key;
  16. var val;
  17. for (var i = 0; i < params.length; i++) {
  18. key = keys[i];
  19. val = decode_param(params[i]);
  20. prop = key
  21. ? key.name
  22. : n++;
  23. this.params[prop] = val;
  24. }
  25. return this;
  26. };
  27. /**
  28. * Decode param value.
  29. *
  30. * @param {string} val
  31. * @return {string}
  32. * @api private
  33. */
  34. function decode_param(val){
  35. if (typeof val !== 'string') {
  36. return val;
  37. }
  38. try {
  39. return decodeURIComponent(val);
  40. } catch (e) {
  41. var err = new TypeError("Failed to decode param '" + val + "'");
  42. err.status = 400;
  43. throw err;
  44. }
  45. }