Skip to content

Instantly share code, notes, and snippets.

@andrewbranch
Last active December 21, 2015 04:59
Show Gist options
  • Save andrewbranch/6253522 to your computer and use it in GitHub Desktop.
Save andrewbranch/6253522 to your computer and use it in GitHub Desktop.
Gets an array of Auburn building names from the web API. Works from auburn.edu domain and subdomains.
var auburnBuildingNames;
window.getAuburnBuildingNames = function(callback) {
if (auburnBuildingNames) {
callback(auburnBuildingNames);
} else {
var buildings;
$.getJSON("https://cws.auburn.edu/map/api/3.0/building", function(data) {
buildings = $.map(data, function(building, i) {
return building.name;
});
callback(auburnBuildingNames = buildings);
});
}
};
// Usage example with Bootstrap Typeahead
$(document).ready(function() {
getAuburnBuildingNames(function(data) {
$("[name*=Building]").typeahead({
source: data
});
});
});
var auburnCalendarEvents;
window.getAuburnCalendarEvents = function(callback) {
if (auburnCalendarEvents) {
callback(auburnCalendarEvents);
} else {
var events;
$.getJSON("https://cws.auburn.edu/mobile/api/3.2/feed/academiccalendar", function(data) {
buildings = $.map(data, function(event, i) {
return event.name;
});
callback(auburnCalendarEvents = events);
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment