Last active
December 21, 2015 04:59
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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