| // following function called when they choose an image. i've tried a ton of variatiosn | |
| function handleChosenImage(w,image){ | |
| // set imageView to the image | |
| w.imageView.image = image; | |
| // timestamp stuff | |
| var timestamp = IQE_makeTimestamp() | |
| // image stuff | |
| var tempFile = Titanium.Filesystem.createTempFile(); | |
| tempFile.write(image); | |
| var contents = tempFile.read(); | |
| // upload to cocoafish | |
| CF.sendRequest('photos/create.json', 'POST', {photo: tempFile}, false, CFUploadImageCallback); // 400 - unable to load. i've tried tempFile, contents, tempFile.getNativePath() and a ton of other variations. | |
| } |
| // following function is called when someone submits the form. and it works. | |
| function handleLoginEvent(w) { | |
| var username = w.usernameTextField.value; | |
| var password = w.passwordTextField.value; | |
| var login_data = {login : username, password : password } | |
| if(username == null || username.length == 0 || password == null || password.length == 0) { | |
| alert("Please enter a username (usually your email) and password to login") | |
| return; | |
| } else { | |
| CF.sendRequest('users/login.json', 'POST', login_data, false, function(data){ | |
| if(data) { | |
| if(data.meta) { | |
| var meta = data.meta; | |
| if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'loginUser') { | |
| alert("login success") | |
| CF.sendRequest('users/show/me.json', 'GET', null, false, aboutMeCallback) | |
| } else { | |
| alert("Login unsuccessful") | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| } |