Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created March 17, 2016 16:38
Show Gist options
  • Save michaelschofield/d826c94f72858145f12c to your computer and use it in GitHub Desktop.
Save michaelschofield/d826c94f72858145f12c to your computer and use it in GitHub Desktop.
function addStatus() {
if( $('.itemSelect').length == 0 && $('pre').length == 0) {
$('.bibItemsEntry td:last-child').append('<a href="#" onclick="return false;" onmouseover="statustip(this); return false;"><i class="fa fa-question-circle"></i></a>');
}
}
function statustip(statuslink) {
if(statuslink.id != "set") {
statuslink.id = "current";
var hold_flag = 0;
var isbn = "";
// get status text
var td = statuslink.parentNode;
var status_text = td.innerHTML;
status_text = jQuery(status_text).text();
status_text = status_text.trim();
// check for "+ [X] HOLD(S)/RECALL(S}"
var plus = status_text.indexOf("+");
if(plus != -1) {
hold_flag = 1;
status_text = status_text.substring(0, plus-1);
}
// get briefcitActions div and briefcitRequest div for this item
var div = jQuery(td).closest('div');
var parent_div = div[0].parentNode;
var main_div = parent_div.previousElementSibling;
var main_div_children = main_div.childNodes;
for(i = 0; i < main_div_children.length; i++) {
if(main_div_children[i].className == "briefcitActions") {
var actions_div = main_div_children[i];
}
else if(main_div_children[i].className == "briefcitRequest") {
var request_div = main_div_children[i];
}
}
// get resource link and ISBN and create BorrowItNow link for briefcit
if(actions_div) {
var resource_link = actions_div.firstElementChild.href;
var resource_text = actions_div.firstElementChild.innerHTML;
var isbn_text = actions_div.childNodes[3].innerHTML;
isbn = isbn_text.replace(/[^0-9]/g, '');
var bin_url = "http://gwla.relaisd2d.com/service-proxy/?command=mkauth&LS=ARIZONASTATE&PI=ARIZONASTATE";
if(isbn != "") {
bin_url += "&query=isbn%3D" + isbn;
}
}
// get resource link and BorrowItNow link for bib_display
else {
var resource_link = "";
var resource_text = "";
// if there's a BorrowItNow link, grab it
if(document.getElementById('gwlalink')) {
var bin_url = document.getElementById('gwlalink').href;
}
// if not, use generic BorrowItNow link
else {
var bin_url = "http://gwla.relaisd2d.com/service-proxy/?command=mkauth&LS=ARIZONASTATE&PI=ARIZONASTATE";
}
// if there's a resource link, grab it
if(document.getElementById('bib_links')) {
var links = document.getElementById('bib_links').getElementsByTagName('A');
if(links[0]) {
resource_link = links[0].href;
resource_text = links[0].innerHTML;
}
}
}
// get Request link for briefcit
if(request_div) {
if(request_div.firstElementChild != null) {
var req_url = request_div.firstElementChild.href;
}
}
// get Request link for bib_display
else if(document.getElementById('requestButton')) {
var req_url = document.getElementById('requestButton').parentElement.href;
}
statuslink.className = "statustip";
if(status_text == "SHELF") {
content = "This copy is not checked out and should be on the shelf indicated by the call number and location.";
}
else if(status_text == "AT BINDERY") {
content = "This copy is out for binding repair. Use the <a href='" + req_url +"'>Request</a> link to place a hold on this copy or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "BILLED") {
content = "This copy has been billed and is not requestable. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "BOOKING HOLD") {
content = "This copy is currently on hold for a media booking. Use the <a href='" + req_url +"'>Request</a> link to be added to the queue or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "DAMAGED/PAID") {
content = "This copy is damaged and is not requestable. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text.substr(0,3) == "DUE") {
content = "This copy is checked out. Use the ";
if(req_url){
content += "<a href='" + req_url +"'>Request</a> link to recall this copy or use the ";
}
content += "<a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "IN TRANSIT") {
content = "This copy is in transit to the owning branch or the requested pick up location and should arrive in 1 to 2 business days. Use the <a href='" + req_url +"'>Request</a> link to place a hold on it.";
}
else if(status_text == "LIB USE ONLY") {
content = "This copy does not circulate (check out). It may be used within the library.";
}
else if(status_text == "LOST AND PAID") {
content = "This copy has been billed and paid for and is not requestable. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "MENDING") {
content = "This copy is currently out for repairs. Use the <a href='" + req_url +"'>Request</a> link to place a hold on this copy or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "MISSING" || status_text == "MISSING (T)") {
content = "This copy is missing and is not requestable. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "MUSIC WORKROOM") {
content = "This copy is being bound and labelled. Use the <a href='" + req_url +"'>Request</a> link to place a hold.";
}
else if(status_text == "NEW IN TRANSIT") {
content = "This copy is new to the collection. Check the shelf location or use the <a href='" + req_url +"'>Request</a> link to place a hold.";
}
else if(status_text == "ON EXHIBIT") {
content = "This copy is part of an exhibit/display and is not requestable. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "ON HOLD") {
content = "A user has requested this copy. Use the <a href='" + req_url +"'>Request</a> link to be added to the queue or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "ON SEARCH") {
content = "This copy could not be found on the shelf and is being searched for. Use the <a href='" + req_url +"'>Request</a> link to be added to the queue or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "ONLINE ACCESS") {
content = "This item is available online and can be viewed using the <a href='" + resource_link + "'>link provided</a>.";
}
else if(status_text == "OUT FOR REPAIR") {
content = "This copy is currently out for repairs. Use the <a href='" + req_url +"'>Request</a> link to place a hold on this copy or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a>�service to request another copy through interlibrary loan.";
}
else if(status_text == "PROC DMG BOOKS") {
content = "This copy was damaged and is being repaired. Use the <a href='" + req_url +"'>Request</a> link to place a hold on this copy or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "UNAVAILABLE") {
content = "This copy is currently not available. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "WITHDRAWN") {
content = "This copy has been removed from the collection. Use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else if(status_text == "Questions? Ask Staff.") {
if(resource_text != "") {
if(resource_text.substring(0, 17) == "Request this book" || resource_text.substring(0, 19) == "Request the Library") {
content = "<a href='" + resource_link + "'>Click the link</a> to request that the ASU Libraries purchase this item for the collection.";
}
else {
content = "This item is available online and can be viewed using the <a href='" + resource_link + "'>link provided</a>.";
}
}
else {
content = "<a href='https://lib.asu.edu/libraries'>Contact library staff</a> for information about this item.";
}
}
else if(status_text.indexOf("HOLD")) {
content = "A user has requested this copy. Use the <a href='" + req_url +"'>Request</a> link to be added to the queue or use the <a href='" + bin_url + "' target='_blank'>BorrowItNow</a> service to request another copy through interlibrary loan.";
}
else {
content = "<a href='https://lib.asu.edu/libraries'>Contact library staff</a> for information about this item.";
}
if(window.innerWidth > 1180) {
pos = "right";
}
else {
pos = "left";
}
$('#current').tooltipster({interactive: true, minWidth: 150, maxWidth: 350, position: pos, contentAsHTML: true, content: content});
}
$('#current').tooltipster('show');
statuslink.id = "set";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment