Created
June 5, 2013 15:55
-
-
Save boostbob/5715011 to your computer and use it in GitHub Desktop.
foundation interchange uuid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uuid : function (separator) { | |
var delim = separator || "-"; | |
function S4() { | |
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); | |
} | |
return (S4() + S4() + delim + S4() + delim + S4() | |
+ delim + S4() + delim + S4() + S4() + S4()); | |
}, | |
store : function (el, scenarios) { | |
var uuid = this.uuid(), | |
current_uuid = el.data('uuid'); | |
if (current_uuid) return this.cache[current_uuid]; | |
el.attr('data-uuid', uuid); | |
return this.cache[uuid] = scenarios; | |
}, | |
trim : function(str) { | |
if (typeof str === 'string') { | |
return $.trim(str); | |
} | |
return str; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment