mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
Update main.js
This commit is contained in:
parent
f3790675ee
commit
0cc00dbb29
1 changed files with 26 additions and 2 deletions
|
@ -460,9 +460,33 @@ $(document).ready(function () {
|
|||
/**
|
||||
* Autocomplete password
|
||||
**/
|
||||
var autocomplete = function (noCenter) {
|
||||
var string_result = ""; // Empty string
|
||||
function generatePassword(length) {
|
||||
const lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
|
||||
const uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const numberChars = "0123456789";
|
||||
const specialChars = "!@#$%^&*()_+~`|}{[]:;?><,./-=";
|
||||
|
||||
let password = [
|
||||
getRandomChar(lowercaseChars),
|
||||
getRandomChar(uppercaseChars),
|
||||
getRandomChar(numberChars),
|
||||
getRandomChar(specialChars)
|
||||
];
|
||||
|
||||
for (let i = 4; i < length; i++) {
|
||||
password.push(getRandomChar(lowercaseChars));
|
||||
}
|
||||
|
||||
password = password.sort(() => Math.random() - 0.5);
|
||||
return password.slice(0, length).join("");
|
||||
}
|
||||
|
||||
function getRandomChar(charSet) {
|
||||
return charSet[Math.floor(Math.random() * charSet.length)];
|
||||
}
|
||||
|
||||
var autocomplete = function (noCenter, passwordLength = 10) {
|
||||
let string_result = generatePassword(passwordLength);
|
||||
var _popup_left = (Math.ceil(window.screen.availWidth / 2) - 150);
|
||||
var _popup_top = (Math.ceil(window.screen.availHeight / 2) - 50);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue