Skip to content

Commit

Permalink
finding places to implement offline logic
Browse files Browse the repository at this point in the history
relates to #138
  • Loading branch information
pbywater committed Aug 2, 2017
1 parent 6b591a0 commit 5005742
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions public/scripts/s3-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
if (file == null) {
return new Error('No file selected.');
}
getSignedRequest(file);
if (navigator.onLine) {
getSignedRequest(file);
} else {
console.log('offline');
}
};
}());

Expand Down Expand Up @@ -45,17 +49,21 @@ function uploadFile(file, signedRequest, url) {
}

function updateTagAndHeading(imageId) {
document.getElementById('photo-save').onclick = function (e) {
e.preventDefault();
if (imageUploadPending) {
const tag = $('.tag-input--photo')[0].value;
const heading = $('.heading-input--photo')[0].value;
$.ajax({
method: 'PUT',
url: 'memory-input-photo',
data: { tag, heading, imageId },
success: () => { imageUploadPending = false; },
});
}
};
if (navigator.onLine) {
document.getElementById('photo-save').onclick = function (e) {
e.preventDefault();
if (imageUploadPending) {
const tag = $('.tag-input--photo')[0].value;
const heading = $('.heading-input--photo')[0].value;
$.ajax({
method: 'PUT',
url: 'memory-input-photo',
data: { tag, heading, imageId },
success: () => { imageUploadPending = false; },
});
}
};
} else {
console.log('offline logic');
}
}

0 comments on commit 5005742

Please sign in to comment.