Last active
November 14, 2018 18:00
-
-
Save aaronksaunders/5443666 to your computer and use it in GitHub Desktop.
Tested w/ latest version of parse "parse-1.2.7.js"
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 TiParse = function(options) { | |
// need to convert this to requires | |
Ti.include("parse-1.2.7.js"); | |
Parse.localStorage = { | |
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); | |
} | |
} | |
Parse._ajax = function(method, url, data, success, error) { | |
var options = { | |
success: success, | |
error: error | |
}; | |
var promise = new Parse.Promise, handled = !1, xhr = Ti.Network.createHTTPClient({ | |
timeout : 5000 | |
}); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState === 4) { | |
if (handled) return; | |
handled = !0; | |
if (xhr.status >= 200 && xhr.status < 300) { | |
var response; | |
try { | |
response = JSON.parse(xhr.responseText); | |
} catch (e) { | |
promise.reject(e); | |
} | |
response && promise.resolve(response, xhr.status, xhr); | |
} else promise.reject(xhr); | |
} | |
}; | |
xhr.open(method, url, !0); | |
xhr.setRequestHeader("Content-Type", "text/plain"); | |
Parse._isNode && xhr.setRequestHeader("User-Agent", "Parse/" + Parse.VERSION + " (NodeJS " + process.versions.node + ")"); | |
xhr.send(data); | |
return promise._thenRunCallbacks(options); | |
}; | |
Parse.initialize("Application ID", "JavaScript key"); | |
return Parse; | |
}; | |
module.exports = TiParse; |
updated gist here http://bit.ly/16rKE77 this should work with the most recent version of the parse SDK
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try and route out parse-1.2.7.js - new versions have some elements that do not get "titaniumified" by this script.