From 67148f28463f8d4f2b7b61d38aa5d71df9658e4c Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 21 Jan 2011 13:14:55 +1100 Subject: ... --- main.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index dd46cd18..d0a82dda 100644 --- a/main.js +++ b/main.js @@ -14,9 +14,21 @@ function focusId(id) document.getElementById(id).focus(); init(); } + +function generatePassword() { + pass = ''; + chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+'; + for(i=0;i<8;i++) { + rnd = Math.floor(Math.random() * chars.length); + pass += chars.substring(rnd,rnd + 1); + } + return pass; +} + function dopost(form) { - localStorage.name = form.name.value; - localStorage.email = form.email.value; + localStorage.name = form.name.value.replace(/ ##.+$/, ''); + if(form.email.value != 'sage') + localStorage.email = form.email.value; return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != ""); } @@ -65,6 +77,13 @@ function init() newElement.appendChild(style); } + if(!localStorage.password) + localStorage.password = generatePassword(); + elements = document.getElementsByName('password'); + for(x=0;x