forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_user.js
More file actions
60 lines (54 loc) · 2.05 KB
/
Copy pathadd_user.js
File metadata and controls
60 lines (54 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$(function() {
$('#v_email').change(function() {
if($('#v_email_notify').attr('checked')){
document.getElementById('v_notify').value = document.getElementById('v_email').value;
}
});
$('#v_email_notify').change(function() {
if($('#v_email_notify').attr('checked')){
document.getElementById('v_notify').value = document.getElementById('v_email').value;
}else{
document.getElementById('v_notify').value = '';
}
});
});
randomString = function(min_length = 16) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
var string_length = min_length;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substr(rnum, 1);
}
var regex = new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*\d)[a-zA-Z\d]{8,}$/);
if(!regex.test(randomstring)){
randomString();
}else{
$('input[name=v_password]').val(randomstring);
App.Actions.WEB.update_v_password();
}
}
App.Actions.WEB.update_v_password = function (){
var password = $('input[name="v_password"]').val();
var min_small = new RegExp(/^(?=.*[a-z]).+$/);
var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
var min_num = new RegExp(/^(?=.*\d).+$/);
var min_length = 8;
var score = 0;
if(password.length >= min_length) { score = score + 1; }
if(min_small.test(password)) { score = score + 1;}
if(min_cap.test(password)) { score = score + 1;}
if(min_num.test(password)) { score = score+ 1; }
$('#meter').val(score);
}
App.Listeners.WEB.keypress_v_password = function() {
var ref = $('input[name="v_password"]');
ref.bind('keypress input', function(evt) {
clearTimeout(window.frp_usr_tmt);
window.frp_usr_tmt = setTimeout(function() {
var elm = $(evt.target);
App.Actions.WEB.update_v_password(elm, $(elm).val());
}, 100);
});
}
App.Listeners.WEB.keypress_v_password();