-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bug 37496 item barcodes should go to specific item
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Bug 37496: Restore parameter to limit to details of one item | ||
if (location.pathname.match('/cgi-bin/koha/catalogue/detail.pl')) { | ||
// holdings table not available on page load | ||
setTimeout(() => { | ||
console.log($('#holdings_table')) | ||
// barcode is literally the only <td> with no unique classname :eyeroll: | ||
$('#holdings_table td > a[href^="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="]').each(function (idx, el) { | ||
console.log(el) | ||
// parse item id from item#### fragment at end of link | ||
const url = new URL(el.href) | ||
const item = url.hash.match(/#item(\d+)/)[1] | ||
if (item) { | ||
url.searchParams.set('item', item) | ||
$(this).attr('href', url.toString()) | ||
} | ||
}) | ||
}, 1000) | ||
} |