Skip to content

Instantly share code, notes, and snippets.

@mreidsma
Created May 24, 2016 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreidsma/26b931cce2be7adeb3586721b4e19227 to your computer and use it in GitHub Desktop.
Save mreidsma/26b931cce2be7adeb3586721b4e19227 to your computer and use it in GitHub Desktop.
Availability Code Demo for Infopeople Course
<!DOCTYPE html>
<html lang="en">
<head>
<style>
span { display: inline-block; margin-left: 1em; }
.holdings { padding: .5em 1em; }
.avail_yes { background-color:green; color: white; }
.avail_no { background-color: red; color: white; }
</style>
</head>
<body>
<div class="holdings-table">
<table class="bib_items" border="1">
<tbody>
<tr class="bibItemsHeader">
<th width="38%" class="bibItemsHeader">
Location
</th>
<th width="38%" class="bibItemsHeader">
Call No.
</th>
<th width="24%" class="bibItemsHeader">
Status
</th>
</tr>
<tr class="bibItemsEntry">
<td width="38%">Mary Idema Pew - 3rd Floor</td>
<td width="38%">PS3562.E353 G6 2015</td>
<td width="24%">DUE 09-17-15 +2 HOLDS</td>
</tr>
</tbody>
</table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
var itemLocation = $('table.bib_items').find('tr.bibItemsEntry').find('td:first').text();
var callNo = $('table.bib_items').find('tr.bibItemsEntry').find('td:nth-child(2)').text();
var availability = $('table.bib_items').find('tr.bibItemsEntry').find('td:last').text();
$('.holdings-table').html('<ul class="holdings-list"><li><span class="holdings">' + availability + '</span><span class="location">' + itemLocation + '</span><span class="callno">' + callNo + '</span></li></ul>');
$('.holdings:contains("DUE")').addClass('avail_no');
$('.holdings:contains("AVAILABLE")').addClass('avail_yes');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment