Tuesday, November 25, 2014

Document viewer in DSpace with JSPUI


Open the [utils.js] file in any editor

sudo gedit /dspace/webapps/jspui/utils.js

copy the following code in utils.js file


-------------------copy bellow lines in utils.js at the end of all codes--------

var flag=0
$( document ).ready(function() {
jQuery(".standard").find("a[target='_blank']").each(function(){
  jQuery(this).attr('value',jQuery(this).attr('href'));
  jQuery(this).removeAttr('href');
  jQuery(this).css("text-decoration", "underline");
  jQuery(this).css("cursor", "pointer");

 
});
  jQuery(".metadataFieldLabel").each( function(index){     
if(jQuery(this).text().trim().replace(/:/g, '').replace(" ",'') == 'EnteredBy'){
$(this).next().remove();
$(this).remove();
} });
    jQuery(".standard").find("a[target='_blank']").on( "click", function() {   
if(flag==1){
jQuery( this ).parents('table').parents('table').eq(0).find('tr:last').remove();
jQuery( this ).parents('table').parents('table').eq(0).find('tr:last').remove();
jQuery( this ).parents('table').parents('table').eq(0).append("<tr><td><object style='overflow: auto;' data='"+jQuery( this ).attr('value')+"' type='application/pdf' width='100%' height='548px'></object><td><tr>");   
}else{
flag=1;
jQuery( this ).parents('table').parents('table').eq(0).append("<tr><td><object style='overflow: auto;' data='"+jQuery( this ).attr('value')+"' type='application/pdf' width='100%' height='548px'></object><td><tr>");   
}
 

});
}); 



---------------------end up the code-------------------------------------

Document viewer can look like bellow




3 comments:

Unknown said...

Thank you very much for sharing & guidance! I tried to edit utils.js but when I restart tomcat . Viewe button don't work. Please help me how to config pdf view online only, don't permit download for member of DSpace (I use jspui). Thanks in advanced! My email: dspacehuha@gmail.com.

Unknown said...

Thank you very much for sharing & guidance! I tried to edit utils.js but when I restart tomcat . Viewe button don't work. Please help me how to config pdf view online only, don't permit download for member of DSpace (I use jspui). Thanks in advanced! My email: dspacehuha@gmail.com.

pratishjha said...

I have pasted the code but nothing happened...just wanted to show pdf's in a viewer..is any more configuration to do for above.

How to migrate Linux Dspace to Window 10

Take a backup of Dspace database and folder s Assume the version is same with both OS [I have tested DSpace 6.3] sudo su mkdir dspace_backup...