WordPress.org

Make WordPress Core

Changeset 15998


Ignore:
Timestamp:
10/27/2010 06:39:20 AM (11 years ago)
Author:
westi
Message:

Bring back a seperate js file for the password strength meter and correctly mark it as a dependancy of the user profile code. See #5919.

Location:
trunk
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/install.php

    r15780 r15998  
    245245<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
    246246<script type="text/javascript" src="../wp-includes/js/jquery/jquery.js"></script>
     247<script type="text/javascript" src="js/password-strength-meter.js"></script>
    247248<script type="text/javascript" src="js/user-profile.js"></script>
    248249<script type="text/javascript" src="js/utils.js"></script>
  • trunk/wp-admin/js/user-profile.dev.js

    r15780 r15998  
    11(function($){
    2 
    3     function passwordStrength(password1, username, password2) {
    4         var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
    5 
    6         // password 1 != password 2
    7         if ( (password1 != password2) && password2.length > 0)
    8             return mismatch
    9 
    10         //password < 4
    11         if ( password1.length < 4 )
    12             return shortPass
    13 
    14         //password1 == username
    15         if ( password1.toLowerCase() == username.toLowerCase() )
    16             return badPass;
    17 
    18         if ( password1.match(/[0-9]/) )
    19             symbolSize +=10;
    20         if ( password1.match(/[a-z]/) )
    21             symbolSize +=26;
    22         if ( password1.match(/[A-Z]/) )
    23             symbolSize +=26;
    24         if ( password1.match(/[^a-zA-Z0-9]/) )
    25             symbolSize +=31;
    26 
    27         natLog = Math.log( Math.pow(symbolSize, password1.length) );
    28         score = natLog / Math.LN2;
    29 
    30         if (score < 40 )
    31             return badPass
    32 
    33         if (score < 56 )
    34             return goodPass
    35 
    36         return strongPass;
    37     }
    382
    393    function check_pass_strength() {
  • trunk/wp-admin/js/user-profile.js

    r15780 r15998  
    1 (function(b){function a(i,l,g){var n=1,k=2,e=3,d=4,f=5,j=0,m,h;if((i!=g)&&g.length>0){return f}if(i.length<4){return n}if(i.toLowerCase()==l.toLowerCase()){return k}if(i.match(/[0-9]/)){j+=10}if(i.match(/[a-z]/)){j+=26}if(i.match(/[A-Z]/)){j+=26}if(i.match(/[^a-zA-Z0-9]/)){j+=31}m=Math.log(Math.pow(j,i.length));h=m/Math.LN2;if(h<40){return k}if(h<56){return e}return d}function c(){var f=b("#pass1").val(),e=b("#user_login").val(),d=b("#pass2").val(),g;b("#pass-strength-result").removeClass("short bad good strong");if(!f){b("#pass-strength-result").html(pwsL10n.empty);return}g=a(f,e,d);switch(g){case 2:b("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:b("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:b("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:b("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:b("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}b(document).ready(function(){b("#pass1").val("").keyup(c);b("#pass2").val("").keyup(c);b("#pass-strength-result").show();b(".color-palette").click(function(){b(this).siblings("input[name=admin_color]").attr("checked","checked")});b("#nickname").blur(function(){var f=b(this).val()||b("#user_login").val();var d=b("#display_name");var e=d.children("option:selected").attr("id");d.children("#display_nickname").remove();if(!d.children("option[value="+f+"]").length){d.append('<option id="display_nickname" value="'+f+'">'+f+"</option>")}b("#"+e).attr("selected","selected")});b("#first_name, #last_name").blur(function(){var d=b("#display_name");var g=b("#first_name").val(),e=b("#last_name").val();var f=d.children("option:selected").attr("id");b("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(g&&!d.children("option[value="+g+"]").length){d.append('<option id="display_firstname" value="'+g+'">'+g+"</option>")}if(e&&!d.children("option[value="+e+"]").length){d.append('<option id="display_lastname" value="'+e+'">'+e+"</option>")}if(g&&e){if(!d.children("option[value="+g+" "+e+"]").length){d.append('<option id="display_firstlast" value="'+g+" "+e+'">'+g+" "+e+"</option>")}if(!d.children("option[value="+e+" "+g+"]").length){d.append('<option id="display_lastfirst" value="'+e+" "+g+'">'+e+" "+g+"</option>")}}b("#"+f).attr("selected","selected")})})})(jQuery);
     1(function($){function check_pass_strength(){var pass1=$("#pass1").val(),user=$("#user_login").val(),pass2=$("#pass2").val(),strength;$("#pass-strength-result").removeClass("short bad good strong");if(!pass1){$("#pass-strength-result").html(pwsL10n.empty);return}strength=passwordStrength(pass1,user,pass2);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;case 5:$("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:$("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}$(document).ready(function(){$("#pass1").val("").keyup(check_pass_strength);$("#pass2").val("").keyup(check_pass_strength);$("#pass-strength-result").show();$(".color-palette").click(function(){$(this).siblings("input[name=admin_color]").attr("checked","checked")});$("#nickname").blur(function(){var str=$(this).val()||$("#user_login").val();var select=$("#display_name");var sel=select.children("option:selected").attr("id");select.children("#display_nickname").remove();if(!select.children("option[value="+str+"]").length){select.append('<option id="display_nickname" value="'+str+'">'+str+"</option>")}$("#"+sel).attr("selected","selected")});$("#first_name, #last_name").blur(function(){var select=$("#display_name");var first=$("#first_name").val(),last=$("#last_name").val();var sel=select.children("option:selected").attr("id");$("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(first&&!select.children("option[value="+first+"]").length){select.append('<option id="display_firstname" value="'+first+'">'+first+"</option>")}if(last&&!select.children("option[value="+last+"]").length){select.append('<option id="display_lastname" value="'+last+'">'+last+"</option>")}if(first&&last){if(!select.children("option[value="+first+" "+last+"]").length){select.append('<option id="display_firstlast" value="'+first+" "+last+'">'+first+" "+last+"</option>")}if(!select.children("option[value="+last+" "+first+"]").length){select.append('<option id="display_lastfirst" value="'+last+" "+first+'">'+last+" "+first+"</option>")}}$("#"+sel).attr("selected","selected")})})})(jQuery);
  • trunk/wp-includes/script-loader.php

    r15986 r15998  
    263263        $scripts->add_data( 'admin-custom-fields', 'group', 1 );
    264264
    265         $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20101012' );
    266         $scripts->add_data( 'user-profile', 'group', 1 );
    267         $scripts->localize( 'user-profile', 'pwsL10n', array(
     265        $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
     266        $scripts->add_data( 'password-strength-meter', 'group', 1 );
     267        $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
    268268            'empty' => __('Strength indicator'),
    269269            'short' => __('Very weak'),
     
    275275            'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
    276276        ) );
     277
     278        $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20100925' );
     279        $scripts->add_data( 'user-profile', 'group', 1 );
    277280
    278281        $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'list-table', 'jquery-ui-resizable', 'quicktags'), '20100818' );
  • trunk/wp-login.php

    r15904 r15998  
    342342    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
    343343
    344     wp_enqueue_script( 'user-profile', $guessurl . "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20100331' );
    345     wp_localize_script( 'user-profile', 'pwsL10n', array(
     344    wp_enqueue_script( 'user-profile', $guessurl . "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20100925' );
     345    wp_enqueue_script( 'password-strength-meter', $guessurl . "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
     346    wp_localize_script( 'password-strength-meter', 'pwsL10n', array(
    346347        'empty' => __('Strength indicator'),
    347348        'short' => __('Very weak'),
Note: See TracChangeset for help on using the changeset viewer.