start.js 579 B

12345678910111213141516171819
  1. $(document).ready(function () {
  2. $socket.on('created', function (data) {
  3. $token = data.token;
  4. $('#game_link').val($URL + '/play/' + $token); // create game link
  5. $('#game_link').click(function() {
  6. $(this).select(); // when clicked, link is automatically selected for convenience
  7. });
  8. });
  9. $socket.on('ready', function (data) {
  10. document.location = $URL + '/play/' + $token;
  11. });
  12. $('#play').click(function (ev) {
  13. $socket.emit('start');
  14. $('#waiting').slideDown(400); // show waiting for opponent message
  15. ev.preventDefault();
  16. });
  17. });