Except where otherwise noted, the contents of this presentation are © Copyright 2007 Marty Stepp and are licensed under the Creative Commons Attribution 2.5 License.
Many groups have released Javascript frameworks you can include in your web pages to add effects:
.js
file you include in your web pagewww.cs.washington.edu
or students.washington.edu
)https://students.washington.edu
:
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=
ABQIAAAAjwpa3Lmr7L0oXrBemAIp0BSx0OSUw7R9ozDoChrVVXrbgKdJeBTWWRQkTwM5gxzSfgnTYruTJLircA" type="text/javascript"></script>
// in your window.onload handler: var searchControl = new GSearchControl(); searchControl.addSearcher(new search()); searchControl.draw(document.getElementById("id")); searchControl.execute("query");
div
where you want the search to show upGwebSearch
, GlocalSearch
, GvideoSearch
, GblogSearch
, GnewsSearch
, GbookSearch
GSearchControl
search object | analogous to |
---|---|
GwebSearch | www.google.com |
GlocalSearch | local.google.com |
GvideoSearch | video.google.com |
GblogSearch | blogsearch.google.com |
GnewsSearch | news.google.com |
GbookSearch | books.google.com |
new search()
execute("query")
setSearchCompleteCallback(object
, method
)
results[]
var search = new Search(); search.setSearchCompleteCallback(window, function() { for (var i = 0; i < search.results.length; i++) { do something with search.results[i]; } }); search.execute("query");
var search = new GwebSearch(); search.setSearchCompleteCallback(window, function() { for (var i = 0; i < search.results.length; i++) { alert(search.results[i].url); } }); search.execute("miserable failure");
GwebSearch
results[]
have the following properties:
url
content
: a snippet of the page's texttitleNoFormatting
: search result titleGlocalSearch
results[]
have the following properties:
url
titleNoFormatting
: search result titlelat
, lng
: latitude/longitude coordinatesstreetAddress
, city
, region
, country
phoneNumbers[]
ddUrl
, ddUrlToHere
, ddUrlFromHere
: driving directions URLsGlocalSearch
method: setCenterPoint("location")
search.setCenterPoint("Seattle, WA");
search.setCenterPoint("98105");
GvideoSearch
results[]
have the following properties:
url
content
: a snippet of the video's texttitleNoFormatting
: search result titleduration
: length of clip in secondstbUrl
, tbWidth
, tbHeight
: thumbnail image infoplayUrl
: address of Flash video that can be embeddedGblogSearch
results[]
have the following properties:
postUrl
, blogUrl
: web address of this post and entire blogcontent
: a snippet of the blog post's texttitleNoFormatting
: search result titleauthor
, publishedDate
GnewsSearch
results[]
have the following properties:
url
content
: a snippet of the blog post's texttitleNoFormatting
: search result titlelocation
(e.g. "Edinburgh,Scotland,UK")publishedDate
relatedStories[]
GbookSearch
results[]
have the following properties:
url
content
: a snippet of the blog post's texttitleNoFormatting
: search result titleauthors
publishedYear
pageCount