From 071bf09ac975d7375873b7722dd76b9370957ae9 Mon Sep 17 00:00:00 2001 From: phette23 Date: Thu, 3 Oct 2024 14:44:33 -0700 Subject: [PATCH] refactor: no more 'path' alias for location.pathname this was always sort of hacky and it's weird to rely on the scripts to be concatenated in a particular order plus it made copy-pasting any single script not work because you needed to define path = location.pathname first --- admin-js/_path.js | 2 -- admin-js/acq-neworder.js | 2 +- admin-js/acq-orderreceive.js | 2 +- admin-js/catalog-additem.js | 2 +- admin-js/catalog-home.js | 2 +- admin-js/circ-holds.js | 2 +- admin-js/circ-returns.js | 2 +- admin-js/course-reserves.js | 2 +- admin-js/mainpage.js | 2 +- admin-js/paycollect.js | 2 +- admin-js/serials-edit.js | 2 +- admin-js/serials-menu.js | 2 +- catalog-js/_globals.js | 3 --- catalog-js/account.js | 2 +- catalog-js/article-request.js | 2 +- catalog-js/comics-plus-cover.js | 2 +- catalog-js/course-reserves.js | 2 +- catalog-js/details-actions.js | 2 +- catalog-js/details.js | 2 +- catalog-js/holdings-table-filter.js | 2 +- catalog-js/holds.js | 2 +- catalog-js/home-search.js | 2 +- catalog-js/item-type-icons.js | 2 +- catalog-js/librarian-chat.js | 2 +- catalog-js/login-redirects.js | 18 +++++++++--------- catalog-js/mat-lib.js | 2 +- catalog-js/memberentry.js | 2 +- catalog-js/passwd.js | 2 +- catalog-js/reserves.js | 2 +- catalog-js/save-to-lists.js | 12 ++++++------ catalog-js/search.js | 4 ++-- catalog-js/serials-solutions-holdings.js | 2 +- catalog-js/user.js | 2 +- 33 files changed, 45 insertions(+), 50 deletions(-) delete mode 100644 admin-js/_path.js delete mode 100644 catalog-js/_globals.js diff --git a/admin-js/_path.js b/admin-js/_path.js deleted file mode 100644 index 9194c94..0000000 --- a/admin-js/_path.js +++ /dev/null @@ -1,2 +0,0 @@ -// shortcut var because we use this in almost every snippet -let path = location.pathname diff --git a/admin-js/acq-neworder.js b/admin-js/acq-neworder.js index 96c8b6d..242bf32 100644 --- a/admin-js/acq-neworder.js +++ b/admin-js/acq-neworder.js @@ -1,7 +1,7 @@ // set notforloan = "ordered" for new orders // NOTE: the pattern below matches multiple paths // e.g. acqui/neworderempty.pl, acqui/neworderbiblio.pl, acqui/newordersuggestion.pl -if (path.match('/cgi-bin/koha/acqui/neworder')) { +if (location.pathname.match('/cgi-bin/koha/acqui/neworder')) { $(() => { function set_defaults () { let select = $('#subfield7 select') diff --git a/admin-js/acq-orderreceive.js b/admin-js/acq-orderreceive.js index 2f87523..478c822 100644 --- a/admin-js/acq-orderreceive.js +++ b/admin-js/acq-orderreceive.js @@ -1,6 +1,6 @@ // on the Acquisitions "receive items" page // check the "Received?" box by default & fill in actual price -if (path === '/cgi-bin/koha/acqui/orderreceive.pl') { +if (location.pathname === '/cgi-bin/koha/acqui/orderreceive.pl') { // run after document load $(()=>{ // almost no classees or other good selector hooks on this page diff --git a/admin-js/catalog-additem.js b/admin-js/catalog-additem.js index 883fb7f..d791955 100644 --- a/admin-js/catalog-additem.js +++ b/admin-js/catalog-additem.js @@ -1,5 +1,5 @@ // replacementpricedate is a date field but inexplicably doesn't use a datepicker -if (path.match('/cgi-bin/koha/cataloguing/additem.pl')) { +if (location.pathname.match('/cgi-bin/koha/cataloguing/additem.pl')) { $( // run a second after DOM load, hopefully form is present setTimeout( function () { diff --git a/admin-js/catalog-home.js b/admin-js/catalog-home.js index a2c2321..2a88bb3 100644 --- a/admin-js/catalog-home.js +++ b/admin-js/catalog-home.js @@ -1,5 +1,5 @@ // hide "new from z39.50/SRU" while it's broken // https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37947 -if (path.match('/cgi-bin/koha/cataloguing/cataloging-home.pl')) { +if (location.pathname.match('/cgi-bin/koha/cataloguing/cataloging-home.pl')) { $('#z3950search').parent().hide() } diff --git a/admin-js/circ-holds.js b/admin-js/circ-holds.js index 9c06fe6..b8b5dba 100644 --- a/admin-js/circ-holds.js +++ b/admin-js/circ-holds.js @@ -1,5 +1,5 @@ // "place a hold" page, accessible from multiple places -if (path.match('/cgi-bin/koha/reserve/request.pl')) { +if (location.pathname.match('/cgi-bin/koha/reserve/request.pl')) { $(()=>{ // uncheck "hold next avail. item" on holds page // we don't want people placing bib-level holds by accident diff --git a/admin-js/circ-returns.js b/admin-js/circ-returns.js index db83e43..199beb6 100644 --- a/admin-js/circ-returns.js +++ b/admin-js/circ-returns.js @@ -1,5 +1,5 @@ // run only on the checkin page -if (path.match('/cgi-bin/koha/circ/returns.pl')) { +if (location.pathname.match('/cgi-bin/koha/circ/returns.pl')) { // run on document load $(function(){ // loop over each row in the checkin table diff --git a/admin-js/course-reserves.js b/admin-js/course-reserves.js index 42c4da3..b235ec2 100644 --- a/admin-js/course-reserves.js +++ b/admin-js/course-reserves.js @@ -1,6 +1,6 @@ // If you delete a course reserve without first removing all items from it // the item fields get all messed up, this stops us from doing that. -if (path.match('/cgi-bin/koha/course_reserves/course-details.pl')) { +if (location.pathname.match('/cgi-bin/koha/course_reserves/course-details.pl')) { let num_items = $('#course_reserves_table tbody tr').length if (num_items > 0) { // disable Delete Course button diff --git a/admin-js/mainpage.js b/admin-js/mainpage.js index 77a49e7..0cd70cf 100644 --- a/admin-js/mainpage.js +++ b/admin-js/mainpage.js @@ -1,5 +1,5 @@ // modifications to the "main page" — page staff see right after logging in -if (path.match('/cgi-bin/koha/mainpage.pl')) { +if (location.pathname.match('/cgi-bin/koha/mainpage.pl')) { $(()=>{ // add new module buttons for pending article/purchase requests let $menu = $('.biglinks-list') diff --git a/admin-js/paycollect.js b/admin-js/paycollect.js index f01e355..410d405 100644 --- a/admin-js/paycollect.js +++ b/admin-js/paycollect.js @@ -1,4 +1,4 @@ -if (path.match('/cgi-bin/koha/members/paycollect.pl')) { +if (location.pathname.match('/cgi-bin/koha/members/paycollect.pl')) { // append payment type to notes field, see https://github.com/cca/koha_snippets/issues/20 // and https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21791 let $note = $('#selected_accts_notes') diff --git a/admin-js/serials-edit.js b/admin-js/serials-edit.js index 2874359..403dbc2 100644 --- a/admin-js/serials-edit.js +++ b/admin-js/serials-edit.js @@ -1,5 +1,5 @@ // serials receive default values & form simplification -if (path.match('/cgi-bin/koha/serials/serials-edit.pl')) { +if (location.pathname.match('/cgi-bin/koha/serials/serials-edit.pl')) { // run on document load $(() => { function fixForm() { diff --git a/admin-js/serials-menu.js b/admin-js/serials-menu.js index 24ff213..567b2a8 100644 --- a/admin-js/serials-menu.js +++ b/admin-js/serials-menu.js @@ -1,6 +1,6 @@ // modify the links listed in the main menu of the Serials module // on all pages beginning with path /cgi-bin/koha/serials/ -if (path.match('/cgi-bin/koha/serials/')) { +if (location.pathname.match('/cgi-bin/koha/serials/')) { // execute once document has loaded $(() => { let menu_list = $('#navmenulist ul').eq(0) diff --git a/catalog-js/_globals.js b/catalog-js/_globals.js deleted file mode 100644 index 0efa753..0000000 --- a/catalog-js/_globals.js +++ /dev/null @@ -1,3 +0,0 @@ -// shortcut vars because we use these in multiple snippets -// this file should end in a semicolon or else ga.js turns into a function call -let path = location.pathname; diff --git a/catalog-js/account.js b/catalog-js/account.js index f5ddc6d..f80ad25 100644 --- a/catalog-js/account.js +++ b/catalog-js/account.js @@ -1,5 +1,5 @@ // show on 1) "charges" tab, and 2) "summary" if there's a secondary "charges" tab -if (path.match('/cgi-bin/koha/opac-account.pl') || (path.match('/cgi-bin/koha/opac-user.pl') && $('#opac-user-fines').length)) { +if (location.pathname.match('/cgi-bin/koha/opac-account.pl') || (location.pathname.match('/cgi-bin/koha/opac-user.pl') && $('#opac-user-fines').length)) { let html = '

Pay fines online

Please allow up to 24 hours for online payments to be processed in your library account.

' // only show on charges tab if the user has fine if (parseFloat($('.sum').eq(1).text())) { diff --git a/catalog-js/article-request.js b/catalog-js/article-request.js index 321501a..95b2533 100644 --- a/catalog-js/article-request.js +++ b/catalog-js/article-request.js @@ -1,4 +1,4 @@ -if (path.match('/cgi-bin/koha/opac-request-article.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-request-article.pl')) { // SF is only valid pickup location for us so hide the pickup library menu, // remove the other options, & ensure SF is selected (it should be) $('#branchcode').parent().hide() diff --git a/catalog-js/comics-plus-cover.js b/catalog-js/comics-plus-cover.js index 10f7f58..abde074 100644 --- a/catalog-js/comics-plus-cover.js +++ b/catalog-js/comics-plus-cover.js @@ -1,5 +1,5 @@ // scrape the book cover image URL from the 856$u field and add it as a Koha cover image -if (path.match('/cgi-bin/koha/opac-detail.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { let hasCover = () => !!$('.cover-image').length const addCPCover = function () { diff --git a/catalog-js/course-reserves.js b/catalog-js/course-reserves.js index f911dd9..54725b6 100644 --- a/catalog-js/course-reserves.js +++ b/catalog-js/course-reserves.js @@ -1,4 +1,4 @@ // treat search filter on Course Reserves like every other form input -if (path.match('/cgi-bin/koha/opac-course-reserves.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-course-reserves.pl')) { $('#course_reserves_table_wrapper input[type=search]').addClass('form-control') } diff --git a/catalog-js/details-actions.js b/catalog-js/details-actions.js index 645e840..79d598d 100644 --- a/catalog-js/details-actions.js +++ b/catalog-js/details-actions.js @@ -1,5 +1,5 @@ // changes to the right-side #action menu of bib detail page -if (path.match('/cgi-bin/koha/opac-detail.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { $(()=>{ // Customizations to the right-side "Actions" menu // remove "print", "suggest for purchase", & "save record" links diff --git a/catalog-js/details.js b/catalog-js/details.js index 9ae3fd5..8a49dd3 100644 --- a/catalog-js/details.js +++ b/catalog-js/details.js @@ -1,5 +1,5 @@ // all our customizations to the bib details display in one place -if (path.match('/cgi-bin/koha/opac-detail.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { // extra commas in 700 "contributor" field display // like MARC of 700 __ ‡a Brundige, James, ‡e director, ‡e editor. // => "Brundige, James [director,, editor.]" diff --git a/catalog-js/holdings-table-filter.js b/catalog-js/holdings-table-filter.js index f67199c..fa4bda3 100644 --- a/catalog-js/holdings-table-filter.js +++ b/catalog-js/holdings-table-filter.js @@ -3,7 +3,7 @@ // ex: https://library.cca.edu/cgi-bin/koha/opac-detail.pl?biblionumber=55280&viewallitems=1 // we're on a details page & there are more than 4 rows of holdings (not counting header row) -if (path === '/cgi-bin/koha/opac-detail.pl' && $('#holdingst tr').length > 5) { +if (location.pathname === '/cgi-bin/koha/opac-detail.pl' && $('#holdingst tr').length > 5) { // Rolling our own search input is easier than trying to destory and rebuild the datatable // to change its config and add one, which has some kind of race condition that can break // the table entirely. diff --git a/catalog-js/holds.js b/catalog-js/holds.js index adf6db0..70afbf6 100644 --- a/catalog-js/holds.js +++ b/catalog-js/holds.js @@ -1,4 +1,4 @@ -if (path.match('/cgi-bin/koha/opac-reserve.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-reserve.pl')) { // changes per Paul's request on 2022-09-07 // https://ccaweb.slack.com/archives/C01V8JTGRD2/p1662570492099079 diff --git a/catalog-js/home-search.js b/catalog-js/home-search.js index 8abd6ce..737297c 100644 --- a/catalog-js/home-search.js +++ b/catalog-js/home-search.js @@ -1,7 +1,7 @@ // better home page column layout, simpler search form // run only on home pg (could be at domain root or its own path) -if (path.match('cgi-bin/koha/opac-main.pl') || path === '/') { +if (location.pathname.match('cgi-bin/koha/opac-main.pl') || path === '/') { // we want no form controls over than text input & search button // we hide most with CSS but the library branch selector has a parent // element with only layout classes so it's easier to remove with JS diff --git a/catalog-js/item-type-icons.js b/catalog-js/item-type-icons.js index bf8b834..e358ed9 100644 --- a/catalog-js/item-type-icons.js +++ b/catalog-js/item-type-icons.js @@ -1,5 +1,5 @@ // use our custom-made icons instead of default theme Koha ones -if (path.match('/cgi-bin/koha/opac-search.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-search.pl')) { let icon_map = { 'book': 'book.svg', 'continuing resource': 'periodical.svg', diff --git a/catalog-js/librarian-chat.js b/catalog-js/librarian-chat.js index 354fa36..b18f1c7 100644 --- a/catalog-js/librarian-chat.js +++ b/catalog-js/librarian-chat.js @@ -11,7 +11,7 @@ let paths = [ '/cgi-bin/koha/opac-messaging.pl', '/cgi-bin/koha/opac-shelves.pl?op=list&category=1' ] -if (paths.some(page => path.match(page))) { +if (paths.some(page => location.pathname.match(page))) { // use libraryh3lp Presence API https://dev.libraryh3lp.com/presence.html fetch('https://libraryh3lp.com/presence/jid/cca-libraries-queue/chat.libraryh3lp.com/text') .then(resp => resp.text()) diff --git a/catalog-js/login-redirects.js b/catalog-js/login-redirects.js index c91febe..ce5e79e 100644 --- a/catalog-js/login-redirects.js +++ b/catalog-js/login-redirects.js @@ -20,7 +20,7 @@ let onLoginScreen = !!$('#opac-login-page').length } // 1) record bib number when we're trying to place a hold but not logged in -if (onLoginScreen && path.match('/cgi-bin/koha/opac-reserve.pl')) { +if (onLoginScreen && location.pathname.match('/cgi-bin/koha/opac-reserve.pl')) { // we always clear storage first in case multiple actions build up // e.g. first they place hold, sign out, request article in same session clearCCAStorage() @@ -28,7 +28,7 @@ if (onLoginScreen && path.match('/cgi-bin/koha/opac-reserve.pl')) { // are listed in one parameter and forward-slash separated sessionStorage.setItem('cca_bib_hold', search.get('biblionumber')) sessionStorage.setItem('cca_bib_holds', search.get('biblionumbers')) -} else if (path.match('/cgi-bin/koha/opac-user.pl') && (sessionStorage.getItem('cca_bib_hold') || sessionStorage.getItem('cca_bib_holds'))) { +} else if (location.pathname.match('/cgi-bin/koha/opac-user.pl') && (sessionStorage.getItem('cca_bib_hold') || sessionStorage.getItem('cca_bib_holds'))) { bib = sessionStorage.getItem('cca_bib_hold') bibs = sessionStorage.getItem('cca_bib_holds') // clear storage then go to appropriate reserve page @@ -47,17 +47,17 @@ if (onLoginScreen && path.match('/cgi-bin/koha/opac-reserve.pl')) { if (onLoginScreen && location.href.match(/\/cgi-bin\/koha\/opac-suggestions.pl\?op=add/)) { clearCCAStorage() sessionStorage.setItem('cca_suggestion', true) -} else if (path.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_suggestion')) { +} else if (location.pathname.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_suggestion')) { // clear storage, go to purchase suggestions form sessionStorage.removeItem('cca_suggestion') location = '/cgi-bin/koha/opac-suggestions.pl?op=add' } // 3) we're trying to make an article request but we're not logged in -if (onLoginScreen && path.match('/cgi-bin/koha/opac-request-article.pl')) { +if (onLoginScreen && location.pathname.match('/cgi-bin/koha/opac-request-article.pl')) { clearCCAStorage() sessionStorage.setItem('cca_article_request', search.get('biblionumber')) -} else if (path.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_article_request')) { +} else if (location.pathname.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_article_request')) { bib = sessionStorage.getItem('cca_article_request') // clear storage, go to appropriate article requests page sessionStorage.removeItem('cca_article_request') @@ -65,20 +65,20 @@ if (onLoginScreen && path.match('/cgi-bin/koha/opac-request-article.pl')) { } // 4) we're trying to access the resticted page -if (onLoginScreen && path.match('/cgi-bin/koha/opac-restrictedpage.pl')) { +if (onLoginScreen && location.pathname.match('/cgi-bin/koha/opac-restrictedpage.pl')) { clearCCAStorage() sessionStorage.setItem('cca_restricted_page', true) -} else if (path.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_restricted_page')) { +} else if (location.pathname.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_restricted_page')) { // clear storage, return to restricted page clearCCAStorage() location = '/cgi-bin/koha/opac-restrictedpage.pl' } // 4) we're trying to report a problem -if (onLoginScreen && path.match('/cgi-bin/koha/opac-reportproblem.pl')) { +if (onLoginScreen && location.pathname.match('/cgi-bin/koha/opac-reportproblem.pl')) { clearCCAStorage() sessionStorage.setItem('cca_report_problem', true) -} else if (path.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_report_problem')) { +} else if (location.pathname.match('/cgi-bin/koha/opac-user.pl') && sessionStorage.getItem('cca_report_problem')) { // clear storage, return to restricted page clearCCAStorage() location = '/cgi-bin/koha/opac-reportproblem.pl' diff --git a/catalog-js/mat-lib.js b/catalog-js/mat-lib.js index 17d9e3d..4217c08 100644 --- a/catalog-js/mat-lib.js +++ b/catalog-js/mat-lib.js @@ -1,5 +1,5 @@ // custom display for Materials Library samples -if (path.match('/cgi-bin/koha/opac-detail.pl') && +if (location.pathname.match('/cgi-bin/koha/opac-detail.pl') && $('td.itype').eq(0).text().trim() === 'Material Sample') { // mat lib labels let newLabel = (selector, label) => { diff --git a/catalog-js/memberentry.js b/catalog-js/memberentry.js index 2f5dde2..d845d96 100644 --- a/catalog-js/memberentry.js +++ b/catalog-js/memberentry.js @@ -1,5 +1,5 @@ // "Your personal details" user account page -if (path.match('/cgi-bin/koha/opac-memberentry.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-memberentry.pl')) { // only allow SF to be home branch $('#borrower_branchcode option[value="SF"]').prop('selected', true) $('#borrower_branchcode').prop('disabled', true) diff --git a/catalog-js/passwd.js b/catalog-js/passwd.js index 5faa05c..0eb4269 100644 --- a/catalog-js/passwd.js +++ b/catalog-js/passwd.js @@ -1,5 +1,5 @@ // "change your password" page, currently only Alumni have access -if (path.match('/cgi-bin/koha/opac-passwd.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-passwd.pl')) { let msg = `
Note that this page only changes your Library Catalog password. Some Alumni may sign in with their CCA password; this page does not reset that password, instead see diff --git a/catalog-js/reserves.js b/catalog-js/reserves.js index b6f20a8..f1f4500 100644 --- a/catalog-js/reserves.js +++ b/catalog-js/reserves.js @@ -1,4 +1,4 @@ -if (path.match('/cgi-bin/koha/opac-course-reserves.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-course-reserves.pl')) { let html = '

Instructors: add to your reserves list by filling out our Course Reserves Request Form.

' $('h1').after(html) } diff --git a/catalog-js/save-to-lists.js b/catalog-js/save-to-lists.js index dec4241..aecd75b 100644 --- a/catalog-js/save-to-lists.js +++ b/catalog-js/save-to-lists.js @@ -22,10 +22,10 @@ function addSaveToListBtn(target, wrapper, large=false) { } if (!loggedIn) { - if (path.match('/cgi-bin/koha/opac-detail.pl')) { + if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { // bib detail page & not logged in, add to right-side Actions menu addSaveToListBtn('#action > li:first-child', 'li', true) - } else if (path.match('/cgi-bin/koha/opac-search.pl')) { + } else if (location.pathname.match('/cgi-bin/koha/opac-search.pl')) { // search results page, add to each "actions" row at bottom of result addSaveToListBtn('.actions-menu span.actions:nth-last-child(2)', 'span class="actions"') } @@ -34,10 +34,10 @@ if (!loggedIn) { // we are logged in _and_ have data but were we on a search or details page? if (sessionStorage.cca_search_url) { // we started on a search page - if (path.match('/cgi-bin/koha/opac-user.pl')) { + if (location.pathname.match('/cgi-bin/koha/opac-user.pl')) { // step 1) user page, so we just signed in, redirect to saved search location = sessionStorage.cca_search_url - } else if (path.match('/cgi-bin/koha/opac-search.pl')) { + } else if (location.pathname.match('/cgi-bin/koha/opac-search.pl')) { // step 2) find bib, click "save to lists" action then clear data $('#title_summary_' + bib).find('.actions [href^="/cgi-bin/koha/opac-addbybiblionumber.pl"]').click() sessionStorage.removeItem('cca_save_to_list') @@ -45,10 +45,10 @@ if (!loggedIn) { } } else { // we start on a details page, simpler process - if (path.match('/cgi-bin/koha/opac-user.pl')) { + if (location.pathname.match('/cgi-bin/koha/opac-user.pl')) { // step 1) user page, so we just signed in, redirect to bib location = '/cgi-bin/koha/opac-detail.pl?biblionumber=' + bib - } else if (path.match('/cgi-bin/koha/opac-detail.pl')) { + } else if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { // step 2) click the "save to lists" link then clear data $(addToShelfAction).click() sessionStorage.removeItem('cca_save_to_list') diff --git a/catalog-js/search.js b/catalog-js/search.js index a8a8d0d..59cf19e 100644 --- a/catalog-js/search.js +++ b/catalog-js/search.js @@ -1,6 +1,6 @@ // on specific searches for the Artists' Books collection, show a link to the // previews in VAULT -if (path.match('/cgi-bin/koha/opac-search.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-search.pl')) { let qs = new URLSearchParams(location.search) let q = qs.get('q') && qs.get('q').toLowerCase() let limit = qs.get('limit') @@ -9,7 +9,7 @@ if (path.match('/cgi-bin/koha/opac-search.pl')) { let abHtml = '
View previews of the Artists\' Books Collection in VAULT (login required).
' if (q && q.match(/artists?'? book/) || limit && limit.match('ARTIST')) { $('#numresults').before(abHtml) - } else if (path.match('opac-shelves.pl') && qs.get('op') == 'view' && qs.get('shelfnumber') == '481') { + } else if (location.pathname.match('opac-shelves.pl') && qs.get('op') == 'view' && qs.get('shelfnumber') == '481') { $('#usershelves').before(abHtml) } diff --git a/catalog-js/serials-solutions-holdings.js b/catalog-js/serials-solutions-holdings.js index a1e883b..b638d7c 100644 --- a/catalog-js/serials-solutions-holdings.js +++ b/catalog-js/serials-solutions-holdings.js @@ -4,7 +4,7 @@ // - African arts (0001-9933) several holdings including print // - ARTMargins (2162-2574) one online holding & print // - Art & artists (0004-3001) has only a print holding -if (path.match('/cgi-bin/koha/opac-detail.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-detail.pl')) { // do we have an ISSN? use 360 Link API to see if we have online holdings let issn = $('.results_summary.issn').find('span[property="issn"]') diff --git a/catalog-js/user.js b/catalog-js/user.js index b2d6557..88d8dff 100644 --- a/catalog-js/user.js +++ b/catalog-js/user.js @@ -1,5 +1,5 @@ // user's "summary" page immediately after logging in -if (path.match('/cgi-bin/koha/opac-user.pl')) { +if (location.pathname.match('/cgi-bin/koha/opac-user.pl')) { // edit (On hold) text in the "Renew" column to indicate a recall & make more prominent $('.renew .renewals:contains("(On hold)")') .css('font-weight', 'bold').text('Item recalled - please return')