+if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
+ $is_profile_page = true;
+else
+ $is_profile_page = false;
+
+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 == pwsL10n.bad ) {
+ jQuery(res).addClass('bad');
+ jQuery(res).html( pwsL10n.bad );
+ }
+ else if ( strength == pwsL10n.good ) {
+ jQuery(res).addClass('good');
+ jQuery(res).html( pwsL10n.good );
+ }
+ else if ( strength == pwsL10n.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 );
+ }
+
+ }
+
+ function update_nickname ( ) {
+
+ var nickname = jQuery('#nickname').val();
+ var display_nickname = jQuery('#display_nickname').val();
+
+ if ( nickname == '' ) {
+ jQuery('#display_nickname').remove();
+ }
+ jQuery('#display_nickname').val(nickname).html(nickname);
+
+ }
+
+ jQuery(function($) {
+ $('#pass1').keyup( check_pass_strength )
+ $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
+ } );
+
+ jQuery(document).ready( function() {
+ jQuery('#pass1,#pass2').attr('autocomplete','off');
+ jQuery('#nickname').blur(update_nickname);
+ });
+</script>
+<?php
+}
+
+if ( $is_profile_page ) {
+ add_action('admin_head', 'profile_js');
+ wp_enqueue_script('jquery');
+ wp_enqueue_script('password-strength-meter');
+}
+
+$title = $is_profile_page? __('Profile') : __('Edit User');
+if ( current_user_can('edit_users') && !$is_profile_page )
+ $submenu_file = 'users.php';