Password strength meter from MellerTime. see #4470

git-svn-id: http://svn.automattic.com/wordpress/trunk@6419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-12-19 21:53:10 +00:00
parent 630cd8267c
commit 1f28d55ab3
3 changed files with 91 additions and 2 deletions

View File

@ -1,6 +1,51 @@
<?php
require_once('admin.php');
function profile_js ( ) {
?>
<script type="text/javascript">
function check_pass_strength ( ) {
var pass = jQuery('#pass1').val();
var user = jQuery('#user_login').val();
// get the result as an object, i'm tired of typing it
var res = jQuery('#pass-strength-result');
var strength = passwordStrength(pass, user);
jQuery(res).removeClass('short bad good strong');
if ( strength == 'Bad' ) {
jQuery(res).addClass('bad');
jQuery(res).html( pwsL10n.bad );
}
else if ( strength == 'Good' ) {
jQuery(res).addClass('good');
jQuery(res).html( pwsL10n.good );
}
else if ( strength == 'Strong' ) {
jQuery(res).addClass('strong');
jQuery(res).html( pwsL10n.strong );
}
else {
// this catches 'Too short' and the off chance anything else comes along
jQuery(res).addClass('short');
jQuery(res).html( pwsL10n.short );
}
}
jQuery(document).ready( function() { jQuery('#pass1').keyup( check_pass_strength ) } );
</script>
<?php
}
add_action('admin_head', 'profile_js');
wp_enqueue_script('jquery');
wp_enqueue_script('password-strength-meter');
$title = __('Profile');
if ( current_user_can('edit_users') )
@ -42,7 +87,7 @@ $bookmarklet_height= 440;
<fieldset id="information">
<legend><?php _e('Name'); ?></legend>
<p><label><?php _e('Username: (no editing)'); ?><br />
<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
<input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
</label></p>
<p><label><?php _e('First name:') ?><br />
@ -114,6 +159,10 @@ if ( $show_password_fields ) :
<p><label><?php _e('Type it one more time:'); ?><br />
<input type="password" name="pass2" id="pass2" size="16" value="" />
</label></p>
<p><strong><?php _e('Password Strength:'); ?></strong></p>
<div id="pass-strength-result"><?php _e('Too short'); ?></div>
<!--[if IE 6]><div id="pass-strength-iesucks"><?php _e("If you weren&#8217;t using this sucky IE6, there would be pretty colors... and cookies!"); ?></div><![endif]-->
<p><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"£$%^&( in your password.'); ?></p>
</fieldset>
<?php endif; ?>

View File

@ -1356,3 +1356,36 @@ a.view-link {
#update-nag a:link, .plugin-update a:link {
color: #036;
}
#pass-strength-result {
padding: 3px 5px 3px 5px;
margin-top: 3px;
text-align: center;
background-color: #e3e3e3;
border: 1px solid #000000;
}
#pass-strength-result.short {
background-color: #e3e3e3;
border: 1px solid #000000;
}
#pass-strength-result.bad {
background-color: #ffeff7;
border: 1px solid #cc6699;
}
#pass-strength-result.good {
background-color: #effff4;
border: 1px solid #66cc87;
}
#pass-strength-result.strong {
background-color: #59ef86;
border: 1px solid #319f52;
}
#pass-strength-iesucks {
font-size: 8pt;
text-align: center;
}

View File

@ -117,6 +117,13 @@ class WP_Scripts {
) );
$this->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' );
$this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
$this->add( 'password-strength-meter', '/wp-admin/js/passwordStrengthMeter.js', array('jquery'), '20070405' );
$this->localize( 'password-strength-meter', 'pwsL10n', array(
'short' => __('Too short'),
'bad' => __('Bad'),
'good' => __('Good'),
'strong' => __('Strong')
) );
$this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20071104' );
$this->add( 'admin-posts', '/wp-admin/js/edit-posts.js', array('wp-lists'), '20071023' );
$this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );