controldeck-flowtime.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var messageHandler;
  2. if (typeof jQuery === 'undefined') jQuery = {};
  3. function messageHandler(message, a, b, c, d) {
  4. if (message === '37') Flowtime.prevSection(a);
  5. else if (message === '38') Flowtime.prev(a);
  6. else if (message === '39') Flowtime.nextSection(a);
  7. else if (message === '40') Flowtime.next(a);
  8. else if (message === '33') Flowtime.gotoTop();
  9. else if (message === '34') Flowtime.gotoBottom();
  10. else if (message === '36') Flowtime.gotoHome();
  11. else if (message === '35') Flowtime.gotoEnd();
  12. else if (message === '27') Flowtime.toggleOverview(true);
  13. else if (message === '13') Flowtime.toggleOverview(false);
  14. else if (message === 'prev') Flowtime.prev();
  15. else if (message === 'prev(true)') Flowtime.prev(true);
  16. else if (message === 'next') Flowtime.next();
  17. else if (message === 'next(true)') Flowtime.next(true);
  18. else if (message === 'prevSection') Flowtime.prevSection();
  19. else if (message === 'prevSection(true)') Flowtime.prevSection(true);
  20. else if (message === 'nextSection') Flowtime.nextSection();
  21. else if (message === 'nextSection(true)') Flowtime.nextSection(true);
  22. else if (message === 'overview') Flowtime.toggleOverview(true);
  23. else if (message === 'navigate') Flowtime.gotoPage(a,b);
  24. }
  25. var iosocket = io.connect();
  26. iosocket.on('connect', function () {
  27. console.log('connected');
  28. });
  29. iosocket.on('message', function(message) {
  30. messageHandler(message);
  31. });
  32. iosocket.on('key down', function(data) {
  33. if (typeof Flowtime === 'undefined') {
  34. messageHandler("" +data.keyCode, data.shiftKey, data.altKey, data.ctrlKey, data.metaKey);
  35. }
  36. });
  37. iosocket.on('key up', function(data) {
  38. if (typeof Flowtime !== 'undefined') {
  39. messageHandler("" + data.keyCode, data.shiftKey, data.altKey, data.ctrlKey, data.metaKey);
  40. }
  41. });
  42. iosocket.on('navigate', function(data) {
  43. messageHandler("" + 'navigate', data.section, data.page);
  44. });
  45. iosocket.on('disconnect', function() {
  46. console.log('disconnected');
  47. });