window.wp=window.wp||{};
(function($){
var __=wp.i18n.__,
sprintf=wp.i18n.sprintf;
wp.passwordStrength={
meter:function(password1, disallowedList, password2){
if(! Array.isArray(disallowedList))
disallowedList=[ disallowedList.toString() ];
if(password1!=password2&&password2&&password2.length > 0)
return 5;
if('undefined'===typeof window.zxcvbn){
return -1;
}
var result=zxcvbn(password1, disallowedList);
return result.score;
},
userInputBlacklist:function(){
window.console.log(sprintf(
__('%1$s is deprecated since version %2$s! Use %3$s instead. Please consider writing more inclusive code.'),
'wp.passwordStrength.userInputBlacklist()',
'5.5.0',
'wp.passwordStrength.userInputDisallowedList()'
)
);
return wp.passwordStrength.userInputDisallowedList();
},
userInputDisallowedList:function(){
var i, userInputFieldsLength, rawValuesLength, currentField,
rawValues=[],
disallowedList=[],
userInputFields=[ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
rawValues.push(document.title);
rawValues.push(document.URL);
userInputFieldsLength=userInputFields.length;
for(i=0; i < userInputFieldsLength; i++){
currentField=$('#' + userInputFields[ i ]);
if(0===currentField.length){
continue;
}
rawValues.push(currentField[0].defaultValue);
rawValues.push(currentField.val());
}
rawValuesLength=rawValues.length;
for(i=0; i < rawValuesLength; i++){
if(rawValues[ i ]){
disallowedList=disallowedList.concat(rawValues[ i ].replace(/\W/g, ' ').split(' '));
}}
disallowedList=$.grep(disallowedList, function(value, key){
if(''===value||4 > value.length){
return false;
}
return $.inArray(value, disallowedList)===key;
});
return disallowedList;
}};
window.passwordStrength=wp.passwordStrength.meter;
})(jQuery);