2009-05-25 01:39:56 +02:00
|
|
|
(function($){
|
|
|
|
|
|
|
|
function check_pass_strength() {
|
2010-03-31 10:45:51 +02:00
|
|
|
var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
|
2009-05-25 01:39:56 +02:00
|
|
|
|
|
|
|
$('#pass-strength-result').removeClass('short bad good strong');
|
2010-03-31 10:45:51 +02:00
|
|
|
if ( ! pass1 ) {
|
2009-05-25 01:39:56 +02:00
|
|
|
$('#pass-strength-result').html( pwsL10n.empty );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-31 10:45:51 +02:00
|
|
|
strength = passwordStrength(pass1, user, pass2);
|
2009-05-25 01:39:56 +02:00
|
|
|
|
|
|
|
switch ( strength ) {
|
|
|
|
case 2:
|
|
|
|
$('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
$('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
$('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
|
|
|
|
break;
|
2010-03-31 10:45:51 +02:00
|
|
|
case 5:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
|
|
|
|
break;
|
2009-05-25 01:39:56 +02:00
|
|
|
default:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-01 22:40:16 +02:00
|
|
|
$(document).ready(function() {
|
2009-05-25 01:39:56 +02:00
|
|
|
$('#pass1').val('').keyup( check_pass_strength );
|
2010-03-31 10:45:51 +02:00
|
|
|
$('#pass2').val('').keyup( check_pass_strength );
|
2010-09-25 12:58:01 +02:00
|
|
|
$('#pass-strength-result').show();
|
2011-05-25 03:04:12 +02:00
|
|
|
$('.color-palette').click(function(){$(this).siblings('input[name="admin_color"]').prop('checked', true)});
|
2011-04-01 22:40:16 +02:00
|
|
|
$('#first_name, #last_name, #nickname').blur(function(){
|
|
|
|
var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [],
|
|
|
|
inputs = {
|
|
|
|
display_nickname : $('#nickname').val(),
|
|
|
|
display_username : $('#user_login').val(),
|
|
|
|
display_firstname : $('#first_name').val(),
|
|
|
|
display_lastname : $('#last_name').val()
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( inputs.display_firstname && inputs.display_lastname ) {
|
|
|
|
inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
|
|
|
|
inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
|
2009-05-25 01:39:56 +02:00
|
|
|
}
|
2011-04-01 22:40:16 +02:00
|
|
|
|
|
|
|
$('option', select).remove();
|
|
|
|
$.each(inputs, function( id, value ) {
|
2011-06-28 18:17:49 +02:00
|
|
|
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
|
2011-04-01 22:40:16 +02:00
|
|
|
|
2011-06-28 18:17:49 +02:00
|
|
|
if ( inputs[id].length && $.inArray( val, dub ) == -1 ) {
|
|
|
|
dub.push(val);
|
|
|
|
$('<option />', {
|
|
|
|
'id': id,
|
|
|
|
'text': val,
|
|
|
|
'selected': (id == current)
|
|
|
|
}).appendTo( select );
|
2011-04-01 22:40:16 +02:00
|
|
|
}
|
|
|
|
});
|
2009-05-25 01:39:56 +02:00
|
|
|
});
|
2011-04-01 22:40:16 +02:00
|
|
|
});
|
2009-05-25 01:39:56 +02:00
|
|
|
|
|
|
|
})(jQuery);
|