Create random pad name on the client side, this makes it possible to use it with ep-lite with https
parent
3cef5e4b23
commit
6a94c5de94
|
@ -81,13 +81,6 @@ async.waterfall([
|
||||||
res.sendfile(filePath, { maxAge: 1000*60*60 });
|
res.sendfile(filePath, { maxAge: 1000*60*60 });
|
||||||
});
|
});
|
||||||
|
|
||||||
//redirect the newpad requests
|
|
||||||
app.get('/newpad', function(req, res)
|
|
||||||
{
|
|
||||||
res.header("Server", serverName);
|
|
||||||
res.redirect('/p/' + randomPadName());
|
|
||||||
});
|
|
||||||
|
|
||||||
//let the server listen
|
//let the server listen
|
||||||
app.listen(settings.port);
|
app.listen(settings.port);
|
||||||
console.log("Server is listening at port " + settings.port);
|
console.log("Server is listening at port " + settings.port);
|
||||||
|
@ -135,15 +128,3 @@ function errorlog(e)
|
||||||
console.error(timeStr + JSON.stringify(e));
|
console.error(timeStr + JSON.stringify(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomPadName()
|
|
||||||
{
|
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
|
||||||
var string_length = 10;
|
|
||||||
var randomstring = '';
|
|
||||||
for (var i=0; i<string_length; i++) {
|
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
|
||||||
randomstring += chars.substring(rnum,rnum+1);
|
|
||||||
}
|
|
||||||
return randomstring;
|
|
||||||
}
|
|
||||||
|
|
|
@ -55,21 +55,38 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function go()
|
function go2Name()
|
||||||
{
|
{
|
||||||
var padname = document.getElementById("padname").value;
|
var padname = document.getElementById("padname").value;
|
||||||
if(padname.length > 0)
|
if(padname.length > 0)
|
||||||
{
|
{
|
||||||
window.location = "http://" + window.location.host + "/p/" + padname;
|
window.location = window.location.protocol + "//" + window.location.host + "/p/" + padname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function go2Random()
|
||||||
|
{
|
||||||
|
window.location = window.location.protocol + "//" + window.location.host + "/p/" + randomPadName() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomPadName()
|
||||||
|
{
|
||||||
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||||
|
var string_length = 10;
|
||||||
|
var randomstring = '';
|
||||||
|
for (var i=0; i<string_length; i++) {
|
||||||
|
var rnum = Math.floor(Math.random() * chars.length);
|
||||||
|
randomstring += chars.substring(rnum,rnum+1);
|
||||||
|
}
|
||||||
|
return randomstring;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<a href="/newpad" id="button"><span>New Pad</span></a>
|
<a href="javascript:go2Random()" id="button"><span>New Pad</span></a>
|
||||||
<div id="nameWrapper"><form>
|
<div id="nameWrapper"><form>
|
||||||
<span><br>or create a Pad with the name <br></span> <input type="text" id="padname"/> <input type="submit" value="OK" onclick="go();return false;">
|
<span><br>or create a Pad with the name <br></span> <input type="text" id="padname"/> <input type="submit" value="OK" onclick="go2Name();return false;">
|
||||||
</form></div></a>
|
</form></div></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue