var bookapi = { $dialog: null, resulttpl: '
' + ' '+ '
' + '
' + '
' + ' ' + '
' + '

' + '

' + '

' + '

' + ' ' + ' ' + ' ' + '

' + '
' + '
', init: function(){ $('body').append('
'); bookapi.$dialog = $('#bookapi'); bookapi.$dialog.dialog( { autoOpen: false, title: 'Lookup Book Data', width: 800, height: 500 } ); bookapi.$dialog.append('
Lookup:
') .append('
'); bookapi.$out = $('#bookapi-out'); $('#bookpanel').append('Lookup Book Data'); $('#bookapi-s').attr('title','Search this book at Google Books'); $('#bookapi-s').click(bookapi.open); $('#bookapi-q').keypress( function(event){ if(event.which == 13){ event.preventDefault(); bookapi.search(); } }); }, open: function(){ bookapi.$dialog.dialog('open'); var query = $('#bookpanel input[name=title]').val(); $('#bookapi-q').val(query); bookapi.search(); }, search: function(){ bookapi.$out.html('please wait...'); $.ajax({ type: 'GET', data: {'api':$('#bookapi-q').val()}, success: bookapi.searchdone, dataType: 'json' }); }, searchdone: function(data){ if(data.totalItems == 0){ bookapi.$out.html('Found no results.
Try adjusting the query and retry.'); return; } bookapi.$out.html(''); for(i=0; i"], ["Header 1", "

"], ["Header 2", "

"], ["Header 3", "

"], ["Header 4","

"], ["Header 5","

"]] }); });