Archive for the ‘javascript’ Category

Updated Twitter Javascript Search Stuff

Wednesday, May 13th, 2009


Twitter Search from Javascript

Tuesday, May 5th, 2009

I was working on building a js twitter search app for jazzfest, which I didn’t finish in time really, but I liked the interface I came up with.

Twitter = {
  _callbacks:[]
};
Twitter.search = function(opts){
//opts.q
//opts.callback
var callback = function(data){
    opts.callback(data); 
    Twitter._callbacks = Twitter._callbacks.without(callback)
  }
var len = Twitter._callbacks.push(callback)
document.body.insert("

You call it by doing:

Twitter.search({q:'happy birthday',callback: function(data){
  something_awesome(data.results)
}})

The next thing to do would be to add support for more of the search API's parameters.
Or to remove the dependency on Prototype introduced by using insert on the body rather than something more verbose.