diff --git a/grails-app/assets/javascripts/application-pages.js b/grails-app/assets/javascripts/application-pages.js index 4f107076..3b2b6d0a 100644 --- a/grails-app/assets/javascripts/application-pages.js +++ b/grails-app/assets/javascripts/application-pages.js @@ -13,4 +13,5 @@ //= require datatables.min.js //= require ala/ala-charts.js //= require collectory.js +//= require images.js //= require_self diff --git a/grails-app/assets/javascripts/images.js b/grails-app/assets/javascripts/images.js new file mode 100644 index 00000000..d71bc932 --- /dev/null +++ b/grails-app/assets/javascripts/images.js @@ -0,0 +1,40 @@ +/** + * Populate Images tab body with images via AJAX call to Biocache + */ +function loadImagesTab() { + var wsBase = "/occurrences/search.json"; + var uiBase = "/occurrences/search"; + var imagesQueryUrl = "?facets=type_status&fq=multimedia%3AImage&pageSize=100&q=collectionUid:" + SHOW_REC.instanceUuid; + $.ajax({ + url: SHOW_REC.biocacheServicesUrl + wsBase + imagesQueryUrl, + dataType: 'jsonp', + timeout: 20000, + complete: function(jqXHR, textStatus) { + if (textStatus == 'timeout') { + noBiocacheData(); + } + if (textStatus == 'error') { + noBiocacheData(); + } + }, + success: function(data) { + // check for errors + if (data.length == 0 || data.totalRecords == undefined || data.totalRecords == 0) { + //noBiocacheData(); + } else { + if(data.totalRecords > 0){ + $('#imagesTabEl').css({display:'block'}); + var description = "" + $('#imagesSpiel').html('
' + data.totalRecords + ' images have been made available from the ' + SHOW_REC.instanceName + '.
' + description + '