Skip to content

Commit

Permalink
fix javascript when not on an ao page
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed Apr 4, 2023
1 parent 8c8f26e commit d3f0a8d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions frontend/assets/getty_barcode.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
(function(exports) {
$(document).on("loadedrecordform.aspace", function(event, $pane) {
const name = $('label[for=archival_object_component_id_]').parent().find('div').text() || document.location.hash.split('::')[1];
const data = $('label[for=archival_object_ref_id_]').parent().find('.identifier-display').text();
const text = document.location.hash.split('::')[1].split('_')[2];
const loc_hash = document.location.hash.split('::');
if (loc_hash.length > 1) {
const name = $('label[for=archival_object_component_id_]').parent().find('div').text() || loc_hash[1];
const data = $('label[for=archival_object_ref_id_]').parent().find('.identifier-display').text();
const text = loc_hash[1].split('_')[2];

if (data) {
const url = AS.app_prefix('/plugins/getty_barcode?data=' + data + '&name=barcode_' + name + '&text=' + text);
const bbut = '<a id="getty-barcode-button" class="btn btn-sm btn-default" href="' + url + '">Barcode</a>';
$('.record-toolbar > .btn-toolbar > .btn-group').prepend(bbut);
if (data) {
const url = AS.app_prefix('/plugins/getty_barcode?data=' + data + '&name=barcode_' + name + '&text=' + text);
const bbut = '<a id="getty-barcode-button" class="btn btn-sm btn-default" href="' + url + '">Barcode</a>';
$('.record-toolbar > .btn-toolbar > .btn-group').prepend(bbut);

// show the barcode in the title area. disable for now. not sure if it's required
// const bimg = '<div class="pull-right"><a href="' + url + '" title="Click to download"><img id="getty-barcode-image" style="height:50px;" src="' + url + '"/></a></div>';
// $('.record-pane').prepend(bimg);
// show the barcode in the title area. disable for now. not sure if it's required
// const bimg = '<div class="pull-right"><a href="' + url + '" title="Click to download"><img id="getty-barcode-image" style="height:50px;" src="' + url + '"/></a></div>';
// $('.record-pane').prepend(bimg);
}
}
});
}(window));
Expand Down

0 comments on commit d3f0a8d

Please sign in to comment.