39 lines
1.3 KiB
CoffeeScript
39 lines
1.3 KiB
CoffeeScript
@App = Ember.Application.create
|
|
LOG_TRANSITIONS: true
|
|
rootElement: '#ember-app-container'
|
|
|
|
App.deferReadiness()
|
|
|
|
@App.modals = Ember.Namespace.create()
|
|
@Modals = @App.modals
|
|
|
|
Ember.$.ajaxPrefilter (options) ->
|
|
if options.type.toUpperCase() == 'GET'
|
|
if auth_token = Qstorage.getItem('auth_token')
|
|
if options.data
|
|
options.data += "&auth_token=#{auth_token}&app_version=#{$app_version}"
|
|
else
|
|
options.data = "auth_token=#{auth_token}&app_version=#{$app_version}"
|
|
if options.type.toUpperCase() == 'POST'
|
|
if auth_token = Qstorage.getItem('auth_token')
|
|
if options.data
|
|
if typeof(options.data) == 'string'
|
|
if options.data[0] == '{' || options.data[0] == '[' # json
|
|
object = JSON.parse(options.data)
|
|
object.auth_token = auth_token
|
|
object.app_version = $app_version
|
|
options.data = JSON.stringify(object)
|
|
else
|
|
options.data += "&auth_token=#{auth_token}&app_version=#{$app_version}"
|
|
else
|
|
options.data.auth_token = auth_token
|
|
else
|
|
options.data = "auth_token=#{auth_token}"
|
|
true
|
|
|
|
Ember.$.ajaxSetup
|
|
error: (jqXHR, textStatus, errorThrown)->
|
|
console.log "Error: #{textStatus}: #{errorThrown}"
|
|
if jqXHR.status == 401
|
|
App.__container__.lookup('route:application').unauthorized()
|