Permalink
Browse files

Correctly set the id number of an item selected in the sidebar (#1641)

  • Loading branch information...
fbennett authored and dstillman committed Apr 27, 2018
1 parent beb41ff commit fbbef8992f3f633520b12e15e3b46d87be23e322
Showing with 16 additions and 9 deletions.
  1. +16 −9 HeinOnline.js
View
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsbv",
"lastUpdated": "2016-08-10 09:29:21"
"lastUpdated": "2018-04-27 02:53:31"
}
/*
@@ -103,15 +103,22 @@ function translateCOinS(COinS) {
// Build URL for RIS, and for PDF if available
function scrapePage(doc, url) {
var risPopupURL = getXPathStr("href", doc, '//form[@id="pagepicker"]//a[contains(@href, "PrintRequest")][1]');
if (risPopupURL) {
// If page has RIS, use that
var docParams = extractQueryValues(risPopupURL);
// We need the id= and the handle= of the current target item.
// From that, we can build URL for RIS.
// Check for an RIS popup link in the page.
var risPopupLink = getXPathStr("href", doc, '//form[@id="pagepicker"]//a[contains(@href, "PrintRequest")][1]');
if (risPopupLink) {
// Get the id from pageSelect.
var pageID = doc.getElementById("pageSelect").value;
// Get other parameters from the page URL.
var docParams = extractQueryValues(url);
// Compose the RIS link.
var risURL = docParams.base
+ "CitationFile?handle=" + docParams.handle
+ "&div=" + docParams.div
+ "&id=" + docParams.id
+ "CitationFile?kind=ris&handle=" + docParams.handle
+ "&id=" + pageID
+ "&base=js";
// updatediv apparently gives us a page that will refresh itself to the PDF.
var pdfPageURLs = doc.getElementsByClassName("updatediv");
ZU.doGet(risURL, function(ris) {
if (pdfPageURLs) {
@@ -176,7 +183,7 @@ function doWeb (doc,url) {
ZU.processDocuments(urls, scrapePage);
});
} else {
scrapePage(doc);
scrapePage(doc, url);
}
}

0 comments on commit fbbef89

Please sign in to comment.