if ( typeof KOHA == "undefined" || !KOHA ) {
var KOHA = {};
}
KOHA.RecordedBooks = new function() {
var svc_url = '/cgi-bin/koha/svc/recordedbooks';
var error_div = $('
');
function display_error ( error ) {
error_div.text(error);
}
var details = null;
function is_identified() {
return details ? details.is_identified : false;
}
var checkout_popup = null;
$( document ).ready(function() {
checkout_popup = $("#recordedbooks-checkout");
});
function display_account (container, data) {
if (!data.is_identified) {
return;
}
if (data.checkouts) {
var checkouts_div = $('
').html('
' + MSG_CHECKOUTS + '
');
var items = data.checkouts.items;
var checkouts_list;
if (items.length == 0) {
checkouts_list = MSG_NO_CHECKOUTS;
} else {
checkouts_list = $('
');
data.checkouts.items.forEach(function(item) {
item_line(checkouts_list, item);
});
}
checkouts_div.append(checkouts_list);
$(container).append(checkouts_div);
}
if (data.holds) {
var holds_div = $('
').html('
' + MSG_HOLDS + '
');
var items = data.holds.items;
var holds_list;
if (items.length == 0) {
holds_list = MSG_NO_HOLDS;
} else {
holds_list = $('
');
data.holds.items.forEach(function(item) {
item_line(holds_list, item);
});
}
holds_div.append(holds_list);
$(container).append(holds_div);
}
}
function item_line(ul_el, item) {
var line = $('
');
if (item.images) {
var thumb_url = item.images.small;
if (thumb_url) {
$('')
.attr("src", thumb_url)
.appendTo(line);
}
}
$('