
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 1.27 KB | hits: 14 | expires: Never
var buttons = {
login: new Button({
label: 'Login to Google',
action: function() {
google.accounts.user.login('https://www.google.com/m8/feeds');
}
}),
logout: new Button({
label: 'Logout from Google',
action: function() {
google.accounts.user.logout();
}
}),
getContacts: new Button({
label: 'Get contacts',
action: function() {
var contactsService = new google.gdata.contacts.ContactsService( 'Contacts Viewer' ),
query = new google.gdata.contacts.ContactQuery( 'https://www.google.com/m8/feeds/contacts/default/full' );
query.setMaxResults( $('#numContacts').val() );
contactsService.getContactFeed(
query,
function( result ) {
$('#contacts').remove();
var $contactsHolder = $('<ul>', {
id: 'contacts'
});
$.each( result.feed.entry, function( i, entry ){
$.each( entry.getEmailAddresses(), function( j, address ){
$contactsHolder.append( '<li>' + address.address + '</li>' );
});
});
$contactsHolder.appendTo( 'body');
},
function( result ) {
// Log the error
console.log('error: ', result);
}
);
}
})
};