jQuery Item Suggest

January 16th, 2009

For a project that I am working on I wanted to make use of a type ahead input box for searching. I found Peter Vulgaris’s jQuery Suggest which worked well. The thing is the results for the suggest that I was returning where not just suggestions but actual results. If the user was to select an item from the suggested list they could skip going to the search page and go to the end page.

If you’ve had enough reading, you can jump to the demo of Item Suggest now.

So I needed a way to pass back the vital information so that I could construct a URL and forward the user there once an item was selected.  The way that jQuery Suggest worked was that it fetched a file that that was then broken apart by a deliminator (default: “\n”) removed empty items, added a class to the matching part of the value and displayed the items as list elements.

I wanted to be able to pass a JSON array back and handle how it got displayed.  So I made some changes to the code and allowed a few more options.  Without specifying any options the plugin behaves the same way that it used to.

usage: suggest(source, options)

source

The location of the file that will generate the response

options
  • delay ( Number ): the length of time to weight before firing off the suggest request (default: 100)
  • resultsClass ( String ): the class to add to the ul holding the suggested items (default:  ‘ac_results’)
  • selectClass ( String ): the class to add to the element of the item that is currently selected (default:  ‘ac_over’)
  • matchClass ( String ): class to add to the segment of the suggestion that matches (default:  ‘ac_match’)
  • minchars ( Number ): How many charecters need to be entered before suggestions start getting made (default: 2)
  • delimiter ( String ):  When a ajax request is returned and createItems is flase the returned text is broken apart by this delimiter (default:  ‘\n’)
  • createItems ( Function(txt) ): This function is called with the resonse from the server passed in as txt, and expects a return of an array with the items in it if this is not specified the delimter is used to break the string into items.
  • formatItem ( Function(item,q) ): For each item in the list this function is called passing in the item and q the query that was preformed. A useful function this.addMatchClass(txt,q) can be used to add a span with the class from match class.  by default the item is wrapped in an li element and passed though addMatchClass.
  • selectItemText ( Function(item) ): This function is called when an Item is selected and expects the return value to be wha to display in input box.  By default the text value of the selected element is used.
  • onSelect ( Function(item) ): This function is called when an item is selected
  • maxCacheSize ( Number ): This controls how much data is stored in the cache (default: 65536)

Making use of the default class values you can start with this style sheet which is used in the demo and is the same used for jquery.suggest.  Here is the source for item-suggest.

Check out the demo.

Tags: ,
Posted in Javascript, jQuery | 1 Comment »

Bergdorf Goodman Holiday Polar Bears

January 2nd, 2009

EXIF
  • FileSize: 188259 bytes
  • FlashUsed: 0
  • model: NIKON D80
  • exposureTime: 0.017 s (10/600) (1/60)
  • fnumber: f/4.0
  • exposure: Reserved
  • isoEquiv: 200
  • DateTime: 2009:01:01 21:38:54
  • dateTimeDigitized: 2009:01:01 21:38:54
  • exposureBias: 0.00 (0/6)
  • aperture: 3.48220225318
  • whiteBalance: 0
  • flashUsed: No
  • focalLength: 18.00 (180/10)
  • sensing: One-chip color area sensor
  • resolution: 767x514
[Bergdorf Goodman Holiday Polar Bears]

This was one of the best Bergdorf Goodman holiday windows.  Two polar bears boxing, one even had a signed Muhammad Ali set of gloves…

Posted in Manhattan, Photo | No Comments »

Brussels Sprouts With Pancetta

December 31st, 2008

EXIF
  • FileSize: 165157 bytes
  • FlashUsed: 0
  • model: NIKON D80
  • exposureTime: 0.005 s (10/2000) (1/200)
  • fnumber: f/9.0
  • exposure: Reserved
  • isoEquiv: 250
  • DateTime: 2008:12:30 18:50:30
  • dateTimeDigitized: 2008:12:30 18:50:30
  • exposureBias: 0.00 (0/6)
  • aperture: 5.27803164309
  • whiteBalance: 1
  • flashUsed: Yes
  • focalLength: 66.00 (660/10)
  • sensing: One-chip color area sensor
  • resolution: 767x514
[Brussels Sprouts With Pancetta]

The Brussels Sprouts were blanched, stuck in the oven, then in the frying pan with the Pancetta.

Posted in Food | No Comments »

Recapping 2008: Most Popular Movie Genre

December 31st, 2008

Most Popular Movie Genre by Gross in Top 10

The Most Popular Movie Genre as Determined by Weekend Gross for 2008

Data pulled from The Numbers

Also see the 2009 recap post

Posted in Data | 2 Comments »

Baguette Dough

December 26th, 2008

EXIF
  • FileSize: 103261 bytes
  • FlashUsed: 0
  • model: NIKON D80
  • exposureTime: 0.010 s (10/1000) (1/100)
  • fnumber: f/4.2
  • exposure: Reserved
  • isoEquiv: 250
  • DateTime: 2008:12:25 15:40:34
  • dateTimeDigitized: 2008:12:25 15:40:34
  • exposureBias: 0.00 (0/6)
  • aperture: 4.14105969537
  • whiteBalance: Cloudy
  • flashUsed: Yes
  • focalLength: 32.00 (320/10)
  • sensing: One-chip color area sensor
  • resolution: 514x767
[Baguette Dough]

For Christmas my sister got me a book on how to make bread, so today I am attempting baguettes. After working the dough by throwing it on the counter many times and folding it over itself it is time for it to rise.

photo credit: Mary

Posted in Food | No Comments »

Meat and Potatoes

December 13th, 2008

EXIF
  • FileSize: 226583 bytes
  • FlashUsed: 0
  • model: NIKON D80
  • exposureTime: 0.100 s (10/100) (1/10)
  • fnumber: f/1.8
  • exposure: Reserved
  • isoEquiv: 400
  • DateTime: 2008:12:11 23:11:10
  • dateTimeDigitized: 2008:12:11 23:11:10
  • exposureBias: 0.00 (0/6)
  • aperture: 1.74110112659
  • whiteBalance: 0
  • flashUsed: No
  • focalLength: 50.00 (500/10)
  • sensing: One-chip color area sensor
  • resolution: 768x514
[Meat and Potatoes]

A little December grilling for gentleman’s night of euchre

Posted in Brooklyn | No Comments »

Carroll Gardens Street

December 10th, 2008

EXIF
  • FileSize: 267982 bytes
  • FlashUsed: 0
  • model: NIKON D80
  • exposureTime: 0.050 s (10/200) (1/20)
  • fnumber: f/2.2
  • exposure: Reserved
  • isoEquiv: 1600
  • DateTime: 2008:12:08 22:22:14
  • dateTimeDigitized: 2008:12:08 22:22:14
  • exposureBias: 0.00 (0/6)
  • aperture: 1.74110112659
  • whiteBalance: 0
  • flashUsed: No
  • focalLength: 50.00 (500/10)
  • sensing: One-chip color area sensor
  • resolution: 768x514
[Carroll Gardens Street]

I got a new lens today a Nikkor 50mm f/1.8D, I wandered around the neighborhood playing with it.

Tags:
Posted in Brooklyn | 1 Comment »

Grouping Friends

November 27th, 2008


Last night I start playing with Processing.  I had previously done a little work on a facebook app to gather what friends of mine were also friends.  I had never taken that data to any sort of useful state, so I decided it was time to try and graph those connections.  I decided to try and use Processing which turned out to be nice in some respects, as it nicely animates the spacing for me.  It also gave me some issues which may just be lack of knowledge, such as I ran into a problem with file size as I was attempting to write all my data into one file.  I then tried to use the loadStrings function which I couldn’t get to load data out of the data directory, so I had to fetch it over the web (well from the web server on my laptop).  After that was all worked out I had to draw everything, which went pretty smoothly but I had to play with my gravity metrics to pull people together that are linked and push people apart that are not.  It’s not perfect but I can see distinct groups (Work, Camp, College, High School).  The way I wrote this I place everyone on the screen in a random spot, and then adjust their position based on the gravity, until sum of the error percent stops decreasing.

Update: here is a new version that seperates a little better and adds blue

Posted in Data, Processing | 3 Comments »

My Garden Bears Fruit

November 19th, 2008

EXIF
  • FileSize: 85211 bytes
  • FlashUsed: 0
  • resolution: 768x514
[My Garden Bears Fruit]

Over the weekend I discovered that my garden had produced fruit.  My strawberry plant after suffering a squirl attack soon after I got it has actually produced a strawberry.  I’m not sure how to tell when it is ready to be picked yet, and I have no idea what I will do with it once I do pick it.  Any Ideas?

Posted in Uncategorized | No Comments »

Catching Up On News

November 13th, 2008

I use google reader a lot, I like that I don’t have to remember to check sites all the time and that it remembers what I’ve read and that I can read things in the order received instead of by site, (So I can see articles such as googles flu trends get posted around the different sites I follow). This past week I have fallen behind do to exess time spent at work.  Today I was able to get home at a reasonable time and spent sometime catching up on news.  I really like how reader tells me how addicted I am to it with a nice chart.  Recently they even updated the chart to show how many times are posted per day so I can see how on top of the news I am, I am normally pretty good about keeping up to date, but not this week, now I am uptdate.  On to hulu to empty my queue there.

Tags: ,
Posted in Musings | No Comments »