56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
/**
|
|
* AI Proxy Manager — скрипты админки.
|
|
* Health-check прокси через AJAX.
|
|
*/
|
|
( function ( $ ) {
|
|
'use strict';
|
|
|
|
$( function () {
|
|
$( '.aipmsp-check-btn' ).on( 'click', function () {
|
|
var $btn = $( this );
|
|
var $result = $btn.siblings( '.aipmsp-check-result' );
|
|
|
|
var data = {
|
|
action: 'aipmsp_check_proxy',
|
|
nonce: aipmspData.nonce,
|
|
ip: $btn.data( 'ip' ),
|
|
port: $btn.data( 'port' ),
|
|
type: $btn.data( 'type' )
|
|
};
|
|
|
|
$btn.prop( 'disabled', true );
|
|
$result
|
|
.removeClass( 'aipmsp-ok aipmsp-fail' )
|
|
.addClass( 'aipmsp-pending' )
|
|
.text( aipmspData.checking );
|
|
|
|
$.post( aipmspData.ajaxUrl, data )
|
|
.done( function ( response ) {
|
|
if ( response && response.success ) {
|
|
$result
|
|
.removeClass( 'aipmsp-pending aipmsp-fail' )
|
|
.addClass( 'aipmsp-ok' )
|
|
.text( response.data.message );
|
|
} else {
|
|
var msg = response && response.data && response.data.message
|
|
? response.data.message
|
|
: 'Ошибка';
|
|
$result
|
|
.removeClass( 'aipmsp-pending aipmsp-ok' )
|
|
.addClass( 'aipmsp-fail' )
|
|
.text( msg );
|
|
}
|
|
} )
|
|
.fail( function () {
|
|
$result
|
|
.removeClass( 'aipmsp-pending aipmsp-ok' )
|
|
.addClass( 'aipmsp-fail' )
|
|
.text( 'Ошибка запроса' );
|
|
} )
|
|
.always( function () {
|
|
$btn.prop( 'disabled', false );
|
|
} );
|
|
} );
|
|
} );
|
|
} )( jQuery );
|