This commit is contained in:
jaseg 2011-12-06 22:01:58 +01:00
commit e9f6a10039
6 changed files with 74 additions and 34 deletions

View file

@ -69,7 +69,7 @@
font-weight: bold;
font-size: 15px
}
input[type="text"] {
input[type="text"], input[type="password"] {
width: 243px;
padding: 10px 47px 10px 10px;
background: #fff;
@ -78,7 +78,13 @@
border-radius: 3px;
text-shadow: 0 0 1px #fff
}
input[type="submit"] {
#usepwlabel {
display: inline;
}
#usePasswordContainer {
margin: 10px 0 5px 0
}
input[type="submit"] {
width: 45px;
margin-left: -50px;
padding: 8px
@ -88,39 +94,68 @@
</style>
<link href="static/custom/index.css" rel="stylesheet">
<script src="static/custom/index.js"></script>
<script src="static/js/jquery.min.js"></script>
<div id="container">
<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;">
<input type="text" id="padname" autofocus>
<input type="submit" value="OK">
<input type="text" id="padname" autofocus/>
<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>
</div>
<script>
function go2Name()
{
var padname = document.getElementById("padname").value;
padname.length > 0 ? window.location = "p/" + padname : alert("Please enter a name")
var padname = $("#padname").val();
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()
{
window.location = "p/" + randomPadName();
$("#padname").val(randomPadName());
go2Name();
}
function randomPadName()
{
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_length = 10;
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.substring(rnum, rnum + 1);
randomstring += chars[Math.floor(Math.random() * chars.length)];
}
return randomstring;
}
//start the costum js
if(typeof costumStart == "function") costumStart();
}
function updatePasswordField()
{
if($("#usePassword:checked").val()){
$("#passwordFieldContainer").css("display", "block");
}
else
{
$("#passwordFieldContainer").css("display", "none");
}
}
updatePasswordField();
if(typeof customStart == "function") customStart();
</script>
</html>
</html>