View Full Version : guid/uuid generator
jcrypt
01-05-2009, 04:54 AM
// only tested in Firefox 3+
function getUniqueID() {
var rnd = '';
while (rnd.length < 36) {
rnd += Math.floor(Math.random()*16).toString(16);
if (rnd.length.toString().search(/^8|^13|^18|^23/) > -1) rnd += '-';
}
return '{' + rnd + '}';
}
var uid = getUniqueID();
jcrypt
01-29-2009, 05:38 AM
If your browser supports bookmarklets you can use the following code to create and display unique ids in your browser by simply clicking on a bookmark.
javascript:var%20rnd%20=%20'';%20while%20(rnd.length%20<%2036)%20{%20rnd%20+=%20Math.floor(Math.random()*16).toString(16);%20if%20(rnd.length.toString().sea rch(/^8|^13|^18|^23/)%20>%20-1)%20rnd%20+=%20'-';%20}%20document.open();%20document.write('{'%20+%20rnd%20+%20'}');%20document.close();
In Firefox try the following:
Click Bookmarks > Bookmark this page. It doesn't matter which page you bookmark since the url will only be used temporarily.
Click on Bookmarks and find the new bookmark that you just created.
Right click on the bookmark and select properties.
In the Name box type "UUID Generator".
In the Location box paste the entire javascript url from the code box above.
Delete any text that appears in the keyword or description boxes and then click 'save changes'.
Now anytime you need a new guid/uuid simply click on Bookmarks and then click UUID Generator.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.