From 0d278156941829dc289708bd4bbe291daaa0dd45 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 1 Jun 2006 19:46:57 +0000 Subject: [PATCH] Scholar.randomString( [int len] ) -- generate a random string --- .../content/scholar/xpcom/scholar.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js index 44e125275b..eadd95afc6 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/scholar.js +++ b/chrome/chromeFiles/content/scholar/xpcom/scholar.js @@ -21,6 +21,7 @@ var Scholar = new function(){ this.getString = getString; this.flattenArguments = flattenArguments; this.join = join; + this.randomString = randomString; this.Hash = Hash; @@ -177,6 +178,23 @@ var Scholar = new function(){ } + /** + * Generate a random string of length 'len' (defaults to 8) + **/ + function randomString(len) { + var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; + if (!len){ + len = 8; + } + var randomstring = ''; + for (var i=0; i