Created
February 15, 2012 20:52
-
-
Save kaimallea/1838923 to your computer and use it in GitHub Desktop.
Khan Academy API JS Wrapper
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
var khan = (function (document) { | |
var _head = document.getElementsByTagName('head')[0], | |
_reusable_script_ele = document.createElement('script'), | |
_default_host = 'http://www.khanacademy.org/api/v1/'; | |
var _jsonp = function (url) { | |
var script = _reusable_script_ele.cloneNode(false); | |
script.src = url; | |
_head.appendChild(script); | |
}; | |
var _api = function (endpoint, callback) { | |
var url = _default_host + endpoint.replace(/^\/+/, '') + '?callback=khan.callback'; | |
_callback = callback; | |
_jsonp(url); | |
}; | |
return { | |
api: _api, | |
callback: function (res) { | |
_callback(res); | |
} | |
}; | |
}(document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment