From 788ee7fee2e9aaa9205ae895046b5f4eadb354d7 Mon Sep 17 00:00:00 2001 From: euzuro Date: Tue, 18 Jul 2006 16:10:38 +0000 Subject: [PATCH] add a util function to create a random id git-svn-id: http://svn.openlayers.org/trunk/openlayers@968 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 4ef93f9cb5..fa509386f8 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1081,3 +1081,17 @@ OpenLayers.Util.getArgs = function() { } return args; // Return the object. }; + +/** + * @param {String} prefix String to prefix random id. If null, default + * is "id_" + * + * @returns A unique id string, built on the passed in prefix + * @type String + */ +OpenLayers.Util.CreateID = function(prefix) { + if (prefix == null) { + prefix = "id_"; + } + return prefix + Math.round(Math.random() * 10000); +}; \ No newline at end of file