|
1 | 1 | (function(exports) { |
2 | 2 | $(document).on("loadedrecordform.aspace", function(event, $pane) { |
3 | | - const name = $('label[for=archival_object_component_id_]').parent().find('div').text() || document.location.hash.split('::')[1]; |
4 | | - const data = $('label[for=archival_object_ref_id_]').parent().find('.identifier-display').text(); |
5 | | - const text = document.location.hash.split('::')[1].split('_')[2]; |
| 3 | + const loc_hash = document.location.hash.split('::'); |
| 4 | + if (loc_hash.length > 1) { |
| 5 | + const name = $('label[for=archival_object_component_id_]').parent().find('div').text() || loc_hash[1]; |
| 6 | + const data = $('label[for=archival_object_ref_id_]').parent().find('.identifier-display').text(); |
| 7 | + const text = loc_hash[1].split('_')[2]; |
6 | 8 |
|
7 | | - if (data) { |
8 | | - const url = AS.app_prefix('/plugins/getty_barcode?data=' + data + '&name=barcode_' + name + '&text=' + text); |
9 | | - const bbut = '<a id="getty-barcode-button" class="btn btn-sm btn-default" href="' + url + '">Barcode</a>'; |
10 | | - $('.record-toolbar > .btn-toolbar > .btn-group').prepend(bbut); |
| 9 | + if (data) { |
| 10 | + const url = AS.app_prefix('/plugins/getty_barcode?data=' + data + '&name=barcode_' + name + '&text=' + text); |
| 11 | + const bbut = '<a id="getty-barcode-button" class="btn btn-sm btn-default" href="' + url + '">Barcode</a>'; |
| 12 | + $('.record-toolbar > .btn-toolbar > .btn-group').prepend(bbut); |
11 | 13 |
|
12 | | - // show the barcode in the title area. disable for now. not sure if it's required |
13 | | - // 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>'; |
14 | | - // $('.record-pane').prepend(bimg); |
| 14 | + // show the barcode in the title area. disable for now. not sure if it's required |
| 15 | + // 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>'; |
| 16 | + // $('.record-pane').prepend(bimg); |
| 17 | + } |
15 | 18 | } |
16 | 19 | }); |
17 | 20 | }(window)); |
|
0 commit comments