aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-30 14:46:45 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-30 14:46:45 +0100
commit611b3c665a1fc02bb45036db7b1100dddabb5db6 (patch)
treef4776bf8c2f459c35df2fbb73ec6e61c7596e475 /www/js
parent43d40199ac0e68ea58ddf7f58b02a8430028d911 (diff)
properly parse response back when submitting a report with a photo
make sure we re-enable all submit buttons after photo upload error
Diffstat (limited to 'www/js')
-rw-r--r--www/js/mobile.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/www/js/mobile.js b/www/js/mobile.js
index 554872a..01c87fa 100644
--- a/www/js/mobile.js
+++ b/www/js/mobile.js
@@ -187,8 +187,19 @@ function takePhoto(type) {
function fileUploadSuccess(r) {
console.log( r.response );
console.log( typeof r.response );
- if ( r.response.indexOf( 'success' ) >= 0 ) {
- window.location = 'email_sent.html';
+ if ( r.response ) {
+ var data = JSON.parse( r.response );
+ if ( data.success ) {
+ if ( data.report ) {
+ localStorage.report = data.report;
+ window.location = 'report_created.html';
+ } else {
+ window.location = 'email_sent.html';
+ }
+ } else {
+ alert('Could not submit report');
+ $('input[type=submit]').prop("disabled", false);
+ }
} else {
alert('Could not submit report');
$('input[type=submit]').prop("disabled", false);
@@ -197,6 +208,7 @@ function fileUploadSuccess(r) {
function fileUploadFail() {
alert('Could not submit report');
+ $('input[type=submit]').prop("disabled", false);
}