diff --git a/headless_client.coffee b/headless_client.coffee index ca91cc034..8fb9e49b5 100644 --- a/headless_client.coffee +++ b/headless_client.coffee @@ -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 diff --git a/package.json b/package.json index 59bfdb9e9..0725978ee 100644 --- a/package.json +++ b/package.json @@ -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",