# Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ $(document).ready -> $('.game-item-wrapper').click -> window.location=$(this).find("a").attr("href") false window.responseHandler = (json, callback) -> j = jQuery.parseJSON( json ) window[callback](j) window.start_game = (callback) -> url = pmGameData["apiPath"] + pmGameData["id"] + "/start.json" $.ajax { type: 'POST' dataType: 'json' url: url complete: (res) -> responseHandler res["responseText"], callback } window.finish_game = (callback) -> url = pmGameData["apiPath"] + pmGameData["id"] + "/finish.json" $.ajax { type: 'POST' dataType: 'json' url: url complete: (res) -> responseHandler res["responseText"], callback }