Koha/koha-tmpl/intranet-tmpl/prog/js/coce.js
Charles Farmer 3c0cdedfb0
Bug 18421: Add Coce to the staff intranet
TEST PLAN:
    1) Apply the patch with git-bz
    2) Run updatedatabase.pl
        2.1) Console output should confirm database modification
    3) Visit the 'Enhanced Content' tab of admin/syspref
        3.1) ressource is /cgi-bin/koha/admin/preferences.pl?tab=enhanced_content
        3.2) You should see that the previous preference, Coce, is now CoceOPAC,
             and that a new preference was added, CoceIntranet
    4) Activate CoceIntranet
    5) Do a search for a book for which you have a Coce cover
        5.1) The cover image url should now point to a provider you defined in Coce
        5.2) Your Coce log should show a query
    6) Click on the book's name to visit the detail.pl page
        6.1) The book's cover should also be provided by Coce on that page

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-07 14:09:12 +01:00

43 lines
1.2 KiB
JavaScript

if (KOHA === undefined || !KOHA) { var KOHA = {}; }
/**
* A namespace for Coce cover images cache
*/
KOHA.coce = {
/**
* Search all:
* <div title="biblionumber" id="isbn" class="coce-thumbnail"></div>
* or
* <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div>
* and run a search with all collected isbns to coce cover service.
* The result is asynchronously returned, and used to append <img>.
*/
getURL: function(host,provider,newWindow) {
var ids = [];
$("[id^=coce-thumbnail]").each(function(i) {
var id = $(this).attr("class"); // id=isbn
if ( id !== '' ) { ids.push(id); }
});
if (ids.length == 0) return;
ids = ids.join(',');
var coceURL = host + '/cover?id=' + ids + '&provider=' + provider;
$.ajax({
url: coceURL,
dataType: 'jsonp',
success: function(urlPerID){
for (var id in urlPerID) {
var url = urlPerID[id];
$("[id^=coce-thumbnail]."+id).each(function() {
var img = document.createElement("img");
img.src = url;
img.title = url; //FIXME: to delete
$(this).html(img);
});
}
}
});
}
};