4 * Format the biblio response from a Koha RESTful API request.
5 * @param {Object} biblio The biblio json object as returned from the Koha RESTful API
6 * @param {Object} config A configuration object
7 * Valid keys are: `link`
8 * @return {string} The formatted HTML string
10 window.$biblio_to_html = function(biblio, config) {
12 if (biblio === undefined) {
13 return ''; // empty string for no biblio
16 var title = '<span class="biblio-title">';
17 if (biblio.title != null && biblio.title != '') {
18 title += escape_str(biblio.title);
20 title += __("No title");
25 if (biblio.subtitle != null && biblio.subtitle != '') {
26 title += ' <span class="biblio-subtitle">' + escape_str(biblio.subtitle) + '</span>';
30 if (config && config.link) {
31 if (config.link === 'marcdetail') {
32 title = '<a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>';
33 } else if (config.link === 'labeled_marc') {
34 title = '<a href="/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>';
35 } else if (config.link === 'isbd') {
36 title = '<a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>';
38 title = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>';
43 if (biblio.medium != null && biblio.medium != '') {
44 title += ' <span class="biblio-medium">' + escape_str(biblio.medium) + '</span>';
47 // add part numbers/names
48 let part_numbers = (typeof biblio.part_number === 'string') ? biblio.part_number.split("|") : [];
49 let part_names = (typeof biblio.part_name === 'string') ? biblio.part_name.split("|") : [];
51 while (part_numbers[i] || part_names[i]) {
52 if (part_numbers[i]) {
53 title += ' <span class="part-number">' + escape_str(part_numbers[i]) + '</span>';
56 title += ' <span class="part-name">' + escape_str(part_names[i]) + '</span>';