Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rickhernandezio/54d9a6a09fd3cf431873461efae4504b to your computer and use it in GitHub Desktop.
Save rickhernandezio/54d9a6a09fd3cf431873461efae4504b to your computer and use it in GitHub Desktop.
Raw HTML
<div class="region region-content">
<section id="block-system-main" class="block block-system block-style-frameless clearfix">
<article id="node-23856" class="node node-page clearfix">
<!-- field-->
<div class="field field-name-body field-type-text-with-summary field-label-hidden">
<div class="field-items" id="append-items">
<div class="field-item even">
<p style="text-align: center; line-height: 20px; font-size: 13px;">Enjoy a Free Day at NHMU made possible by funding through the Salt Lake County Zoo, Arts, and Parks
fund. Reserve your tickets below!</p>
<p style="text-align: center; line-height: 20px; font-size: 13px;"></p>
<div class="media media-element-container media-media_original" style="display: inline-block;">
<div id="file-15799" class="file file-image file-image-jpeg">
<h2 class="element-invisible"><a href="/file/15799">1.jpeg</a></h2>
<div class="content">
<img height="197" width="480" class="media-image media-element file-media-original" data-delta="1" src="https://nhmu.utah.edu/sites/default/files/1.jpeg"
alt="" title=""> </div>
</div>
</div>
<p></p>
<hr style="line-height: 20px; font-size: 13px;">
<p style="text-align: center; line-height: 20px; font-size: 13px;"><strong style="line-height: 20px; font-size: 13px;">NHMU Free day hours 10:00AM - 5:00PM</strong></p>
<p style="text-align: center; line-height: 20px; font-size: 13px;"><strong style="line-height: 20px; font-size: 13px;">Last&nbsp;admission is at 4:00PM&nbsp;</strong></p>
</div>
</div>
</div>
<footer>
</footer>
</article>
</section>
</div>
<script>
jQuery(document).ready(function () {
var $ = jQuery;
var freeDay = getFreeDay();
if (freeDay) {
$('<iframe id="sales" src="https://sales.nhmu.utah.edu/itemList.aspx?d=' + freeDay +
'" frameborder="0" style="min-height: 750px" width="100%" frameborder="0" ></iframe>').appendTo(
'#append-items');
} else {
// Show message to add more dates to array
$(
'<div class="alert alert-block alert-warning"><a class="close" data-dismiss="alert" href="#">×</a>There are no free dates available.</div>'
).appendTo('#append-items');
}
// Returns the next free day in this format (YYY-m-d)
function getFreeDay() {
var dates = ['2016/08/22', '2016/10/10', '2016/12/12', '2017/01/23', '2017/05/15', '2017/08/21',
'2017/12/11'
]; // ADD MORE FREE DAYS HERE! FORMAT YYYY/mm/dd
var today = new Date();
for (var i = 0; i < dates.length; i++) {
var split = dates[i].split('/');
if (split.length == 3) {
// Year, Month - 1, Day
var day = new Date(parseInt(split[0]), parseInt(split[1]) - 1, parseInt(split[2])); // Work around for android devices
if (today.getTime() <= day.getTime()) {
return day.getFullYear() + '-' + (day.getMonth() + 1) + '-' + day.getDate();
}
}
}
return undefined;
}
// Remove buy-tickets buttons
var element = document.getElementById("buy-tickets");
element.parentNode.removeChild(element);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment