Make WordPress Core

Changeset 42528


Ignore:
Timestamp:
01/18/2018 01:38:26 PM (9 years ago)
Author:
atimmer
Message:

Docs: Improve JSDoc for password-strength-meter.js.

Props herregroen, carolinegeven, ireneyoast, jjcomack.
Fixes #43066.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/password-strength-meter.js

    r37940 r42528  
    44var passwordStrength;
    55(function($){
     6
     7        /**
     8         * Contains functions to determine the password strength.
     9         *
     10         * @since 3.7.0
     11         *
     12         * @namespace
     13         */
    614        wp.passwordStrength = {
    715                /**
    8                  * Determine the strength of a given password
     16                 * Determines the strength of a given password.
    917                 *
    10                  * @param string password1 The password
    11                  * @param array blacklist An array of words that will lower the entropy of the password
    12                  * @param string password2 The confirmed password
     18                 * Compares first password to the password confirmation.
     19                 *
     20                 * @since 3.7.0
     21                 *
     22                 * @param {string} password1 The subject password.
     23                 * @param {Array}  blacklist An array of words that will lower the entropy of
     24                 *                           the password.
     25                 * @param {string} password2 The password confirmation.
     26                 *
     27                 * @returns {number} The password strength score.
    1328                 */
    1429                meter : function( password1, blacklist, password2 ) {
     
    2944
    3045                /**
    31                  * Builds an array of data that should be penalized, because it would lower the entropy of a password if it were used
     46                 * Builds an array of words that should be penalized.
    3247                 *
    33                  * @return array The array of data to be blacklisted
     48                 * Certain words need to be penalized because it would lower the entropy of a
     49                 * password if they were used. The blacklist is based on user input fields such
     50                 * as username, first name, email etc.
     51                 *
     52                 * @since 3.7.0
     53                 *
     54                 * @returns {string[]} The array of words to be blacklisted.
    3455                 */
    3556                userInputBlacklist : function() {
     
    3960                                userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
    4061
    41                         // Collect all the strings we want to blacklist
     62                        // Collect all the strings we want to blacklist.
    4263                        rawValues.push( document.title );
    4364                        rawValues.push( document.URL );
     
    5576                        }
    5677
    57                         // Strip out non-alphanumeric characters and convert each word to an individual entry
     78                        /*
     79                         * Strip out non-alphanumeric characters and convert each word to an
     80                         * individual entry.
     81                         */
    5882                        rawValuesLength = rawValues.length;
    5983                        for ( i = 0; i < rawValuesLength; i++ ) {
     
    6387                        }
    6488
    65                         // Remove empty values, short words, and duplicates. Short words are likely to cause many false positives.
     89                        /*
     90                         * Remove empty values, short words and duplicates. Short words are likely to
     91                         * cause many false positives.
     92                         */
    6693                        blacklist = $.grep( blacklist, function( value, key ) {
    6794                                if ( '' === value || 4 > value.length ) {
     
    76103        };
    77104
    78         // Back-compat.
     105        // Backward compatibility.
     106
     107        /**
     108         * Password strength meter function.
     109         *
     110         * @since 2.5.0
     111         * @deprecated 3.7.0 Use wp.passwordStrength.meter instead.
     112         *
     113         * @global
     114         *
     115         * @type {wp.passwordStrength.meter}
     116         */
    79117        passwordStrength = wp.passwordStrength.meter;
    80118})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.