-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkoha-catalog.js
More file actions
52 lines (46 loc) · 2.43 KB
/
koha-catalog.js
File metadata and controls
52 lines (46 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ==UserScript==
// @name Koha Catalog for Staff
// @namespace https://libraries.cca.edu
// @version 1.4.1
// @description handy links & functions for staff use of Koha OPAC
// @author @phette23
// @match https://library.cca.edu/cgi-bin/koha/*
// @grant none
// @updateURL https://raw.githubusercontent.com/cca/libraries_tampermonkey/main/koha-catalog.js
// @downloadURL https://raw.githubusercontent.com/cca/libraries_tampermonkey/main/koha-catalog.js
// ==/UserScript==
function runWhenJQueryLoaded(callback) {
if (window.jQuery) callback(window.jQuery)
else setTimeout(() => runWhenJQueryLoaded(callback), 100)
}
runWhenJQueryLoaded(function($) {
$(document).ready(function () {
console.log('Running Koha Catalog for Staff script.')
// show total results, informative for us & useless for patrons
$('#numresults').show()
// record detail page enhancements
if (location.pathname === '/cgi-bin/koha/opac-detail.pl') {
// show all the "views": normal, marc, ISBD
const views = $('#views').show()
// insert links to edit & view record on staff side
const id = new URLSearchParams(location.search).get('biblionumber')
if (id && id.match(/^\d+$/)) {
views.append(
`<span class="view"><a id="staffView" href="https://library-staff.cca.edu/cgi-bin/koha/cataloguing/editor.pl#catalog/${id}" style="background-position:-10px -56px;">Edit MARC</a></span>`,
)
views.append(
`<span class="view"><a id="staffView" href="https://library-staff.cca.edu/cgi-bin/koha/catalogue/detail.pl?biblionumber=${id}" style="background-position:-10px -56px;">Staff</a></span>`,
)
}
// link to Summon search, title is null in ISBD view
const title = encodeURIComponent($('h1.title').text())
if (title) {
const summon_url = 'https://cca.summon.serialssolutions.com/#!/search?fvf=SourceType,Library%20Catalog&q=' + title
views.append(`<span class="view"><a id="summonSearch" href="${summon_url}" style="background-position:-10px -56px;">Summon</a></span>`)
}
// show "print record" & "export" actions, these are hidden in our OpacUserJS
$('.print-large').parent('li').show()
$('#export').parent('li').show()
}
})
})