mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
Merged.
This commit is contained in:
commit
e9f6a10039
6 changed files with 74 additions and 34 deletions
|
@ -280,11 +280,11 @@ Example returns:
|
||||||
exports.setPublicStatus = function(padID, publicStatus, callback)
|
exports.setPublicStatus = function(padID, publicStatus, callback)
|
||||||
{
|
{
|
||||||
//ensure this is a group pad
|
//ensure this is a group pad
|
||||||
if(padID.indexOf("$") == -1)
|
/*if(padID.indexOf("$") == -1)
|
||||||
{
|
{
|
||||||
callback({stop: "You can only get/set the publicStatus of pads that belong to a group"});
|
callback({stop: "You can only get/set the publicStatus of pads that belong to a group"});
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//get the pad
|
//get the pad
|
||||||
getPadSafe(padID, true, function(err, pad)
|
getPadSafe(padID, true, function(err, pad)
|
||||||
|
@ -349,8 +349,8 @@ exports.setPassword = function(padID, password, callback)
|
||||||
//ensure this is a group pad
|
//ensure this is a group pad
|
||||||
if(padID.indexOf("$") == -1)
|
if(padID.indexOf("$") == -1)
|
||||||
{
|
{
|
||||||
callback({stop: "You can only get/set the password of pads that belong to a group"});
|
//callback({stop: "You can only get/set the password of pads that belong to a group"});
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the pad
|
//get the pad
|
||||||
|
|
|
@ -202,7 +202,7 @@ exports.createGroupPad = function(groupID, padName, text, callback)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//ensure pad does not exists
|
//ensure pad does not exist
|
||||||
function (callback)
|
function (callback)
|
||||||
{
|
{
|
||||||
padManager.doesPadExists(padID, function(err, exists)
|
padManager.doesPadExists(padID, function(err, exists)
|
||||||
|
@ -278,8 +278,7 @@ function randomString(len)
|
||||||
var randomstring = '';
|
var randomstring = '';
|
||||||
for (var i = 0; i < len; i++)
|
for (var i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
randomstring += chars[Math.floor(Math.random() * chars.length)];
|
||||||
randomstring += chars.substring(rnum, rnum + 1);
|
|
||||||
}
|
}
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ Class('Pad', {
|
||||||
|
|
||||||
publicStatus : {
|
publicStatus : {
|
||||||
is: 'rw',
|
is: 'rw',
|
||||||
init: false,
|
init: true,
|
||||||
getterName : 'getPublicStatus'
|
getterName : 'getPublicStatus'
|
||||||
}, //publicStatus
|
}, //publicStatus
|
||||||
|
|
||||||
|
@ -486,7 +486,11 @@ Class('Pad', {
|
||||||
},
|
},
|
||||||
setPassword: function(password)
|
setPassword: function(password)
|
||||||
{
|
{
|
||||||
this.passwordHash = password == null ? null : hash(password, generateSalt());
|
if(password == null){
|
||||||
|
this.passwordHash = null;
|
||||||
|
}else{
|
||||||
|
this.passwordHash = hash(password, generateSalt());
|
||||||
|
}
|
||||||
db.setSub("pad:"+this.id, ["passwordHash"], this.passwordHash);
|
db.setSub("pad:"+this.id, ["passwordHash"], this.passwordHash);
|
||||||
},
|
},
|
||||||
getPasswordSalt: function()
|
getPasswordSalt: function()
|
||||||
|
@ -520,8 +524,7 @@ function generateSalt()
|
||||||
var randomstring = '';
|
var randomstring = '';
|
||||||
for (var i = 0; i < len; i++)
|
for (var i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
var rnum = Math.floor(Math.random() * charset.length);
|
randomstring += chars[Math.floor(Math.random() * chars.length)];
|
||||||
randomstring += charset[rnum];
|
|
||||||
}
|
}
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ var sessionManager = require("./SessionManager");
|
||||||
exports.checkAccess = function (padID, sessionID, token, password, callback)
|
exports.checkAccess = function (padID, sessionID, token, password, callback)
|
||||||
{
|
{
|
||||||
// it's not a group pad, means we can grant access
|
// it's not a group pad, means we can grant access
|
||||||
if(padID.indexOf("$") == -1)
|
/*if(padID.indexOf("$") == -1)
|
||||||
{
|
{
|
||||||
//get author for this token
|
//get author for this token
|
||||||
authorManager.getAuthor4Token(token, function(err, author)
|
authorManager.getAuthor4Token(token, function(err, author)
|
||||||
|
@ -46,7 +46,7 @@ exports.checkAccess = function (padID, sessionID, token, password, callback)
|
||||||
|
|
||||||
//don't continue
|
//don't continue
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
var groupID = padID.split("$")[0];
|
var groupID = padID.split("$")[0];
|
||||||
var padExists = false;
|
var padExists = false;
|
||||||
|
|
|
@ -112,7 +112,7 @@ exports.doImport = function(req, res, padId)
|
||||||
//convert file to text
|
//convert file to text
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
var randNum = Math.floor(Math.random()*new Date().getTime());
|
var randNum = Math.floor(Math.random()*0xFFFFFFFF);
|
||||||
destFile = tempDirectory + "eplite_import_" + randNum + ".txt";
|
destFile = tempDirectory + "eplite_import_" + randNum + ".txt";
|
||||||
abiword.convertFile(srcFile, destFile, "txt", callback);
|
abiword.convertFile(srcFile, destFile, "txt", callback);
|
||||||
},
|
},
|
||||||
|
@ -136,10 +136,13 @@ exports.doImport = function(req, res, padId)
|
||||||
|
|
||||||
//node on windows has a delay on releasing of the file lock.
|
//node on windows has a delay on releasing of the file lock.
|
||||||
//We add a 100ms delay to work around this
|
//We add a 100ms delay to work around this
|
||||||
setTimeout(function()
|
if(os.type().indexOf("Windows") > -1)
|
||||||
{
|
{
|
||||||
callback(err);
|
setTimeout(function()
|
||||||
}, 100);
|
{
|
||||||
|
callback(err);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 15px
|
font-size: 15px
|
||||||
}
|
}
|
||||||
input[type="text"] {
|
input[type="text"], input[type="password"] {
|
||||||
width: 243px;
|
width: 243px;
|
||||||
padding: 10px 47px 10px 10px;
|
padding: 10px 47px 10px 10px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
@ -78,7 +78,13 @@
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
text-shadow: 0 0 1px #fff
|
text-shadow: 0 0 1px #fff
|
||||||
}
|
}
|
||||||
input[type="submit"] {
|
#usepwlabel {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
#usePasswordContainer {
|
||||||
|
margin: 10px 0 5px 0
|
||||||
|
}
|
||||||
|
input[type="submit"] {
|
||||||
width: 45px;
|
width: 45px;
|
||||||
margin-left: -50px;
|
margin-left: -50px;
|
||||||
padding: 8px
|
padding: 8px
|
||||||
|
@ -88,39 +94,68 @@
|
||||||
</style>
|
</style>
|
||||||
<link href="static/custom/index.css" rel="stylesheet">
|
<link href="static/custom/index.css" rel="stylesheet">
|
||||||
<script src="static/custom/index.js"></script>
|
<script src="static/custom/index.js"></script>
|
||||||
|
<script src="static/js/jquery.min.js"></script>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="button" onclick="go2Random()">New Pad</div><br><div id="label">or create/open a Pad with the name</div>
|
<div id="button" onclick="go2Random()">New Pad</div><br><div id="label">or create/open a Pad with the name</div>
|
||||||
<form action="#" onsubmit="go2Name();return false;">
|
<form action="#" onsubmit="go2Name();return false;">
|
||||||
<input type="text" id="padname" autofocus>
|
<input type="text" id="padname" autofocus/>
|
||||||
<input type="submit" value="OK">
|
<input type="submit" value="OK"/><br/>
|
||||||
|
<div id="usePasswordContainer"><input type="checkbox" id="usePassword" onclick="updatePasswordField()"/><label for="usePassword"><div id="usepwlabel">Use password</div></label></div>
|
||||||
|
<div id="passwordFieldContainer"><input type="password" id="passwordField"/></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function go2Name()
|
function go2Name()
|
||||||
{
|
{
|
||||||
var padname = document.getElementById("padname").value;
|
var padname = $("#padname").val();
|
||||||
padname.length > 0 ? window.location = "p/" + padname : alert("Please enter a name")
|
if(padname.length > 0){
|
||||||
|
if($("#passwordField").val().length>0)
|
||||||
|
{
|
||||||
|
$.get("api/1/createPad", {apikey: "o8PJ496RtbcwoMQGgDyjoOmyq5wJ8dON", padID: padname}, function(data){
|
||||||
|
$.get("api/1/setPassword", {apikey: "o8PJ496RtbcwoMQGgDyjoOmyq5wJ8dON", padID: padname, password: $("#passwordField").val()}, function(data){
|
||||||
|
window.location = "p/" + padname;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.location = "p/" + padname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alert("Please enter a name");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function go2Random()
|
function go2Random()
|
||||||
{
|
{
|
||||||
window.location = "p/" + randomPadName();
|
$("#padname").val(randomPadName());
|
||||||
|
go2Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomPadName()
|
function randomPadName()
|
||||||
{
|
{
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
var string_length = 10;
|
|
||||||
var randomstring = '';
|
var randomstring = '';
|
||||||
for (var i = 0; i < string_length; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
randomstring += chars[Math.floor(Math.random() * chars.length)];
|
||||||
randomstring += chars.substring(rnum, rnum + 1);
|
|
||||||
}
|
}
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
//start the costum js
|
function updatePasswordField()
|
||||||
if(typeof costumStart == "function") costumStart();
|
{
|
||||||
|
if($("#usePassword:checked").val()){
|
||||||
|
$("#passwordFieldContainer").css("display", "block");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#passwordFieldContainer").css("display", "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePasswordField();
|
||||||
|
if(typeof customStart == "function") customStart();
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue