Make WordPress Core


Ignore:
Timestamp:
08/24/2008 02:35:46 PM (16 years ago)
Author:
azaozz
Message:

Few small improvements to the password strength meter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/user-edit.php

    r8701 r8722  
    2424?>
    2525<script type="text/javascript">
    26     function check_pass_strength ( ) {
    27 
    28         var pass = jQuery('#pass1').val();
    29         var user = jQuery('#user_login').val();
    30 
    31         // get the result as an object, i'm tired of typing it
    32         var res = jQuery('#pass-strength-result');
     26(function($){
     27   
     28    function check_pass_strength () {
     29
     30        var pass = $('#pass1').val();
     31        var user = $('#user_login').val();
     32
     33        $('#pass-strength-result').removeClass('short bad good strong');
     34        if ( ! pass ) {
     35            $('#pass-strength-result').html( pwsL10n.empty );
     36            return;
     37        }
    3338
    3439        var strength = passwordStrength(pass, user);
    3540
    36         jQuery(res).removeClass('short bad good strong');
    37 
    38         if ( strength == pwsL10n.bad ) {
    39             jQuery(res).addClass('bad');
    40             jQuery(res).html( pwsL10n.bad );
     41        if ( 2 == strength )
     42            $('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
     43        else if ( 3 == strength )
     44            $('#pass-strength-result').addClass('good').html( pwsL10n.good );
     45        else if ( 4 == strength )
     46            $('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
     47        else
     48            // this catches 'Too short' and the off chance anything else comes along
     49            $('#pass-strength-result').addClass('short').html( pwsL10n.short );
     50
     51    }
     52
     53    function update_nickname () {
     54
     55        var nickname = $('#nickname').val();
     56        var display_nickname = $('#display_nickname').val();
     57
     58        if ( nickname == '' ) {
     59            $('#display_nickname').remove();
    4160        }
    42         else if ( strength == pwsL10n.good ) {
    43             jQuery(res).addClass('good');
    44             jQuery(res).html( pwsL10n.good );
    45         }
    46         else if ( strength == pwsL10n.strong ) {
    47             jQuery(res).addClass('strong');
    48             jQuery(res).html( pwsL10n.strong );
    49         }
    50         else {
    51             // this catches 'Too short' and the off chance anything else comes along
    52             jQuery(res).addClass('short');
    53             jQuery(res).html( pwsL10n.short );
    54         }
    55 
    56     }
    57 
    58     function update_nickname ( ) {
    59 
    60         var nickname = jQuery('#nickname').val();
    61         var display_nickname = jQuery('#display_nickname').val();
    62 
    63         if ( nickname == '' ) {
    64             jQuery('#display_nickname').remove();
    65         }
    66         jQuery('#display_nickname').val(nickname).html(nickname);
    67 
    68     }
    69 
    70     jQuery(function($) {
    71         $('#pass1').keyup( check_pass_strength )
     61        $('#display_nickname').val(nickname).html(nickname);
     62
     63    }
     64
     65    $(document).ready( function() {
     66        $('#pass1,#pass2').attr('autocomplete','off');
     67        $('#nickname').blur(update_nickname);
     68        $('#pass1').keyup( check_pass_strength );
    7269        $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
    73     } );
    74 
    75     jQuery(document).ready( function() {
    76         jQuery('#pass1,#pass2').attr('autocomplete','off');
    77         jQuery('#nickname').blur(update_nickname);
    7870    });
     71})(jQuery);
    7972</script>
    8073<?php
     
    350343        <?php if ( $is_profile_page ): ?>
    351344        <p><strong><?php _e('Password Strength'); ?></strong></p>
    352         <div id="pass-strength-result"><?php _e('Too short'); ?></div> <?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&amp;( in your password.'); ?>
     345        <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
     346        <p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
    353347        <?php endif; ?>
    354348    </td>
Note: See TracChangeset for help on using the changeset viewer.