Last active
December 28, 2015 06:09
-
-
Save iskugor/7455044 to your computer and use it in GitHub Desktop.
Use parse.com JS API in Titanium mobile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
getItem : function(_key) { | |
return Ti.App.Properties.getObject(_key); | |
}, | |
setItem : function(_key, _value) { | |
return Ti.App.Properties.setObject(_key, _value); | |
}, | |
removeItem : function(_key, _value) { | |
return Ti.App.Properties.removeProperty(_key); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Parse = require("parse").Parse; | |
Parse.initialize(app_id, javascript_key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function XMLHttpRequest() { | |
this._client = Ti.Network.createHTTPClient({ | |
autoEncodeUrl: false, | |
timeout: 5000 | |
}); | |
var _this = this; | |
this._client.onreadystatechange = function() { | |
_this._onreadystatechange(); | |
}; | |
this._client.onerror = function() { | |
_this.onerror(); | |
}; | |
}; | |
XMLHttpRequest.prototype = { | |
open: function(method, url, async) { | |
this._client.open(method, url, async); | |
}, | |
setRequestHeader: function(key, value) { | |
this._client.setRequestHeader(key, value); | |
}, | |
send: function(data) { | |
this._client.send(data); | |
}, | |
_onreadystatechange: function() { | |
if (this.onreadystatechange) { | |
this.readyState = this._client.readyState; | |
this.status = this._client.status; | |
this.responseText = this._client.responseText; | |
this.onreadystatechange(); | |
} | |
}, | |
onerror: function() { | |
if (this.onreadystatechange) { | |
this.readyState = this._client.DONE; | |
this.status = this._client.status; | |
this.responseText = this._client.responseText; | |
this.onreadystatechange(); | |
} | |
} | |
} | |
exports.XMLHttpRequest = XMLHttpRequest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parse JS API: https://parse.com/downloads/javascript/parse-1.2.12.js