index.hbs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Socket.IO chat</title>
  5. <style>
  6. * { margin: 0; padding: 0; box-sizing: border-box; }
  7. body { font: 13px Helvetica, Arial; }
  8. form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
  9. form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
  10. form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
  11. #messages { list-style-type: none; margin: 0; padding: 0; }
  12. #messages li { padding: 5px 10px; }
  13. #messages li:nth-child(odd) { background: #eee; }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>LAN Jukebox</h1>
  18. <a href='/youtube'>Add a Youtube video</a><br/>
  19. <a href='/file'>Add a music file</a><br/>
  20. {{{playlist_view}}}
  21. {{{playing_view}}}
  22. {{{played_view}}}
  23. <button type='button' id='control-button'></button>
  24. <p>Allan put music player here</p>
  25. <script src='/socket.io/socket.io.js'></script>
  26. <script src='https://code.jquery.com/jquery-1.11.1.js'></script>
  27. <script>
  28. $(function () {
  29. var socket = io();
  30. $('form').submit(function(){
  31. socket.emit('chat message', $('#m').val());
  32. $('#m').val('');
  33. return false;
  34. });
  35. socket.on('chat message', function(msg){
  36. $('#messages').append($('<li>').text(msg));
  37. });
  38. socket.on('player-transition', function(state) {
  39. $('#control-button').attr('disabled', 'disabled');
  40. $('#control-button').html(state);
  41. });
  42. socket.on('paused', function() {
  43. $('#control-button').removeAttr('disabled');
  44. $('#control-button').html('Play');
  45. $('#control-button').unbind('click').click(function() {
  46. socket.emit('play');
  47. });
  48. });
  49. socket.on('playing', function() {
  50. $('#control-button').removeAttr('disabled');
  51. $('#control-button').html('Pause');
  52. $('#control-button').unbind('click').click(function() {
  53. socket.emit('pause');
  54. });
  55. });
  56. });
  57. </script>
  58. <h3>Chat Log:</h3>
  59. <ul id='messages'></ul>
  60. <form action=''>
  61. <input id='m' autocomplete='off' /><button>Send</button>
  62. </form>
  63. </body>
  64. </html>