-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhours.html
More file actions
80 lines (75 loc) · 5.15 KB
/
hours.html
File metadata and controls
80 lines (75 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="col-md-6">
<h3>Albany Campus Library</h3>
<a class="btn" href="http://library.linnbenton.edu/hours#albany" id="albany-hours" style="white-space: normal;margin-bottom:8px;"><span aria-hidden="true" class="fa fa-university"></span> Albany Campus Library</a>
<ul><li>Monday-Thursday 7:30am-9pm</li>
<li>Friday 7:30am-5pm</li>
<li>Saturday-Sunday 11am-4pm</li></ul>
</div>
<div class="col-md-6">
<h3>Healthcare Occupations Center Library</h3>
<a class="btn" href="http://library.linnbenton.edu/hours#hoc" id="hoc-hours" style="white-space: normal;margin-bottom:8px;"><span aria-hidden="true" class="fa fa-stethoscope"></span> Healthcare Occupations Center Library</a>
<ul><li>Monday-Friday 7:30am-4:30pm</li></ul>
</div>
<script type="text/javascript">
function apiUrl(calendarId, apiKey) {
timeMin = new Date().toISOString();
return "https://www.googleapis.com/calendar/v3/calendars/" + calendarId + "/events?key=" + apiKey + "&singleEvents=true&orderBy=startTime&timeMin=" + timeMin;
}
function sendHoursToBrowser(elementId) {
return function(response) {
var events = response.items;
for (var i = 0; i < events.length; i += 1) {
if(events[i].end.hasOwnProperty('dateTime')) {
var start = new Date(events[i].start.dateTime);
var end = new Date(events[i].end.dateTime);
var now = new Date();
if ((end.toDateString() == now.toDateString()) && (now < end)) { // If the day matches and event isn't over
if ('library open' == events[i].summary.toLowerCase()) {
if (start.getHours() < 12) {
var oTimeCiv = start.getHours() + ':' + (start.getMinutes()<10?'0':'') + start.getMinutes() + 'am';
} else {
var oTimeCiv = (start.getHours() == 12 ? 12 : (start.getHours() % 12)) + ':' + (start.getMinutes()<10?'0':'') + start.getMinutes() + 'pm';
}
if (end.getHours() < 12) {
var cTimeCiv = end.getHours() + ':' + (end.getMinutes()<10?'0':'') + end.getMinutes() + 'am';
} else {
var cTimeCiv = (end.getHours() == 12 ? 12 : (end.getHours() % 12)) + ':' + (end.getMinutes()<10?'0':'') + end.getMinutes() + 'pm';
}
if (start > now) { // the event hasn't started yet
var t = document.createTextNode(" opens today at " + oTimeCiv); // Create a text node
$(elementId).addClass("btn-warning");
$(elementId).append(t); // Append the text to <button>
return 0
} else {
var t = document.createTextNode(" open today " + oTimeCiv + '-' + cTimeCiv); // Create a text node
$(elementId).addClass("btn-success");
$(elementId).append(t); // Append the text to <button>
return 0
}
}
}
}
}
var t = document.createTextNode(' currently closed; see library hours');
$(elementId).addClass("btn-warning");
$(elementId).append(t);
return 0;
}
}
$( document ).ready(function() {
apiKey = "AIzaSyDXVbhmf9MdPsUN5osl3tYZcCwbnus0Y4Y";
$.getJSON(apiUrl('linnbenton.edu_kncbp9oce0ardu7idrt38inl3c@group.calendar.google.com', apiKey), sendHoursToBrowser('#hoc-hours'));
$.getJSON(apiUrl('linnbenton.edu_un13554vos71aein8m7j285u4c@group.calendar.google.com', apiKey), sendHoursToBrowser('#albany-hours'));
});
/* ]]> */
</script>
</body>
</html>