1function uuid(){
2 var dt = new Date().getTime();
3 var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
4 var r = (dt + Math.random()*16)%16 | 0;
5 dt = Math.floor(dt/16);
6 return (c=='x' ? r :(r&0x3|0x8)).toString(16);
7 });
8 return uuid;
9}
10
11
1function uuid() {
2 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
3 var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
4 return v.toString(16);
5 });
6}
7
8var userID=uuid();//something like: "ec0c22fa-f909-48da-92cb-db17ecdb91c5"