| 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('click', function (e) { |
| 11 |
e.preventDefault(); |
| 12 |
|
| 13 |
var tempLabel = $('#adminify_error_log_refresh').html(), |
| 14 |
jsonObjects = [{ command: 'refresh_error_log' }], |
| 15 |
jsonData = JSON.stringify(jsonObjects); |
| 16 |
|
| 17 |
|
| 18 |
$.ajax({ |
| 19 |
type: 'POST', |
| 20 |
dataType: 'text', |
| 21 |
async:false, |
| 22 |
url: WPAdminify.ajax_url, |
| 23 |
data: { |
| 24 |
action: 'jltwp_adminify_error_log_content_refresh', |
| 25 |
security: WPAdminify.security_nonce, |
| 26 |
fileData: jsonData, |
| 27 |
}, |
| 28 |
beforeSend: function () { |
| 29 |
$('#adminify_error_log_refresh').text(WPAdminify.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.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 |
// AJAX request: Clear Log Data |
| 52 |
Error_Clear_Logs: function(){ |
| 53 |
|
| 54 |
$('#adminify_error_log_clear').on('click', function (e) { |
| 55 |
e.preventDefault(); |
| 56 |
|
| 57 |
var tempLabel = $('#adminify_error_log_clear').html(), |
| 58 |
jsonObjects = [{ command: 'clear_error_log', }], |
| 59 |
jsonData = JSON.stringify(jsonObjects); |
| 60 |
|
| 61 |
$.ajax({ |
| 62 |
type: 'POST', |
| 63 |
dataType: 'text', |
| 64 |
async:false, |
| 65 |
url: WPAdminify.ajax_url, |
| 66 |
data: { |
| 67 |
action: 'jltwp_adminify_error_log_content_clear', |
| 68 |
security: WPAdminify.security_nonce, |
| 69 |
fileData: jsonData, |
| 70 |
}, |
| 71 |
beforeSend: function () { |
| 72 |
// Clearing button text |
| 73 |
$('#adminify_error_log_clear').html(WPAdminify.label_clear); |
| 74 |
}, |
| 75 |
cache: false, |
| 76 |
success: function (data) { |
| 77 |
// Refresh the textarea content |
| 78 |
$("textarea#adminify_error_log_area").val(data.file_content); |
| 79 |
|
| 80 |
// Change the button text |
| 81 |
$('#adminify_error_log_clear').html(WPAdminify.label_done); |
| 82 |
|
| 83 |
// Set button text to start text |
| 84 |
setTimeout(function () { $('#adminify_error_log_clear').html(tempLabel); }, 1500); |
| 85 |
}, |
| 86 |
error: function (data) { |
| 87 |
$('#adminify_error_log_clear').html('ERROR'); |
| 88 |
} |
| 89 |
}); |
| 90 |
|
| 91 |
}); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
// Documents Loaded |
| 96 |
$( document ).ready(function() { |
| 97 |
WP_Adminify_Error_Logs.Error_Refresh(); |
| 98 |
WP_Adminify_Error_Logs.Error_Clear_Logs(); |
| 99 |
}); |
| 100 |
|
| 101 |
|
| 102 |
})(jQuery); |
| 103 |
|