mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Pads are now saved to the database, but some weird Bugs with the Attribute Pool
This commit is contained in:
parent
73efbf216d
commit
08b8568f7b
3 changed files with 236 additions and 158 deletions
|
@ -31,31 +31,34 @@ globalPads = [];
|
|||
* @param id A String with the id of the pad
|
||||
* @param createIfNotExist A Boolean which says the function if it should create the Pad if it not exist
|
||||
*/
|
||||
exports.getPad = function(id, createIfNotExist)
|
||||
{
|
||||
var pad = globalPads[id];
|
||||
|
||||
if(!pad && createIfNotExist == true)
|
||||
exports.getPad = function(id, callback)
|
||||
{
|
||||
var pad = globalPads[id];
|
||||
|
||||
//return pad if its already loaded
|
||||
if(pad != null)
|
||||
{
|
||||
callback(null, pad);
|
||||
}
|
||||
//try to load pad
|
||||
else
|
||||
{
|
||||
pad = new Pad(id);
|
||||
globalPads[id] = pad;
|
||||
|
||||
//initalize the pad
|
||||
pad.init(function(err)
|
||||
{
|
||||
if(err)
|
||||
{
|
||||
callback(err, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
globalPads[id] = pad;
|
||||
callback(null, pad);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(!pad) return null;
|
||||
|
||||
//globalPads[id].timestamp = new Date().getTime();
|
||||
|
||||
return pad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the Pad exists
|
||||
* @param id The Pad id
|
||||
*/
|
||||
exports.ensurePadExists = function(id)
|
||||
{
|
||||
if(!globalPads[id])
|
||||
{
|
||||
exports.getPad(id, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue