Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 1.27 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var buttons = {
  2.   login: new Button({
  3.     label: 'Login to Google',
  4.     action: function() {
  5.       google.accounts.user.login('https://www.google.com/m8/feeds');
  6.     }
  7.   }),
  8.   logout: new Button({
  9.     label: 'Logout from Google',
  10.     action: function() {
  11.       google.accounts.user.logout();          
  12.     }
  13.   }),
  14.   getContacts: new Button({
  15.     label: 'Get contacts',
  16.     action: function() {
  17.       var contactsService = new google.gdata.contacts.ContactsService( 'Contacts Viewer' ),
  18.       query = new google.gdata.contacts.ContactQuery( 'https://www.google.com/m8/feeds/contacts/default/full' );
  19.       query.setMaxResults( $('#numContacts').val() );
  20.       contactsService.getContactFeed(
  21.         query,
  22.         function( result ) {
  23.           $('#contacts').remove();
  24.           var $contactsHolder = $('<ul>', {
  25.             id: 'contacts'
  26.           });
  27.           $.each( result.feed.entry, function( i, entry ){
  28.             $.each( entry.getEmailAddresses(), function( j, address ){
  29.               $contactsHolder.append( '<li>' + address.address + '</li>' );
  30.             });                  
  31.           });
  32.           $contactsHolder.appendTo( 'body');
  33.         },
  34.         function( result ) {
  35.           // Log the error
  36.           console.log('error: ', result);
  37.         }
  38.       );
  39.     }
  40.   })
  41. };