Skip to content

Instantly share code, notes, and snippets.

@rococodogs
Forked from rococodogs/trumpy.js
Last active August 29, 2015 13:56
Show Gist options
  • Save rococodogs/9220015 to your computer and use it in GitHub Desktop.
Save rococodogs/9220015 to your computer and use it in GitHub Desktop.
updated version of trumpy, sending serials solution ill request to our new catcher page
// hacky fix to replace the link in "Go to request form" for interlibrary loans
// with a dynamic link to our ILL catcher.
// v. 3, 3/10/14
(function() {
var item = {
"atitle" : document.getElementById("CitationJournalArticleValue")
|| document.getElementById("CitationBookChapterValue") || undefined
, "btitle" : document.getElementById("CitationBookTitleValue") || undefined
// "au" field works for articles AND books
, "author" : document.getElementById("CitationJournalAuthorValue")
|| document.getElementById("CitationBookAuthorValue") || undefined
, "date" : document.getElementById("CitationBookDateValue")
|| document.getElementById("CitationJournalDateValue") || undefined
, "isbn" : document.getElementById("CitationBookISBNValue") || undefined
, "issn" : document.getElementById("CitationJournalIssnValue") || undefined
, "issue" : document.getElementById("CitationJournalIssueValue") || undefined
, "jtitle" : document.getElementById("CitationJournalTitleValue") || undefined
// book chapters only list the start page value
, "pages" : document.getElementById("CitationJournalPageValue")
|| document.getElementById("CitationBookSpageValue") || undefined
, "volume" : document.getElementById("CitationJournalVolumeValue") || undefined
}
, url = "http://trexler.muhlenberg.edu/ill?"
, a = document.getElementsByClassName("AnchorButton") || document.getElementsByTagName("a")
, counter = 0
;
for ( var prop in item ) {
if ( typeof item[prop] !== "undefined" ) {
var res = item[prop].getElementsByClassName("res")[0].innerHTML;
url += "&" + prop + "=" + encodeURI(res);
} else {
counter++;
}
}
// if every field is undefined, leave the ILL link as-is
if ( counter === Object.keys(item).length ) {
return false;
}
for ( var i = 0, count = a.length; i < count; i++ ) {
if ( a[i].href.match(/(library\.muhlenberg\.edu\/ill)/i) ) {
a[i].href = url;
}
}
})()
(function(){var e={atitle:document.getElementById("CitationJournalArticleValue")||document.getElementById("CitationBookChapterValue")||undefined,btitle:document.getElementById("CitationBookTitleValue")||undefined,author:document.getElementById("CitationJournalAuthorValue")||document.getElementById("CitationBookAuthorValue")||undefined,date:document.getElementById("CitationBookDateValue")||document.getElementById("CitationJournalDateValue")||undefined,isbn:document.getElementById("CitationBookISBNValue")||undefined,issn:document.getElementById("CitationJournalIssnValue")||undefined,issue:document.getElementById("CitationJournalIssueValue")||undefined,jtitle:document.getElementById("CitationJournalTitleValue")||undefined,pages:document.getElementById("CitationJournalPageValue")||document.getElementById("CitationBookSpageValue")||undefined,volume:document.getElementById("CitationJournalVolumeValue")||undefined},t="http://trexler.muhlenberg.edu/ill?",n=document.getElementsByClassName("AnchorButton")||document.getElementsByTagName("a"),r=0;for(var i in e){if(typeof e[i]!=="undefined"){var s=e[i].getElementsByClassName("res")[0].innerHTML;t+="&"+i+"="+encodeURI(s)}else{r++}}if(r===Object.keys(e).length){return false}for(var o=0,u=n.length;o<u;o++){if(n[o].href.match(/(library\.muhlenberg\.edu\/ill)/i)){n[o].href=t}}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment