Last active
July 3, 2019 07:36
-
-
Save xmorave2/65a1fe2b1d4730f4daba9e89a322acac to your computer and use it in GitHub Desktop.
Obálky knih v intranetu Kohy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cover_obalkyknih, #catalogue_detail_biblio { | |
float:left; | |
} | |
#cover_obalkyknih { | |
margin-right: 10px; | |
margin-top: 5px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Obálky knih v3 */ | |
var obalky = obalky || {}; | |
obalky.cacheUrl = obalky.cacheUrl || "https://cache.obalkyknih.cz"; | |
obalky.coverUrl = obalky.cacheUrl + "/api/cover"; | |
obalky.tocUrl = obalky.cacheUrl + "/api/toc/thumbnail"; | |
obalky.pdfUrl = obalky.cacheUrl + "/api/toc/pdf"; | |
obalky.linkUrl = "https://www.obalkyknih.cz/view"; | |
obalky.coverText = "cover"; | |
obalky.tocText = "table of content"; | |
obalky.queryPart = obalky.href || function(bibinfo) { | |
var queryPart = ""; | |
var sep = ""; | |
$.each(bibinfo, function (name, value) { | |
queryPart += sep + name + "=" + encodeURIComponent(value); | |
sep = "&"; | |
}); | |
return queryPart; | |
} | |
obalky.coverTargetUrl = obalky.coverTargetUrl || function (bibinfo) { | |
return obalky.linkUrl + "?" + obalky.queryPart(bibinfo); | |
} | |
obalky.pdfTargetUrl = obalky.pdfTargetUrl || function (bibinfo) { | |
return obalky.pdfUrl + "?" + obalky.queryPart(bibinfo); | |
} | |
obalky.imageIsLoaded = obalky.imageIsLoaded || function (image) { | |
return (image.height > 1 && image.width > 1); | |
} | |
obalky.fetchImage = obalky.fetchImage || function (element, bibinfo, query, type) { | |
var img = new Image(); | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
var dim = "height='80' width='63'"; | |
if (type == "thumbnail") { | |
dim = "height='36' width='27'"; | |
} | |
$(element).html("<a href='" + href + "' class='title'><img src='" + img.src + "' alt='" + obalky.coverText + "' " + dim + "></img></a>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=" + type + "&keywords=" + encodeURIComponent(query); | |
} | |
obalky.fetchImage = obalky.fetchImageWithoutLinks || function (element, bibinfo, query, type) { | |
var img = new Image(); | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
var dim = "height='80' width='63'"; | |
if (type == "thumbnail") { | |
dim = "height='36' width='27'"; | |
} | |
$("[id=" + $(element).attr('id') + "]").html("<img src='" + img.src + "' alt='" + obalky.coverText + "' " + dim + "></img>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=" + type + "&keywords=" + encodeURIComponent(query); | |
} | |
obalky.display_thumbnail = obalky.display_thumbnail || function (element, bibinfo, query, type) { | |
type = type || "icon"; | |
$(document).ready( | |
obalky.fetchImage(element, bibinfo, query, type) | |
); | |
} | |
obalky.display_thumbnail_without_links = obalky.display_thumbnail || function (element, bibinfo, query, type) { | |
type = type || "icon"; | |
$(document).ready( | |
obalky.fetchImageWithoutLinks(element, bibinfo, query, type) | |
); | |
} | |
obalky.display_cover = obalky.display_cover || function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><a href='" + href + "' class='title'><img align='left' src='" + img.src + "' alt='" + obalky.coverText + "'></img></a></div>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.pdfTargetUrl(bibinfo); | |
$(element).append("<div class='toc_thumbnail'><a href='" + href + "' class='title'><img align='left' src='" + img.src + "' alt='" + obalky.tocText + "'></img></a></div>"); | |
} | |
} | |
img.src = obalky.tocUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
} | |
obalky.display_cover_without_links = function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><img align='left' src='" + img.src + "' alt='" + obalky.coverText + "'></img></div>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.pdfTargetUrl(bibinfo); | |
$(element).append("<div class='toc_thumbnail'><a href='" + href + "' class='title'><img align='left' src='" + img.src + "' alt='" + obalky.tocText + "'></img></a></div>"); | |
} | |
} | |
img.src = obalky.tocUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
$(document).ready(function() { | |
if ($(element).length > 0) { | |
if (!$(element+' div:first-child').hasClass("iconlabel")) { | |
$(element).append("<div align='left' style='padding-left: 0px; width:170px; text-align:center;' class='obalky-knih-link col-md-12'>"+VuFind.translate('Source')+": <a href='"+ obalky.coverTargetUrl(bibinfo) +"' class='title' target='_blank'>Obálky knih</a></div>"); | |
} | |
} | |
}); | |
} | |
obalky.display_cover_without_links = function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><img align='left' src='" + img.src + "' alt='" + obalky.coverText + "'></img></div>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.pdfTargetUrl(bibinfo); | |
$(element).append("<div class='toc_thumbnail'><a href='" + href + "' class='title'><img align='left' src='" + img.src + "' alt='" + obalky.tocText + "'></img></a></div>"); | |
} | |
} | |
img.src = obalky.tocUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
}); | |
$(document).ready(function() { | |
setTimeout(function() { | |
if ($(element).length > 0) { | |
if (!$(element+' div:first-child').hasClass("iconlabel")) { | |
$(element).append("<div align='left' style='padding-left: 0px; width:170px; text-align:center;' class='obalky-knih-link col-md-12'>"+VuFind.translate('Source')+": <a href='"+ obalky.coverTargetUrl(bibinfo) +"' class='title' target='_blank'>Obálky knih</a></div>"); | |
} | |
} | |
}, 2000); | |
}); | |
} | |
obalky.display_thumbnail_cover_without_links = function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><img align='center' width='100' src='" + img.src + "' alt='" + obalky.coverText + "'></img></div>"); | |
} | |
} | |
img.src = obalky.coverUrl + "?multi=" + multi + "&type=medium&keywords=" + encodeURIComponent(query); | |
if (bibinfo.cover_medium_url) { | |
img.src = bibinfo.cover_medium_url; | |
} | |
}); | |
} | |
obalky.display_authority_cover = function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><img align='left' src='" + img.src + "' alt='" + obalky.coverText + "'></img></div>"); | |
} | |
} | |
img.src = bibinfo.cover_medium_url; | |
}); | |
} | |
obalky.display_authority_thumbnail_cover_without_links = function (element, bibinfo, query) { | |
var multi = encodeURIComponent(JSON.stringify(bibinfo)); | |
$(document).ready(function() { | |
var img = new Image(); | |
img.onload = function() { | |
if (obalky.imageIsLoaded(img)) { | |
var href = obalky.coverTargetUrl(bibinfo); | |
$(element).html("<div class='cover_thumbnail'><img align='left' width='65' src='" + img.src + "' alt='" + obalky.coverText + "'></img></div>"); | |
} | |
} | |
img.src = bibinfo.cover_medium_url; | |
}); | |
} | |
$(document).ready(function() { | |
if ( $("#catalogue_detail_biblio").length ) { | |
$("#catalogue_detail_biblio").parent(".yui-g").prepend("<div id='cover_obalkyknih'></div>"); | |
obalky.display_cover("#cover_obalkyknih", { | |
"isbn": $("[property='ISBN'],[property='isbn']").text(), | |
"issn": $("[property='ISSN'],[property='issn']").text() | |
}); | |
} | |
if ( $("#auth_detail").length ) { | |
var values = $("#auth_detail #tab1XX .tag p").last().text().split(" "); | |
var value = values[values.length-4]; | |
$("#auth_detail .yui-t7").prepend("<div id='cover_authority'></div>"); | |
obalky.display_authority_cover("#cover_authority", { "auth_id": value }); | |
} | |
}); | |
/* end of obalky knih */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment