Tuesday, October 28, 2008

Design Eye for the Backend Guy

Stefano Mazzocchi has published an awesome summary of everything a clueless front-end guy should be looking at. Key features are modern CSS design, color pickers, JS-based ui correction, font stuff, the whole nine yards. Basically the entire article is essential.

If you are that stubborn programmer that doesn't know anything about front-end and needs a modern guide to getting it done, this is for you.

http://www.betaversion.org/~stefano/linotype/news/169/

Sunday, October 12, 2008

Simple JQuery UID Plugin

UID's can be tricky to make, but here's a simple one for discussion.

I'm posting this to see if anyone can make it a little safer to prevent collisions and/or improve the algorithm. Any thoughts? The prefix allow you to create uids you can select with a prefix on. The random string will give you a fairly large but not unmanageable string. We'll also return the JQuery instance so we can continue our chain.


(function($){
$.fn.uid = function(prefix) {
if (!prefix) {
prefix = "uid";
}
var generate = function() {
var dt = new Date().getMilliseconds();
var num = Math.random();
var rnd = Math.round(num*100000);
return prefix+dt+rnd;
};
return this.each(function() {
this.id = generate();
return $;
});
};
})(jQuery);

Usage:
$().ready(function() {
$('div').uid().css('background-color','blue');
});


Oui? Non?