games.js.coffee 906 B

1234567891011121314151617181920212223242526272829303132
  1. # Place all the behaviors and hooks related to the matching controller here.
  2. # All this logic will automatically be available in application.js.
  3. # You can use CoffeeScript in this file: http://coffeescript.org/
  4. $(document).ready ->
  5. $('.game-item-wrapper').click ->
  6. window.location=$(this).find("a").attr("href")
  7. false
  8. window.responseHandler = (json, callback) ->
  9. j = jQuery.parseJSON( json )
  10. window[callback](j)
  11. window.start_game = (callback) ->
  12. url = pmGameData["apiPath"] + pmGameData["id"] + "/start.json"
  13. $.ajax {
  14. type: 'POST'
  15. dataType: 'json'
  16. url: url
  17. complete: (res) ->
  18. responseHandler res["responseText"], callback
  19. }
  20. window.finish_game = (callback) ->
  21. url = pmGameData["apiPath"] + pmGameData["id"] + "/finish.json"
  22. $.ajax {
  23. type: 'POST'
  24. dataType: 'json'
  25. url: url
  26. complete: (res) ->
  27. responseHandler res["responseText"], callback
  28. }