Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we only try to process reponse as JSON for files #210

Merged
merged 2 commits into from
Jan 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions public/assets/js/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,28 @@ $doc.ready(function() {
}
}

var newFile = JSON.parse(data);

if ( values[1]['value'] == 'files' ) {
$reportURL.attr('href', newFile.url);

$reportID.each( function() {
$(this).attr('value', newFile.id);
});
// Ensure we were looking at a file before we try to parse the file
// response from the server
for(var prop in values){
if(values.hasOwnProperty(prop)){
if(values[prop].name == "contenttype" && values[prop].value == "files") {
try {
var newFile = JSON.parse(data);

if ( values[1]['value'] == 'files' ) {
$reportURL.attr('href', newFile.url);

$reportID.each( function() {
$(this).attr('value', newFile.id);
});
}
} catch(e){
try {
console.log('Failed to parse JSON response during a File based UFIXIT attempt!')
} catch(e){}
}
}
}
}

$submit.addClass('inactive');
Expand Down