Line 0
Link Here
|
|
|
1 |
<script> |
2 |
(function() { |
3 |
/** |
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 |
9 |
*/ |
10 |
window.$itemtype_to_html = function( itemtype, config ) { |
11 |
|
12 |
if ( itemtype === undefined ) { |
13 |
return ''; // empty string for no itemtype |
14 |
} |
15 |
|
16 |
// Fetch list of itemtypes |
17 |
var itemtypes = $.ajax({ |
18 |
url: '/api/v1/itemtypes', |
19 |
dataType: 'json', |
20 |
type: 'GET' |
21 |
}); |
22 |
|
23 |
var title = '<span class="itemtype-title">'; |
24 |
if ( itemtype.title != null && itemtype.title != '' ) { |
25 |
title += escape_str(itemtype.title); |
26 |
} else { |
27 |
title += __("No title"); |
28 |
} |
29 |
title += '</span>'; |
30 |
|
31 |
if ( itemtype.subtitle != null && itemtype.subtitle != '' ) { |
32 |
title += '<span clas="itemtype-subtitle">' + escape_str(itemtype.subtitle) + '</span>'; |
33 |
} |
34 |
|
35 |
if (config && config.link) { |
36 |
if ( config.link === 'marcdetail' ) { |
37 |
title = '<a href="/cgi-bin/koha/catalogue/MARCdetail.pl?itemtypenumber='+ encodeURIComponent(itemtype.itemtype_id) +'">' + title + '</a>'; |
38 |
} |
39 |
else if ( config.link === 'labeled_marc') { |
40 |
title = '<a href="/cgi-bin/koha/catalogue/labeledMARCdetail.pl?itemtypenumber='+ encodeURIComponent(itemtype.itemtype_id) +'">' + title + '</a>'; |
41 |
} |
42 |
else if ( config.link === 'isbd' ) { |
43 |
title = '<a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?itemtypenumber='+ encodeURIComponent(itemtype.itemtype_id) +'">' + title + '</a>'; |
44 |
} |
45 |
else { |
46 |
title = '<a href="/cgi-bin/koha/catalogue/detail.pl?itemtypenumber='+ encodeURIComponent(itemtype.itemtype_id) +'">' + title + '</a>'; |
47 |
} |
48 |
} |
49 |
|
50 |
if ( itemtype.medium != null && itemtype.medium != '' ) { |
51 |
title += '<span class="itemtype-medium">'+escape_str(itemtype.medium)+'</span>'; |
52 |
} |
53 |
|
54 |
return title; |
55 |
}; |
56 |
})(); |
57 |
</script> |