This is a snippet from the Facebook Developers site.
<div id="info"></div>
<script>
var
info = document.getElementById('info'),
update = function(response) {
if (!response.session) {
info.innerHTML = '<em>You must login using the controls at the top.</em>';
return;
}
FB.api(
{
method: 'fql.query',
query: 'SELECT name, pic_square FROM user WHERE uid=' + response.session.uid
},
function(response) {
info.innerHTML = (
'<img src="' + response[0].pic_square + '"> ' +
response[0].name
);
}
);
};
// update on login, logout, and once on page load
FB.Event.subscribe('auth.login', update);
FB.Event.subscribe('auth.logout', update);
FB.getLoginStatus(update);
</script>
Above, can you please tell me what is the update variable, its type and how works, where does the assignment ends and who calls this function?
Secondly, what's the first argument to the FB.api call? What type of object is it? And I believe the second one is a callback function right?