jQuery UUID Extension plugin

***UPDATED FOR JQUERY 1.6***
There is a long time since I visited my plugin, and on a recent project I got to use it again and found it was not working. So I have reworked it for the latest jQuery version.
A backwards-incompatible function name change was necessary due to jQuery.uuid being already taken. Function is now jQuery.uidGen(). Sorry about that.
This is a conversion of a few functions I make use of to a jQuery plugin.
I never added a license before, (didn't even care about it back then), now the code is MIT licensed.
This stems out from my need to be sure to have unique IDs, but I dont want to waste time reviewing code to make sure it is really unique, so as to not collide with other IDs on my page. I can have a random amount of forms at the same time in an inordinate amount of tabs, and each form has several form elements, and making sure they are all unique can be painstaking.
So I track my forms by registering the id of each form in an object array.
Naturally, other people may have other uses for the UUIDs.
UUIDs are generated in one of two formats: 00000000-0000-0000-0000-000000000000 , with an optional prefix; or a global counter which is incremented for each uuid created.
Straight from the file header:
/*
* jQuery UUID Generator 2.0.0
*
* Copyright 2011 Tiago Mikhael Pastorello Freire a.k.a Brazilian Joe
*
* Licensed under the MIT license.
http://www.opensource.org/licenses/MIT
*
* Functionality:
* Usage 1: define the default prefix by using an object with the
* property prefix as a parameter which contains a string value,
* and/or determine the uuid generation mode:
* (sequential|random) jQuery.uidGen({prefix: 'id',mode:'sequential'})
* Usage 2: call the function jQuery.uidGen() with a
* string parameter p to be used as a prefix to generate a random uuid;
* Usage 3: call the function jQuery.uidGen() with no parameters
* to generate a uuid with the default prefix; default prefix: '' (empty string)
*/
Get the plugin at the jQuery Plugins here.

Nenhum comentário: