Lines 1-50
Link Here
|
1 |
<script> |
1 |
< script > |
2 |
(function() { |
2 |
(function() { |
3 |
/** |
3 |
/** |
4 |
* Format the biblio response from a Koha RESTful API request. |
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 |
5 |
* @param {Object} biblio The biblio json object as returned from the Koha RESTful API |
6 |
* @param {Object} config A configuration object |
6 |
* @param {Object} config A configuration object |
7 |
* Valid keys are: `link` |
7 |
* Valid keys are: `link` |
8 |
* @return {string} The formatted HTML string |
8 |
* @return {string} The formatted HTML string |
9 |
*/ |
9 |
*/ |
10 |
window.$biblio_to_html = function( biblio, config ) { |
10 |
window.$biblio_to_html = function(biblio, config) { |
11 |
|
11 |
|
12 |
if ( biblio === undefined ) { |
12 |
if (biblio === undefined) { |
13 |
return ''; // empty string for no biblio |
13 |
return ''; // empty string for no biblio |
14 |
} |
14 |
} |
15 |
|
15 |
|
16 |
var title = '<span class="biblio-title">'; |
16 |
var title = '<span class="biblio-title">'; |
17 |
if ( biblio.title != null && biblio.title != '' ) { |
17 |
if (biblio.title != null && biblio.title != '') { |
18 |
title += escape_str(biblio.title); |
18 |
title += escape_str(biblio.title); |
19 |
} else { |
19 |
} else { |
20 |
title += __("No title"); |
20 |
title += __("No title"); |
21 |
} |
21 |
} |
22 |
title += '</span>'; |
22 |
title += '</span>'; |
23 |
|
23 |
|
24 |
if ( biblio.subtitle != null && biblio.subtitle != '' ) { |
24 |
// add subtitle |
25 |
title += '<span clas="biblio-subtitle">' + escape_str(biblio.subtitle) + '</span>'; |
25 |
if (biblio.subtitle != null && biblio.subtitle != '') { |
|
|
26 |
title += '<span class="biblio-subtitle">' + escape_str(biblio.subtitle) + '</span>'; |
26 |
} |
27 |
} |
27 |
|
28 |
|
|
|
29 |
// set title as link |
28 |
if (config && config.link) { |
30 |
if (config && config.link) { |
29 |
if ( config.link === 'marcdetail' ) { |
31 |
if (config.link === 'marcdetail') { |
30 |
title = '<a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>'; |
32 |
title = '<a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>'; |
31 |
} |
33 |
} else if (config.link === 'labeled_marc') { |
32 |
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>'; |
33 |
title = '<a href="/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>'; |
35 |
} else if (config.link === 'isbd') { |
34 |
} |
36 |
title = '<a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>'; |
35 |
else if ( config.link === 'isbd' ) { |
37 |
} else { |
36 |
title = '<a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>'; |
38 |
title = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + encodeURIComponent(biblio.biblio_id) + '" class="title">' + title + '</a>'; |
37 |
} |
|
|
38 |
else { |
39 |
title = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>'; |
40 |
} |
39 |
} |
41 |
} |
40 |
} |
42 |
|
41 |
|
43 |
if ( biblio.medium != null && biblio.medium != '' ) { |
42 |
// add medium |
44 |
title += '<span class="biblio-medium">'+escape_str(biblio.medium)+'</span>'; |
43 |
if (biblio.medium != null && biblio.medium != '') { |
|
|
44 |
title += '<span class="biblio-medium">' + escape_str(biblio.medium) + '</span>'; |
45 |
} |
46 |
|
47 |
// add part numbers/names |
48 |
let part_numbers = biblio.part_number.split("|"); |
49 |
let part_names = biblio.part_name.split("|"); |
50 |
let i = 0; |
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>'; |
54 |
} |
55 |
if (part_names[i]) { |
56 |
title += '<span class="part-name">'+escape_str(part_name[i])+'</span>'; |
57 |
} |
58 |
i++; |
45 |
} |
59 |
} |
46 |
|
60 |
|
47 |
return title; |
61 |
return title; |
48 |
}; |
62 |
}; |
49 |
})(); |
63 |
})(); < |
50 |
</script> |
64 |
/script> |
51 |
- |
|
|