<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13900] trunk:
Add Password Mismatch feedback to the Password Strength Meter.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13900">13900</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-31 08:45:51 +0000 (Wed, 31 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add Password Mismatch feedback to the Password Strength Meter. Props dancole. Fixes <a href="http://trac.wordpress.org/ticket/12576">#12576</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmininstallphp">trunk/wp-admin/install.php</a></li>
<li><a href="#trunkwpadminjspasswordstrengthmeterdevjs">trunk/wp-admin/js/password-strength-meter.dev.js</a></li>
<li><a href="#trunkwpadminjspasswordstrengthmeterjs">trunk/wp-admin/js/password-strength-meter.js</a></li>
<li><a href="#trunkwpadminjsuserprofiledevjs">trunk/wp-admin/js/user-profile.dev.js</a></li>
<li><a href="#trunkwpadminjsuserprofilejs">trunk/wp-admin/js/user-profile.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/install.php (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/install.php        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-admin/install.php        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -249,7 +249,8 @@
</span><span class="cx"> short: "<?php echo esc_js( __( 'Very weak' ) ); ?>",
</span><span class="cx"> bad: "<?php echo esc_js( __( 'Weak' ) ); ?>",
</span><span class="cx"> good: "<?php echo esc_js( __( 'Medium' ) ); ?>",
</span><del>- strong: "<?php echo esc_js( __( 'Strong' ) ); ?>"
</del><ins>+ strong: "<?php echo esc_js( __( 'Strong' ) ); ?>",
+ mismatch: "<?php echo esc_js( __( 'Mismatch' ) ); ?>"
</ins><span class="cx"> };
</span><span class="cx"> try{convertEntities(pwsL10n);}catch(e){};
</span><span class="cx"> /* ]]> */
</span></span></pre></div>
<a id="trunkwpadminjspasswordstrengthmeterdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/password-strength-meter.dev.js (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/password-strength-meter.dev.js        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-admin/js/password-strength-meter.dev.js        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -1,21 +1,36 @@
</span><span class="cx"> // Password strength meter
</span><del>-function passwordStrength(password,username) {
- var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, symbolSize = 0, natLog, score;
</del><ins>+function passwordStrength(password1, username, password2) {
+        var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
</ins><span class="cx">
</span><ins>+        // password 1 != password 2
+        if ( (password1 != password2) && password2.length > 0)
+                return mismatch
+
</ins><span class="cx">         //password < 4
</span><del>- if (password.length < 4 ) { return shortPass };
</del><ins>+        if ( password1.length < 4 )
+                return shortPass
</ins><span class="cx">
</span><del>- //password == username
- if (password.toLowerCase()==username.toLowerCase()) return badPass;
</del><ins>+        //password1 == username
+        if ( password1.toLowerCase() == username.toLowerCase() )
+                return badPass;
</ins><span class="cx">
</span><del>-        if (password.match(/[0-9]/)) symbolSize +=10;
-        if (password.match(/[a-z]/)) symbolSize +=26;
-        if (password.match(/[A-Z]/)) symbolSize +=26;
-        if (password.match(/[^a-zA-Z0-9]/)) symbolSize +=31;
</del><ins>+        if ( password1.match(/[0-9]/) )
+                symbolSize +=10;
+        if ( password1.match(/[a-z]/) )
+                symbolSize +=26;
+        if ( password1.match(/[A-Z]/) )
+                symbolSize +=26;
+        if ( password1.match(/[^a-zA-Z0-9]/) )
+                symbolSize +=31;
</ins><span class="cx">
</span><del>-        natLog = Math.log( Math.pow(symbolSize,password.length) );
</del><ins>+        natLog = Math.log( Math.pow(symbolSize, password1.length) );
</ins><span class="cx">         score = natLog / Math.LN2;
</span><del>-        if (score < 40 ) return badPass
-        if (score < 56 ) return goodPass
</del><ins>+
+        if (score < 40 )
+                return badPass
+
+        if (score < 56 )
+                return goodPass
+
</ins><span class="cx"> return strongPass;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminjspasswordstrengthmeterjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/password-strength-meter.js (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/password-strength-meter.js        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-admin/js/password-strength-meter.js        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -1 +1 @@
</span><del>-function passwordStrength(i,f){var h=1,e=2,b=3,a=4,d=0,g,c;if(i.length<4){return h}if(i.toLowerCase()==f.toLowerCase()){return e}if(i.match(/[0-9]/)){d+=10}if(i.match(/[a-z]/)){d+=26}if(i.match(/[A-Z]/)){d+=26}if(i.match(/[^a-zA-Z0-9]/)){d+=31}g=Math.log(Math.pow(d,i.length));c=g/Math.LN2;if(c<40){return e}if(c<56){return b}return a};
</del><span class="cx">\ No newline at end of file
</span><ins>+function passwordStrength(password1,username,password2){var shortPass=1,badPass=2,goodPass=3,strongPass=4,mismatch=5,symbolSize=0,natLog,score;if((password1!=password2)&&password2.length>0){return mismatch}if(password1.length<4){return shortPass}if(password1.toLowerCase()==username.toLowerCase()){return badPass}if(password1.match(/[0-9]/)){symbolSize+=10}if(password1.match(/[a-z]/)){symbolSize+=26}if(password1.match(/[A-Z]/)){symbolSize+=26}if(password1.match(/[^a-zA-Z0-9]/)){symbolSize+=31}natLog=Math.log(Math.pow(symbolSize,password1.length));score=natLog/Math.LN2;if(score<40){return badPass}if(score<56){return goodPass}return strongPass};
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminjsuserprofiledevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/user-profile.dev.js (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.dev.js        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-admin/js/user-profile.dev.js        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -1,15 +1,15 @@
</span><span class="cx"> (function($){
</span><span class="cx">
</span><span class="cx">         function check_pass_strength() {
</span><del>-                var pass = $('#pass1').val(), user = $('#user_login').val(), strength;
</del><ins>+                var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
</ins><span class="cx">
</span><span class="cx">                 $('#pass-strength-result').removeClass('short bad good strong');
</span><del>-                if ( ! pass ) {
</del><ins>+                if ( ! pass1 ) {
</ins><span class="cx">                         $('#pass-strength-result').html( pwsL10n.empty );
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                strength = passwordStrength(pass, user);
</del><ins>+                strength = passwordStrength(pass1, user, pass2);
</ins><span class="cx">
</span><span class="cx">                 switch ( strength ) {
</span><span class="cx">                         case 2:
</span><span class="lines">@@ -21,6 +21,9 @@
</span><span class="cx">                         case 4:
</span><span class="cx">                                 $('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
</span><span class="cx">                                 break;
</span><ins>+                        case 5:
+                                $('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
+                                break;
</ins><span class="cx">                         default:
</span><span class="cx">                                 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
</span><span class="cx">                 }
</span><span class="lines">@@ -28,6 +31,7 @@
</span><span class="cx">
</span><span class="cx">         $(document).ready( function() {
</span><span class="cx">                 $('#pass1').val('').keyup( check_pass_strength );
</span><ins>+                $('#pass2').val('').keyup( check_pass_strength );
</ins><span class="cx">                 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
</span><span class="cx">                 $('#nickname').blur(function(){
</span><span class="cx">                         var str = $(this).val() || $('#user_login').val();
</span></span></pre></div>
<a id="trunkwpadminjsuserprofilejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/user-profile.js (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.js        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-admin/js/user-profile.js        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(a){function b(){var d=a("#pass1").val(),c=a("#user_login").val(),e;a("#pass-strength-result").removeClass("short bad good strong");if(!d){a("#pass-strength-result").html(pwsL10n.empty);return}e=passwordStrength(d,c);switch(e){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+(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);$(".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);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (13899 => 13900)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-03-31 08:20:28 UTC (rev 13899)
+++ trunk/wp-includes/script-loader.php        2010-03-31 08:45:51 UTC (rev 13900)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">                 $scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
</span><span class="cx">                 $scripts->add_data( 'admin-custom-fields', 'group', 1 );
</span><span class="cx">
</span><del>-                $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20090102' );
</del><ins>+                $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20100331' );
</ins><span class="cx">                 $scripts->add_data( 'password-strength-meter', 'group', 1 );
</span><span class="cx">                 $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
</span><span class="cx">                         'empty' => __('Strength indicator'),
</span><span class="lines">@@ -260,6 +260,7 @@
</span><span class="cx">                         /* translators: password strength */
</span><span class="cx">                         'good' => _x('Medium', 'password strength'),
</span><span class="cx">                         'strong' => __('Strong'),
</span><ins>+                        'mismatch' => __('Mismatch'),
</ins><span class="cx">                         'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
</span><span class="cx">                 ) );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>