-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Added sample: javascript/search.js"
- Loading branch information
1 parent
e9ae998
commit 7b1e273
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// After the API loads, call a function to enable the search box. | ||
function handleAPILoaded() { | ||
$('#search-button').attr('disabled', false); | ||
} | ||
|
||
// Search for a specified string. | ||
function search() { | ||
var q = $('#query').val(); | ||
var request = gapi.client.youtube.search.list({ | ||
q: q, | ||
part: 'snippet' | ||
}); | ||
|
||
request.execute(function(response) { | ||
var str = JSON.stringify(response.result); | ||
$('#search-container').html('<pre>' + str + '</pre>'); | ||
}); | ||
} |