Home / Cataloging and Metadata Services / UW Libraries Open Metadata Guidelines / Java Bookmarklet for Viewing MARC or PNX Records

Java Bookmarklet for Viewing MARC or PNX Records

Directions for creating a Java bookmarklet for viewing the MARC or PNX for University of Washington Libraries catalog records.
Create a New Browser Bookmark
The Java bookmarklet below is a short JavaScript program that can be run from the address bar of browsers that will create options on a page for viewing the MARC record or PNX (Primo Normalized XML) record for a Primo record.
In your browser, create a new bookmark containing the Java bookmarklet text below. Copy and paste all of the text exactly as it appears below into the URL of the bookmark:
javascript:(function() { var showPnxLinkElem = document.querySelectorAll('prm-brief-result-container'), urlParamVid = location.search.split('vid=')[1].split('&')[0], urlLocation = location.href; function createLink (linkUrl, linkText) { var obj = document.createElement("a"); obj.setAttribute("href", linkUrl); obj.setAttribute("target", "_blank"); obj.style.margin = "0 0 0 2em"; obj.innerHTML = linkText; return obj; } for (var i=0, j=showPnxLinkElem.length; i < j; i++) { var showPnxRecId = showPnxLinkElem[i].querySelector('.list-item-primary-content').getAttribute('data-recordid'), resultItemChildren = showPnxLinkElem[i].parentNode.childNodes, resultItemLastChild = resultItemChildren[resultItemChildren.length-1], recordIdSpan = document.createElement("span"), hrefBase = showPnxLinkElem[i].querySelector('.media-thumbnail').querySelector('a').getAttribute('ng-href').replace(/docid=.*?(&|$)/, "docid="+showPnxRecId+"$1"), showSourceLinkHref = hrefBase.replace(/fulldisplay/, "sourceRecord").replace(/docid=/, "docId="), showSourceLink = createLink (showSourceLinkHref, "Show Source Record"), showRISLinkHref = "../primo_library/libweb/action/display.do?doc="+showPnxRecId+"&vid="+urlParamVid+"&showRIS=true", showRISLink = createLink (showRISLinkHref, "Show RIS"), showCDILinkHref = location.href+"&searchCDI=true", showCDILink = createLink (showCDILinkHref, "Search CDI"); /* Service Pages via old UI for the time being */ if (/openurl/.test(location) === true) { var templocation = location.href; showPnxLinkHref = templocation.replace(/primo-explore/, "primo_library/libweb/action")+"&showPnx=true"; } else { /* Make use of new urlToXmlPnx */ showPnxLinkHref = showPnxLinkElem[i].querySelector('.urlToXmlPnx').getAttribute('data-url'); } var showPnxLink = createLink (showPnxLinkHref, "Show PNX (XML)") ,showCDILink = createLink (showCDILinkHref, "Search CDI"); recordIdSpan.className = "show-recordid"; recordIdSpan.innerHTML = showPnxRecId; recordIdSpan.style.padding = "2em 0 0 0"; if (/openurl/.test(hrefBase) !== true ) { recordIdSpan.appendChild(showPnxLink), recordIdSpan.appendChild(showCDILink); } /* No Source-links for Third Node (PCI, EBSCO etc.) records */ if (/context=L/.test(hrefBase) === true) { recordIdSpan.appendChild(showSourceLink); /* No RIS-links for PrimoVE (no old UI to link to) */ if (/\/discovery\//.test(hrefBase) === false) { recordIdSpan.appendChild(showRISLink); } } /* Append recordid and links only once */ if (resultItemLastChild.className !== 'show-recordid') { /* Prepend FRBR records with note */ if (showPnxLinkElem[i].querySelector('prm-search-result-frbr-line')) { var prefix = document.createElement("strong"); prefix.innerHTML = 'FRBR preferred/generic record:'; showPnxLinkElem[i].appendChild(prefix); var linebreak = document.createElement("br"); showPnxLinkElem[i].appendChild(linebreak); } showPnxLinkElem[i].parentNode.appendChild(recordIdSpan); } }})();
View MARC or PNX for a Primo Record
Search for a record in Primo.
On the search page for your search, click on the bookmark you created above.
The page will reload with clickable links to Show PNX (XML), Search CDI, Show Source Record, and Show RIS.
Click Show Source Record to display the MARC in a new browser window.
Click Show PNX (XML) to display the PNX for the record in a new browser window.

Create a New Browser Bookmark

The Java bookmarklet below is a short JavaScript program that can be run from the address bar of browsers that will create options on a page for viewing the MARC record or PNX (Primo Normalized XML) record for resources in the UW Libraries catalog.

  • In your browser, create a new bookmark containing the Java bookmarklet text below. Copy and paste all of the text exactly as it appears below into the URL of the bookmark:

javascript:(function() { var showPnxLinkElem = document.querySelectorAll('prm-brief-result-container'), urlParamVid = location.search.split('vid=')[1].split('&')[0], urlLocation = location.href; function createLink (linkUrl, linkText) { var obj = document.createElement("a"); obj.setAttribute("href", linkUrl); obj.setAttribute("target", "_blank"); obj.style.margin = "0 0 0 2em"; obj.innerHTML = linkText; return obj; } for (var i=0, j=showPnxLinkElem.length; i < j; i++) { var showPnxRecId = showPnxLinkElem[i].querySelector('.list-item-primary-content').getAttribute('data-recordid'), resultItemChildren = showPnxLinkElem[i].parentNode.childNodes, resultItemLastChild = resultItemChildren[resultItemChildren.length-1], recordIdSpan = document.createElement("span"), hrefBase = showPnxLinkElem[i].querySelector('.media-thumbnail').querySelector('a').getAttribute('ng-href').replace(/docid=.*?(&|$)/, "docid="+showPnxRecId+"$1"), showSourceLinkHref = hrefBase.replace(/fulldisplay/, "sourceRecord").replace(/docid=/, "docId="), showSourceLink = createLink (showSourceLinkHref, "Show Source Record"), showRISLinkHref = "../primo_library/libweb/action/display.do?doc="+showPnxRecId+"&vid="+urlParamVid+"&showRIS=true", showRISLink = createLink (showRISLinkHref, "Show RIS"), showCDILinkHref = location.href+"&searchCDI=true", showCDILink = createLink (showCDILinkHref, "Search CDI"); /* Service Pages via old UI for the time being */ if (/openurl/.test(location) === true) { var templocation = location.href; showPnxLinkHref = templocation.replace(/primo-explore/, "primo_library/libweb/action")+"&showPnx=true"; } else { /* Make use of new urlToXmlPnx */ showPnxLinkHref = showPnxLinkElem[i].querySelector('.urlToXmlPnx').getAttribute('data-url'); } var showPnxLink = createLink (showPnxLinkHref, "Show PNX (XML)") ,showCDILink = createLink (showCDILinkHref, "Search CDI"); recordIdSpan.className = "show-recordid"; recordIdSpan.innerHTML = showPnxRecId; recordIdSpan.style.padding = "2em 0 0 0"; if (/openurl/.test(hrefBase) !== true ) { recordIdSpan.appendChild(showPnxLink), recordIdSpan.appendChild(showCDILink); } /* No Source-links for Third Node (PCI, EBSCO etc.) records */ if (/context=L/.test(hrefBase) === true) { recordIdSpan.appendChild(showSourceLink); /* No RIS-links for PrimoVE (no old UI to link to) */ if (/\/discovery\//.test(hrefBase) === false) { recordIdSpan.appendChild(showRISLink); } } /* Append recordid and links only once */ if (resultItemLastChild.className !== 'show-recordid') { /* Prepend FRBR records with note */ if (showPnxLinkElem[i].querySelector('prm-search-result-frbr-line')) { var prefix = document.createElement("strong"); prefix.innerHTML = 'FRBR preferred/generic record:'; showPnxLinkElem[i].appendChild(prefix); var linebreak = document.createElement("br"); showPnxLinkElem[i].appendChild(linebreak); } showPnxLinkElem[i].parentNode.appendChild(recordIdSpan); } }})();

View MARC or PNX for a UW Libraries Record

  • Search for a record in UW Libraries Search.
  • On the search page for your search (not the individual page for a resource/record), click on the bookmark you created above.
  • The page will reload with clickable links to Show PNX (XML), Search CDI, Show Source Record, and Show RIS.
  • Click Show Source Record to display the MARC in a new browser window. If the Show Source Record link is not available for a resource, there is not a corresponding MARC record for the resource (metadata comes from a variety of different sources, not all of which are MARC records).
  • Click Show PNX (XML) to display the PNX for the record in a new browser window.