       style = "success"
   return style
 
-window.apiNotify = (data) ->
+@apiNotify = (data) ->
   style = getStyle data
   $.notify data.message, style
 

        if not data.data["logged_in"]
          window.location.href = "/login"

window.redirectIfLoggedIn = ->
  apiCall "GET", "/api/user/status", {}
  .done (data) ->
    switch data["status"]

@apiCall = (type, url, data) ->
  $.ajax {url: url, type: type, data: data, cache: false}
  .fail (jqXHR, text) ->
    $.notify "API is offline. :(", "error"

@redirectIfNotLoggedIn = ->
  apiCall "GET", "/api/user/status", {}
  .done (data) ->
    switch data["status"]
