Monthly Archives: September 2009

jQuery

I picked up the book jQuery In Action, and I think I love this library!  Actually, I picked it up a while ago and I’m just getting around to writing about it.  I recently built a website for watching the building of the new arena in Pittsburgh (which is down now because the building is big enough to block the webcam), and I used jQuery to do some really nice fades for image thumbnails.  The only problem was, I was following pre-written instructions and did not know what was really going on.  It did, however, introduce me to the magic of jQuery!

CSS consistency across browsers

One of the best things about jQuery is that you can (almost always) just put a line of jQuery in my web page and it will work across all of the major browsers.  I have had some very small issues with this, but nothing major compared to the amount of code it takes in straight javascript to do the same thing.

There’s also the selectors.  If you know CSS, then you can use jQuery.  jQuery works by creating a wrapped set of elements and performing some tasks on each element in the wrapped set.  The book i read uses the term wrapped set, but if that term is confusing you can just think of it as a group of elements that matches the selector you chose to use.

Any CSS selector can be used to query the page and create this wrapped set.  It even allows for CSS3 selectors and a couple of jQuery-specific extended selectors.  For example, consider the child selector #formId > h1 that would select all h1 elements nested inside the element with the id #formId.  This is not supported in IE6, but with jQuery you can use it anyway:

$('#formId > h1').css('color','red');

Simplify, Simplify, Simplify

jQuery is just simple.  You only need to know the CSS selectors to get the maximum power from jQuery, not which browser supports which selectors, etc.  The javascript file is much neater and more readable.  Take this example of code that was used to put focus on the first input on a webpage:

function setFocusOnFirstLocationOfInputType(type){
var elementsInputs = document.getElementsByTagName("input");
for (i=0; i < elementsInputs.length; i++) {
if(elementsInputs[i].type == type){
elementsInputs[i].focus();
break;
}
}
}

and now consider the jQuery that does the same:

function setFocusOnFirstLocationOfInputType(type){
$("input[type="+type+"]:first").focus();
}

Extendable!

The jQuery core library does everything I’ve mentioned and a lot more, and it is small.  If you need more, there are a lot of plugins available that supply very complex features (made simple!) like accordian or sliding menus (jQueryUI plugin), or extended selectors with regular expressions.

Some links to additional info on the library:


market research is hard

I took up a new project at work recently which is semi-related to software.  We are building a new system, and now we expanding our marketing efforts.  My new job for the last couple of weeks was to perform a market study of a niche market in Pennsylvania (Muncipal authorities — but not even, it is a subset of the authorities I’m researching) and determine how we are going to attack it!

Typically being a software developer (I am doing marketing because I also have an MBA), I assumed I would be able to find a nice and tidy set of websites that I could quickly consolidate and tweak in order to serve my purpose of data collection.  However, after the first four hours of looking at authority websites that look like they were created in 1995 (one even has blinking text!), I realized that this was not as easy a solution as I thought.

I took a step back and spent a day looking for associations and group sites.  This was a pretty good path, I found one site that listed a couple of hundred PA authorities websites.  I went with it and, not thinking I guess, started down the list going to each one and writing down email addresses.  By the end of the day, I had all of 31.

I quickly (compared to the rest of the day) put together an email questionaire template and fed the names and emails into it via mail merge (in MS Word).  Also, quickly, I received 4 or 5 replies.  It only took about an hour for them to come in!  And they were useful!  I learned my first lesson.

Just about all replies from email marketing come within 24 hours

No science or official theory behind that, but that was it.  I received those responses and no more.  And more, it seems to fit what I have always heard about replies: about 3-5% response from marketing sent out.

I wised up and remembered that technology could save me.  If I thought of a program that would be slightly useful, i knew someone else would have already written it.  And they did.  I downloaded (bought) a program called “email grabber.”  I took the websites I found, fed them into email grabber, and set it free.  It downloaded 3500 emails for me in about 20 minutes.

After sorting through those and finding the ones that actually went to people, I fed them back through my mail merge template, and guess what…  I got back 95% of my replies by the next afternoon, again at around a 3-5% rate.  This isn’t easy!  Now I’m on to contacting more people by phone.