mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Merge pull request #1028 from domenukk/master
Fixed headless client for deferred jQuery
This commit is contained in:
commit
2cc344c4f0
2 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,5 @@
|
|||
###
|
||||
This file will simulate games on node.js by emulating the browser environment.
|
||||
At some point, most of the code can be merged with Simulator.coffee
|
||||
###
|
||||
|
||||
bowerComponentsPath = "./bower_components/"
|
||||
|
@ -27,7 +26,6 @@ disable = [
|
|||
'../locale/locale'
|
||||
]
|
||||
|
||||
|
||||
# Start of the actual code. Setting up the enivronment to match the environment of the browser
|
||||
|
||||
# the path used for the loader. __dirname is module dependent.
|
||||
|
@ -108,6 +106,9 @@ $.ajax = (options) ->
|
|||
|
||||
console.log "Requesting: " + JSON.stringify options if options.debug
|
||||
console.log "URL: " + url if options.debug
|
||||
|
||||
deferred = Deferred()
|
||||
|
||||
request
|
||||
url: url
|
||||
jar: cookies
|
||||
|
@ -124,15 +125,20 @@ $.ajax = (options) ->
|
|||
if (error)
|
||||
console.warn "\t↳Returned: error: #{error}"
|
||||
options.error(error) if options.error?
|
||||
deferred.reject()
|
||||
|
||||
else
|
||||
console.log "\t↳Returned: statusCode #{response.statusCode}: #{if options.parse then JSON.stringify body else body}" if options.debug
|
||||
options.success(body, response, status: response.statusCode) if options.success?
|
||||
|
||||
deferred.resolve()
|
||||
|
||||
statusCode = response.statusCode if response?
|
||||
options.complete(status: statusCode) if options.complete?
|
||||
responded = true
|
||||
|
||||
deferred.promise()
|
||||
|
||||
|
||||
$.extend = (deep, into, from) ->
|
||||
copy = _.clone(from, deep);
|
||||
if into
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
"node-gyp": "~0.13.0",
|
||||
"aether": "~0.2.3",
|
||||
"JASON": "~0.1.3",
|
||||
"JQDeferred": "^2.1.0"
|
||||
"JQDeferred": "~2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jade": "0.33.x",
|
||||
|
|
Loading…
Reference in a new issue