reverted js functions but reduced if clause using ternary operation

This commit is contained in:
Robin Buse 2011-08-17 21:58:07 +03:00
parent 4aeb76cdac
commit d3a33024ec

View file

@ -96,20 +96,31 @@
</form> </form>
</div> </div>
<script> <script>
function go2Name() { function go2Name()
var a = document.getElementById("padname").value; {
a.length > 0 ? window.location = "p/" + a : alert("Please enter a name") var padname = document.getElementById("padname").value;
padname.length > 0 ? window.location = "p/" + padname : alert("Please enter a name")
} }
function go2Random() {
window.location = "p/" + randomPadName() function go2Random()
{
window.location = "p/" + randomPadName();
} }
function randomPadName() {
for (var a = "", b = 0; b < 10; b++) { function randomPadName()
var c = Math.floor(Math.random() * 62); {
a += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".substring(c, c + 1) var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
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 a return randomstring;
} }
typeof costumStart == "function" && costumStart();
//start the costum js
if(typeof costumStart == "function") costumStart();
</script> </script>
</html> </html>