Skip to content

Instantly share code, notes, and snippets.

@gbinal
Last active December 16, 2015 13:59
Show Gist options
  • Save gbinal/5445448 to your computer and use it in GitHub Desktop.
Save gbinal/5445448 to your computer and use it in GitHub Desktop.
Sample code for embedding an agency list of accounts into 3rd party sites. Registry.USA.gov
<div id="content">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var services = ['Facebook', 'Twitter']
for (var j = 0; j < services.length; j += 1) {
var service = services[j];
$("#content").append("<h2>" + service + "</h2><ul id=\"" + service.toLowerCase() + "\"></ul>");
var url = "http://registry.usa.gov/accounts.json?service_id=" + service.toLowerCase() +"&agency_id=epa";
$.get(url, function (data) {
for (var i = 0; i < data.accounts.length; i += 1) {
var account = data.accounts[i]
$("#" + account.service_id).append('<li><a href="' + account.details_url +'">' + account.account + '</a></li>')
}
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment