Skip to content

Instantly share code, notes, and snippets.

@aaroncox
Last active December 18, 2015 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaroncox/5752567 to your computer and use it in GitHub Desktop.
Save aaroncox/5752567 to your computer and use it in GitHub Desktop.
Synchronous Build Requests
<html>
<head></head>
<body>
<!-- ... (The rest of the page page) ... -->
<script type="text/javascript" charset="utf-8">
$(function() {
d3up.getBuild(1);
d3up.getBuild(2);
console.log(d3up.builds);
});
</script>
</body>
</html>
window.d3up = (function() {
return {
builds: {
},
addBuild: function(build, name) {
if(!name) {
name = build.id;
}
data = new d3up.Calc(build);
d3up.builds[name] = data;
},
getBuild: function(id) {
return d3up.builds[id] || (d3up.builds[id] = $.ajax({
url: 'http://phalcon.d3up.com/builds/' + id + '.json',
dataType: 'jsonp'
}).done(function(buildData) {
d3up.builds[id] = new d3up.Calc(buildData);
}));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment