www Archive

0

Tweaking Jquery AutoSuggest

I have been using the JQuery library for a long time now, and am still amazed at what people get it to do.  One feature that the base libaray was really lacking was a good Autosuggest for a text input.  It needed to be AJAX driven, and understand having multiple values.

I found a great example of what I wanted at Drew Wilson’s blog, complete with almost all the features I needed.

One thing his script is really lacking is a good way to show ALL the results.  We have a huge category list, and want to let someone browse them all.  In the base script, this isn’t going to work, since there isnt a way to make the look up fire off without input.  I didnt want my users to have to enter in, one by one, each letter of the alphabet looking for what they wanted, so I settled on using a double click event to force the display of the entire list.

And here is how to make that happen:

In the js file (jquery.autoSuggest.js) you will need to make some changes.

~line 149 add:

 }).dblclick(function(){
 if (timeout){ clearTimeout(timeout); }
 timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);

so it will look like:

 }).blur(function(){
 if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
 $(this).val(opts.startText);
 } else if(input_focus){
 $("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
 results_holder.hide();
 }
 }).dblclick(function(){
 if (timeout){ clearTimeout(timeout); }
 timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
 }).keydown(function(e) {

This will pull up a list on double click.  You can change dlbclick to just click for a single click response instead.

~line 226 comment out the lines:

if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){ return results_holder.hide(); }

and

if (string == prev) return;

and

if (string.length >= opts.minChars) {

and then on ~line 252 comment out

 } else {
 selections_holder.removeClass("loading");
 results_holder.hide();
 }

You will also want to turn the option “resultsHighlight” false, when you create the instance.

Now, on double click it will present a full list of options.

Enhanced by Zemanta
Share
3

HTML Validation is (still) pointless!

Ok, so we all know that we should write “valid”* HTML, and yet, less than 5% of websites validate for one reason or another.  Now this statistic can be a bit misleading as a comment from a user that didn’t use valid markup could invalidate the website, so granted, there is some play with the stats (per the usual), but let’s again assume that number is close.

Why?  Why do we not write perfect HTML?  Surely with the free validator on the authority’s website there is no excuse to write code that wont validate against the standard.

The answer there is simple, if and when all the major browsers (Firefox, Safari, IE, Opera, Chrome) all render a page according to the standard, then I will finally start caring about the validation of my websites.  Until then, I will continue to write code that works across the board, and just not care if it is “valid”.

To be real though, most of the browsers work pretty well, however the 800lb gorilla in the room, IE, does not.  Microsoft continually changes the standards by which they will render a page, like promising CSS 2 support in IE7 then bailing on that promise 6 months before release.  And let us not forget the horribly pathetic Javascript rendering engine, JScript, that the rest of us just ignore because it can’t be trusted to behave reliably.

So, like even on this website, we find ourselves writing “valid” code, and at the same time having to redefine valid to mean “Code that works in all the browsers”, not “Code that the W3C says is valid even though it looks like crap in IE6″.  Just to maintain a semblance of order and sanity, we use the handy IE CSS hacks where IE on Windows will actually arbitrarly execute code depending on the version of the IE browser being used.  Does that sound like an admission of guilt on the part of MS to anyone else?  OK Bill, repeat after me, “I know my browser sucks, so, instead of fixing it which would severely hamper my marketing and legal budgets, I will just allow hacks in order to ensure you nerdy web guys can still make pretty pages”.  There, was that so hard!?

So, someone feel free to run the validate against any of my websites.  Don’t bother sending me the results because I don’t care.  The sites work, the code looks good, documented, and is maintainable, so, what exactly was the complaint?

*valid code is extremely subjective, but let’s assume here I mean W3C “valid” code.
Reblog this post [with Zemanta]
Share
8

Amateur Web Design

There are a lot of amateur web designers out there.  They post on forums, and advertise freakishly cheap prices, like $150 for a website.  The differences between them and those of us that do this professionally are too many to be named.  Obviously the pricing is a huge difference, they charge for an entire website what my hourly rate is.  But then again, I don’t really make just the brochure 4 page websites, we actually write custom applications that do very complex things ranging from e-commerce to mission critical business processes.

Another huge difference is the professionals actually stick to standards and try to keep up with trends and new technology, unlike the 15 year old designers working from mom’s house.  I found out recently about this “company” (LR Web Design).  First, they call HTML “coding” which is a complete misnomer.  And then talked down Dreamweaver, and yet their “code” is at least 10 years out of date.  No CSS, inline font tags, UPPERCASE tags, image maps for menus, and tables for very basic positioning.  Here is another one of their websites: http://knbcolo.webs.com/ .  They don’t even use a true host, but a free website company.  Let me fill you in, none of this is what you want your company to have on its website.  It is unprofessional and doesn’t really put your best foot forward.  But if you want a slow loading website on a free host with no custom anything, by all means go with one of these people.  Otherwise, go with someone with training, experience, and credentials, as well as a portfolio with real clients you have heard of.

Like wine & cars, you get what you pay for with websites.  I wouldn’t want my company looking cheap.

Enhanced by Zemanta
Share
1

Stop invading my ears!

To everyone out there that thinks it is “cool” or “neat” to put music on your website, do the rest of us a favor, and don’t.  While I understand the aesthetic nature of some sound,  for the most part it is just annoying.  When online, I usually listen to iTunes, and the last thing I want is some hideously encoded streaming .wav file repeating the same 6 seconds of music over and over again.  Unless I really need to be on your website, I hit back on my mouse and try to immediately start repressing the memory that is your website.

At the end of the day, music requires a lot of bandwidth for those of you hosting the music files, a lot more than even a complex page (assuming your images are optimized, but don’t get me started on that today).  And for every Pro:fx out there, there are a 100 Hampsterdance websites.

If you aren’t an amazing DJ, or awesome Flash/Shockwave/Silverlight developer, do us all a favor, and leave the music off your website.  I like my thousands of MP3‘s, and I don’t force you to listen to them.

Enhanced by Zemanta
Share
Tags: ,
6

For the Love of God, Optimize those Images!

Time for another lesson in web design: Image Optimization!  Yes, as we all know it is really pretty to have a huge header on your website.  Hey, look at this website, I have large images on my front page.  But, you don’t have to make that experience painful for your users, especially those on *gasp* dial-up!

The solution is simple: optimize your images.  I use Fireworks, but Photoshop has it built in these days as well.  It is basically a way of taking the image you want to use, and removes unwanted data, making the image size smaller, and hence, faster to load.  The web is a horrible medium for images, the 72dpi resolution of most monitors is just not that great.  But, it is all we have right now, and that is probably a good thing since anything more and the image just gets bigger and bigger.

By optimizing, your look stays intact, and everyone can enjoy it faster.  And it is cheaper on your wallet since it requires less bandwidth and less CPU to serve a smaller file.  Speaking of cheap, for those of you that do not have the Adobe suite, there is a pretty spiffy free online optimizer here.  Enjoy, and for the love of all things holy, optimize!

If you want to read more on the topic: HTMLSource.

Enhanced by Zemanta
Share
4

SEO…It really isn't hard

Search Engine Optimization (SEO) really isnt a new concept although the buzzword is fairly new.  It is basically the process of ensuring your site has on it that which search engines (e.g. Google) index, hence making your search engine rankings higher and presumably driving more traffic to your website.  I still remember doing this in the mid-90′s when we had a huge number of search engines ranging from Hotbot to Alta Vista to AOL that mattered and each one needed to be submitted to and then your site massaged in order to get anything resembling a decent ranking.

Times have changed, the index bots are much more sophisticated than 10+ years ago, and are far less likely to be fooled by the tricks (like using keywords hidden in your background by using the same color for both).

I often get asked, “How can I improve my search results?”.  I usually try to resist rolling my eyes for two reasons: 1) the sheer amount of resources out there covering this topic are just overwhelming and 2) it isnt that hard!  So, to those hosting with me and everyone else reading this, here are a few short tips on how to get your site SEOized!

Content, Content, Content
The more content you have, and I dont mean junk, I mean actual meaningful content, the higher your rank.  So sharpen your pencils and start writing.

New Content, New Images, New Stuff
Daily blog posts or news releases will really help you get noticed by the bots.  But again, dont post junk, otherwise your ranking will drop due to noone visiting.

Network
You must network your site.  Join a few groups, post on them, use WordPress or similar software, embrace RSS, use MySpace or Facebook and link to your site.  These will only drive traffic to your site, increase the relevancy of your keywords and get you the rankings you want.

Use decent HTML/CSS
I say decent, since I still think the entire validation thing is a scam (I will post more on that later).  Your page should work in all major browsers, use alt tags in your images, name your pages something relevant, and avoid a lot of Flash or Images (for now) since they still aren’t fully indexed.    Do not use an image for text blocks, it will not index!

See, not hard.  Enjoy adding quality content, dont overuse images or the other spiffy technologies (Silverlight, Flash, etc…) and have fun watching your traffic come to you for a change.

Enhanced by Zemanta
Share
3

Web Design at its Worst

I admit, I like to find gigs on Craigslist.  There are horrible things on there, and some stupid requests (“I need a PMP certified Project Manager with 12 years industry experience that can start today for $12/hr.”), but every now and then, something decent appears.

I was browsing, wondering about competition and stumbled on this website : LeoScorp, LLC .  What a bad name for a company, but when you first look at the site, you are amazed they claim to be in the website building business.  Bad use of colors, background image is distracting, and let’s face it, picking something like Astrology to base your company name/theme/logo on could actually turn people off, especially down here in the Bible Belt.

Assuming you make it past all that, check out their About Us.  Does anyone care they swam together at a public pool?  Does that make them better developers/designers?  If this was their homepage, sure knock yourself out, but on a business site, keep it professional.

Then go to the Services page, where they have a stupid little computer extremely slowing typing out the content.  First, it is slow, I type much faster than that and read WAY faster.  Let’s go already.  I don’t have time to sit there and be annoyed at a little graphic you thought was cute.  Furthermore, doing that stuff isn’t even close to SEO helpful, so maybe it is a good thing you are on Craigslist looking for jobs since Google just isn’t working out for you.

But let’s face it, no matter how bad a site is, it could always be worse.

Enhanced by Zemanta
Share
Tags: ,
4

Programmers, do you have Insurance?

Calling all programmers, those of you that do it professionally at least.  Do you have your own personal errors and omissions insurance?  Should you?  Probably.

I have been in development for a long time time, about 12 years, and for the web development world I live in, that makes me ancient.  I carry my own errors and omission insurance for personal projects, just in case the GPL can’t protect me well enough.  What is this insurance you ask?

There is a good article over at Insurance Journal that goes over exactly what it is and why you might need it.  My question is a bit more complex though.  If you are a professional programming, working on someone else’s payroll, do you need this insurance?  If you are fired for incompetence, or laid off, and the company you used to work for finds a bug that has cost them $1M a week since it was implemented 2 quarters ago, do they have the right, or abililtty, to sue you for that loss?  Perhaps.  It all depends on where you live, what company, and the situation.

Being sued for something you did on the job, in the best interest of the company, under the leadership of someone else, is extremely rare.  Most likely because it requires the company to admit they were less than diligent, didn’t do a very good job managing, and then makes them liable to their stakeholders since they are basically admitting an agent of their company screwed up.  Companies don’t like to do that.

However, if you are working on a 1099 or a third party W2, you need to make sure you are covered.  If you are on 1099 or doing corp-to-corp, you had better have insurance.  You are liable in that case, in the absence of another contract, for everything you do and write.  While you probably wouldn’t be found guilty of anything (I hope), it would be expensive to fight it, and better let the insurance company do it.

If you are on a third party W2, make sure the folks you are actually workign for have E&O insurance as an add on or rider to their general liablity.  You could need them to protect you for something you did in their employ on behalf of one of their clients.

So, do you have insurance?  Do you need it?  I am not a lawyer, so none of this should be taken and blindly run with, but, ask yourself if you are covered, and if you have questions or doubts, find someone that knows and ask.  It never hurts and could save you a lot of trouble later.

Related articles by Zemanta
Enhanced by Zemanta
Share
1

Programming Standards are NOT pointless

It seems some people took my other article a bit too seriously.  While I was very serious and feel strongly about my convictions when it comes to HTML “validation”, the same cannot be said of programming standards.

For those of you that have never programming professionally, this stuff may be very new to you.  However, trust me, it is extremely important.  Programming standards are not stupid, are not corners to be cut, and must be strict, otherwise they ARE pointless.

There are standards when it comes to documenting your code, and I wont get into them.  But if you are interested there are programs out there which more or less set the standard if you want to use them.  JavaDoc, PHPDoc, and for those MS folks….. .  Go check out their websites for good advice on how to format your comments in your code.

Now, for actually coding, I have my own set of standards, developed over the years, to make the code both readable, but also hopefully logical.  Most people I run into think my code is pretty readable, some languages more than others.  Let’s face it, Perl code will never, ever, be as readable or “pretty” as Python.  It just isn’t going to happen.  Sorry you old UNIX guys, but Perl just isn’t very pretty.  The OO languages are much easier on the eyes.

So, other than for documentation reasons, readability (which leads to maintainability), are there actually other reasons to program to a standard?  Only if you want to use your code in some sort of portfolio.  But those first two reasons are EXTREMELY important.  Everyone out there that has programmed professionally will know exactly what I mean.

Tabs or spaces?  Braces at the end of a line or on their own line?  Spaces between concatenation or operators?  Double quotes or single quotes?  Print to buffer or hold in variables?  Globals or object variables?  Arguments or variables?

There are a ton of questions, and I cant answer them all.  But think about why you do something, and if you cant come up with a good reason, probably time to stop doing it.

Enhanced by Zemanta
Share
0

How to fix WP ECommerce

On front end pages with no ecommerce functionality, this plugin adds over 220+ database queries.  The more I messed with the code trying to make it behave, the more I understood just how horribly written this plugin is.

Now, as someone that has been doing development long enough to know, there are times that code just gets away from the development team and becomes a mess unto itself.  It happens, especially in the OSS world where code reviews are few if ever.  But, as I read the forums for this thing, the developers are just fooling themselves thinking the code is in good shape.

Here are a few basic suggestions:
1) Check to see if the page needs to execute the plugin.  If it doesnt, dont do it.  There is no reason to increase the number of queries by an order of magantuide when I am on a page that has no WP Ecommerce functionality.
2) Clean up the queries.  For example:
SELECT `id` FROM `wp_product_list` WHERE `active` IN(’1′)
should be
SELECT `id` FROM `wp_product_list` WHERE `active` = 1
It is more effiecent.

3) Index the tables!  The query above doesnt use an index.  That is right folks, the field “active” in product_list is not indexed.  This is easy and simple.

4) Use arrays or some other data structure for complex data.  Dont use the same basic query over and over again.  Example:

Share