<!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>[15780] trunk: move password-strength-meter.js into user-profile.js.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15780">15780</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-10-12 20:29:19 +0000 (Tue, 12 Oct 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>move password-strength-meter.js into user-profile.js. See <a href="http://trac.wordpress.org/ticket/5919">#5919</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmininstallphp">trunk/wp-admin/install.php</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="#trunkwpadminusereditphp">trunk/wp-admin/user-edit.php</a></li>
<li><a href="#trunkwpadminusernewphp">trunk/wp-admin/user-new.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
<li><a href="#trunkwploginphp">trunk/wp-login.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmininstallphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/install.php (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/install.php        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/install.php        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -244,7 +244,6 @@
</span><span class="cx"> ?>
</span><span class="cx"> <script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
</span><span class="cx"> <script type="text/javascript" src="../wp-includes/js/jquery/jquery.js"></script>
</span><del>-<script type="text/javascript" src="js/password-strength-meter.js"></script>
</del><span class="cx"> <script type="text/javascript" src="js/user-profile.js"></script>
</span><span class="cx"> <script type="text/javascript" src="js/utils.js"></script>
</span><span class="cx"> <script type='text/javascript'>
</span></span></pre></div>
<a id="trunkwpadminjspasswordstrengthmeterdevjs"></a>
<div class="delfile"><h4>Deleted: trunk/wp-admin/js/password-strength-meter.dev.js (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/password-strength-meter.dev.js        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/js/password-strength-meter.dev.js        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -1,36 +0,0 @@
</span><del>-// Password strength meter
-function passwordStrength(password1, username, password2) {
-        var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
-
-        // password 1 != password 2
-        if ( (password1 != password2) && password2.length > 0)
-                return mismatch
-
-        //password < 4
-        if ( password1.length < 4 )
-                return shortPass
-
-        //password1 == username
-        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;
-}
</del></span></pre></div>
<a id="trunkwpadminjspasswordstrengthmeterjs"></a>
<div class="delfile"><h4>Deleted: trunk/wp-admin/js/password-strength-meter.js (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/password-strength-meter.js        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/js/password-strength-meter.js        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -1 +0,0 @@
</span><del>-function passwordStrength(f,i,d){var k=1,h=2,b=3,a=4,c=5,g=0,j,e;if((f!=d)&&d.length>0){return c}if(f.length<4){return k}if(f.toLowerCase()==i.toLowerCase()){return h}if(f.match(/[0-9]/)){g+=10}if(f.match(/[a-z]/)){g+=26}if(f.match(/[A-Z]/)){g+=26}if(f.match(/[^a-zA-Z0-9]/)){g+=31}j=Math.log(Math.pow(g,f.length));e=j/Math.LN2;if(e<40){return h}if(e<56){return b}return a};
</del><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 (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.dev.js        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/js/user-profile.dev.js        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -1,5 +1,41 @@
</span><span class="cx"> (function($){
</span><span class="cx">
</span><ins>+        function passwordStrength(password1, username, password2) {
+                var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
+
+                // password 1 != password 2
+                if ( (password1 != password2) && password2.length > 0)
+                        return mismatch
+
+                //password < 4
+                if ( password1.length < 4 )
+                        return shortPass
+
+                //password1 == username
+                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">         function check_pass_strength() {
</span><span class="cx">                 var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminjsuserprofilejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/user-profile.js (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.js        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/js/user-profile.js        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(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);
</del><span class="cx">\ No newline at end of file
</span><ins>+(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);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminusereditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-edit.php (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-edit.php        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/user-edit.php        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx">         wp_die( __('Invalid user ID.') );
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script('user-profile');
</span><del>-wp_enqueue_script('password-strength-meter');
</del><span class="cx">
</span><span class="cx"> $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
</span><span class="cx"> if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
</span></span></pre></div>
<a id="trunkwpadminusernewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-new.php (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-new.php        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-admin/user-new.php        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -128,7 +128,6 @@
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script('wp-ajax-response');
</span><span class="cx"> wp_enqueue_script('user-profile');
</span><del>-wp_enqueue_script('password-strength-meter');
</del><span class="cx">
</span><span class="cx"> require_once ('admin-header.php');
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-includes/script-loader.php        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -261,9 +261,9 @@
</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'), '20100331' );
-                $scripts->add_data( 'password-strength-meter', 'group', 1 );
-                $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
</del><ins>+                $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20101012' );
+                $scripts->add_data( 'user-profile', 'group', 1 );
+                $scripts->localize( 'user-profile', 'pwsL10n', array(
</ins><span class="cx">                         'empty' => __('Strength indicator'),
</span><span class="cx">                         'short' => __('Very weak'),
</span><span class="cx">                         'bad' => __('Weak'),
</span><span class="lines">@@ -274,9 +274,6 @@
</span><span class="cx">                         'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
</span><span class="cx">                 ) );
</span><span class="cx">
</span><del>-                $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20100925' );
-                $scripts->add_data( 'user-profile', 'group', 1 );
-
</del><span class="cx">                 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'list-table', 'jquery-ui-resizable', 'quicktags'), '20100818' );
</span><span class="cx">                 $scripts->add_data( 'admin-comments', 'group', 1 );
</span><span class="cx">                 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
</span></span></pre></div>
<a id="trunkwploginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-login.php (15779 => 15780)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-login.php        2010-10-12 19:43:54 UTC (rev 15779)
+++ trunk/wp-login.php        2010-10-12 20:29:19 UTC (rev 15780)
</span><span class="lines">@@ -334,6 +334,28 @@
</span><span class="cx">         return $user_id;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// TODO: Eliminate duplicated code from wp_default_scripts()
+function load_password_strength_meter() {
+        if ( !$guessurl = site_url() )
+                $guessurl = wp_guess_url();
+
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
+
+        wp_enqueue_script( 'password-strength-meter', $guessurl . "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20100331' );
+        wp_localize_script( 'password-strength-meter', 'pwsL10n', array(
+                'empty' => __('Strength indicator'),
+                'short' => __('Very weak'),
+                'bad' => __('Weak'),
+                /* translators: password strength */
+                'good' => _x('Medium', 'password strength'),
+                'strong' => __('Strong'),
+                'mismatch' => __('Mismatch'),
+                'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
+        ) );
+
+        wp_print_scripts( array('password-strength-meter') );
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Main
</span><span class="cx"> //
</span><span class="lines">@@ -384,6 +406,7 @@
</span><span class="cx">
</span><span class="cx"> case 'lostpassword' :
</span><span class="cx"> case 'retrievepassword' :
</span><ins>+
</ins><span class="cx">         if ( $http_post ) {
</span><span class="cx">                 $errors = retrieve_password();
</span><span class="cx">                 if ( !is_wp_error($errors) ) {
</span><span class="lines">@@ -445,6 +468,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Reset your password') . '</p>', $errors );
</span><ins>+
+        load_password_strength_meter();
+
</ins><span class="cx"> ?>
</span><span class="cx"> <form name="resetpassform" id="resetpassform" action="<?php echo site_url('wp-login.php?action=resetpass&key=' . urlencode($_GET['key']) . '&login=' . urlencode($_GET['login']), 'login_post') ?>" method="post">
</span><span class="cx">         <p>
</span><span class="lines">@@ -455,6 +481,10 @@
</span><span class="cx">                 <label><?php _e('New Password Again') ?><br />
</span><span class="cx">                 <input type="password" name="pass2" id="user_pass" class="input" size="20" value="" autocomplete="off" /></label>
</span><span class="cx">         </p>
</span><ins>+
+        <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
+        <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+
</ins><span class="cx">         <br class="clear" />
</span><span class="cx">         <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Reset Password'); ?>" tabindex="100" /></p>
</span><span class="cx"> </form>
</span></span></pre>
</div>
</div>
</body>
</html>