| 1 |
(function ($) |
| 2 |
{ |
| 3 |
'use strict'; |
| 4 |
|
| 5 |
var WP_Adminify_Error_Logs = { |
| 6 |
|
| 7 |
// AJAX request: Clear Log Data |
| 8 |
Error_Refresh: function() { |
| 9 |
|
| 10 |
$( '#adminify_error_log_refresh' ).on( |
| 11 |
'click', |
| 12 |
function (e) { |
| 13 |
e.preventDefault(); |
| 14 |
|
| 15 |
var tempLabel = $( '#adminify_error_log_refresh' ).html(); |
| 16 |
|
| 17 |
$.ajax( |
| 18 |
{ |
| 19 |
type: 'POST', |
| 20 |
dataType: 'text', |
| 21 |
async:false, |
| 22 |
url: WPAdminify_ErrorL.ajax_url, |
| 23 |
data: { |
| 24 |
action: 'jltwp_adminify_error_log_content_refresh', |
| 25 |
security: WPAdminify_ErrorL.security_nonce, |
| 26 |
command: 'refresh_error_log', |
| 27 |
}, |
| 28 |
beforeSend: function () { |
| 29 |
$( '#adminify_error_log_refresh' ).text( WPAdminify_ErrorL.label_update ); |
| 30 |
}, |
| 31 |
cache: false, |
| 32 |
success: function (data){ |
| 33 |
var refresh_content = $.parseJSON( data ); |
| 34 |
// Refresh the textarea content |
| 35 |
$( "textarea#adminify_error_log_area" ).val( refresh_content.file_content ); |
| 36 |
// // Change the button text |
| 37 |
$( '#adminify_error_log_refresh' ).html( WPAdminify_ErrorL.label_done ); |
| 38 |
|
| 39 |
// // Set button text to start text |
| 40 |
setTimeout( function () { $( '#adminify_error_log_refresh' ).html( tempLabel ); }, 1500 ); |
| 41 |
}, |
| 42 |
error: function (data){ |
| 43 |
$( '#adminify_error_log_refresh' ).html( 'ERROR' ); |
| 44 |
} |
| 45 |
} |
| 46 |
); |
| 47 |
|
| 48 |
} |
| 49 |
); |
| 50 |
}, |
| 51 |
|
| 52 |
// AJAX request: Clear Log Data |
| 53 |
Error_Clear_Logs: function(){ |
| 54 |
|
| 55 |
$( '#adminify_error_log_clear' ).on( |
| 56 |
'click', |
| 57 |
function (e) { |
| 58 |
e.preventDefault(); |
| 59 |
|
| 60 |
var tempLabel = $( '#adminify_error_log_clear' ).html(); |
| 61 |
|
| 62 |
$.ajax( |
| 63 |
{ |
| 64 |
type: 'POST', |
| 65 |
dataType: 'text', |
| 66 |
async:false, |
| 67 |
url: WPAdminify_ErrorL.ajax_url, |
| 68 |
data: { |
| 69 |
action: 'jltwp_adminify_error_log_content_clear', |
| 70 |
security: WPAdminify_ErrorL.security_nonce, |
| 71 |
command: 'clear_error_log', |
| 72 |
}, |
| 73 |
beforeSend: function () { |
| 74 |
// Clearing button text |
| 75 |
$( '#adminify_error_log_clear' ).html( WPAdminify_ErrorL.label_clear ); |
| 76 |
}, |
| 77 |
cache: false, |
| 78 |
success: function (data) { |
| 79 |
// Refresh the textarea content |
| 80 |
$( "textarea#adminify_error_log_area" ).val( data.file_content ); |
| 81 |
|
| 82 |
// Change the button text |
| 83 |
$( '#adminify_error_log_clear' ).html( WPAdminify_ErrorL.label_done ); |
| 84 |
|
| 85 |
// Set button text to start text |
| 86 |
setTimeout( function () { $( '#adminify_error_log_clear' ).html( tempLabel ); }, 1500 ); |
| 87 |
}, |
| 88 |
error: function (data) { |
| 89 |
$( '#adminify_error_log_clear' ).html( 'ERROR' ); |
| 90 |
} |
| 91 |
} |
| 92 |
); |
| 93 |
|
| 94 |
} |
| 95 |
); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
// Documents Loaded |
| 100 |
$( document ).ready( |
| 101 |
function() { |
| 102 |
WP_Adminify_Error_Logs.Error_Refresh(); |
| 103 |
WP_Adminify_Error_Logs.Error_Clear_Logs(); |
| 104 |
} |
| 105 |
); |
| 106 |
|
| 107 |
})( jQuery ); |
| 108 |
|