mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
move randomString function into module
This commit is contained in:
parent
f7089bba20
commit
a300bb6e92
8 changed files with 26 additions and 90 deletions
|
@ -22,6 +22,8 @@ var ERR = require("async-stacktrace");
|
|||
var db = require("./DB").db;
|
||||
var async = require("async");
|
||||
|
||||
var randomString = require("../utils/randomstring");
|
||||
|
||||
/**
|
||||
* returns a read only id for a pad
|
||||
* @param {String} padId the id of the pad
|
||||
|
@ -70,18 +72,3 @@ exports.getPadId = function(readOnlyId, callback)
|
|||
{
|
||||
db.get("readonly2pad:" + readOnlyId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random String with the given length. Is needed to generate the read only ids
|
||||
*/
|
||||
function randomString(len)
|
||||
{
|
||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
var randomstring = '';
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
var rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars.substring(rnum, rnum + 1);
|
||||
}
|
||||
return randomstring;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue