You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB
JavaScript

5 years ago
$(document).ready(function() {
var split, filename, grid;
split = window.location.href.split('/');
filename = split[split.length-1];
grid = split[split.length-2];
displayPDF(grid, filename);
});
function displayPDF(grid, filename) {
var BASE_URL='http://dev.unboundedpress.org';
$.getJSON(BASE_URL+"/unboundedpress/"+grid+".files?filter={'filename':'"+filename+"'}", function(data){
var score, details;
score = data._embedded['rh:file'];
console.log(score);
if (score) {
var details = $('<object>').attr({
data: BASE_URL + score[0]._links['rh:data'].href,
type: score.contentType,
width:'100%',
height:'100%'});
$('#pdfdiv').html(details);
} else {
$('#pdfdiv').html("file not found")
}
/*else {
$.getJSON(BASE_URL+"/unboundedpress/scores.files?filter={'legacy_filename':'"+filename+"'}", function(data){
var score, details;
score = data._embedded['rh:file'];
if (score) {
var details = $('<object>').attr({
data: BASE_URL + score[0]._links['rh:data'].href,
type:'application/pdf',
width:'100%',
height:'100%'});
$('#pdfdiv').html(details);
} else {
$('#pdfdiv').html("file not found")
}
});
}*/
});
}