Last active
December 18, 2015 08:18
-
-
Save aaroncox/5752567 to your computer and use it in GitHub Desktop.
Synchronous Build Requests
This file contains hidden or 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
<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> |
This file contains hidden or 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
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