Created
September 9, 2014 14:32
-
-
Save patrickfox/766bf70cd01c122bf812 to your computer and use it in GitHub Desktop.
$.get_named_guid() generates a globally unique ID(GUID) based on a unique reference of handle. This GUID can then be called up at a later point by passing in the handle.
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
$.get_named_guid = function(handle, get_new) { | |
var _base, | |
_name = "_" + handle; | |
get_new = get_new || false; | |
$.guid = $.guid || 0; | |
$.named_guids = $.named_guids || []; | |
_base = $.named_guids["_" + handle]; | |
if (_base[_name] === null) { | |
_base[_name] = $.guid++; | |
} | |
if (!get_new) { | |
return $.named_guids[_name]; | |
} | |
$.named_guids[_name] = ++$.guid; | |
return $.named_guids[_name]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment