ftimme
2012-05-16 00385e0d5a5058862d28270f874b76a2f64f9de2
interface/web/js/scrigo.js.php
@@ -525,3 +525,33 @@
    }
    return rv;
}
function password(length, special) {
   var iteration = 0;
   var password = "";
   var randomNumber;
   length = length || 10;
   if(special == undefined){
      var special = false;
   }
   while(iteration < length){
      randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
      if(!special){
         if ((randomNumber >=33) && (randomNumber <=47)) { continue; }
         if ((randomNumber >=58) && (randomNumber <=64)) { continue; }
         if ((randomNumber >=91) && (randomNumber <=96)) { continue; }
         if ((randomNumber >=123) && (randomNumber <=126)) { continue; }
      }
      iteration++;
      password += String.fromCharCode(randomNumber);
   }
   return password;
}
function generatePassword(passwordFieldID){
   var oldPWField = jQuery('#'+passwordFieldID);
   var newPWField = oldPWField.clone();
   newPWField.attr('type', 'text').attr('id', 'tmp'+passwordFieldID).insertBefore(oldPWField);
   oldPWField.remove();
   newPWField.attr('id', passwordFieldID).val(password(10, true)).trigger('keyup');
}