script.js
82 lines
| 1 | jQuery(document).ready(function($){ |
| 2 | $('#button-purge').on('click', function(e) { |
| 3 | if (!confirm('WARNING: All data will be permanently deleted from the local storage (WordPress), and this action is not reversible. Are you sure you want to proceed with the deletion?')) { |
| 4 | e.preventDefault(); |
| 5 | } else { |
| 6 | $('#form-purge').submit(); |
| 7 | } |
| 8 | }); |
| 9 | |
| 10 | $('#validation_sequence').on('click', function() { |
| 11 | if ($('#validation_sequence').val() == 'after') { |
| 12 | $('#enable_wc_advanced_velocity').prop('disabled', true); |
| 13 | $('#fraud_message').prop('disabled', true); |
| 14 | $('#approve_status').prop('disabled', false); |
| 15 | $('#review_status').prop('disabled', false); |
| 16 | $('#db_err_status').prop('disabled', false); |
| 17 | } else { |
| 18 | $('#enable_wc_advanced_velocity').prop('disabled', false); |
| 19 | $('#fraud_message').prop('disabled', false); |
| 20 | $('#approve_status').prop('disabled', true); |
| 21 | $('#review_status').prop('disabled', true); |
| 22 | $('#db_err_status').prop('disabled', true); |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | $('#enable_wc_fraudlabspro_debug_log').on('click', function() { |
| 27 | if(!$('#enable_wc_fraudlabspro_debug_log').is(':checked')) { |
| 28 | $('#wc_fraudlabspro_debug_log_path').prop('disabled', true); |
| 29 | } else { |
| 30 | $('#wc_fraudlabspro_debug_log_path').prop('disabled', false); |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | $('.dismiss-button').on('click', function(e) { |
| 35 | $('#modal-step-1').css('display', 'none'); |
| 36 | }); |
| 37 | |
| 38 | $('#setup_flp_key').on('input', function() { |
| 39 | $('#btn-to-step-2').prop('disabled', !($(this).val().length == 32)); |
| 40 | }); |
| 41 | |
| 42 | $('#btn-to-step-2').on('click', function(e) { |
| 43 | e.preventDefault(); |
| 44 | |
| 45 | $('#modal-step-1').css('display', 'none'); |
| 46 | $('#modal-step-2').css('display', 'block'); |
| 47 | |
| 48 | var $btn = $(this); |
| 49 | |
| 50 | $('#fraudlabs_pro_key_validation_status').html('<span class="dashicons dashicons-update spin"></span> Validating API Key...'); |
| 51 | $btn.prop('disabled', true); |
| 52 | |
| 53 | $.post(ajaxurl, { action: 'fraudlabspro_woocommerce_validate_api_key', token: $('#setup_flp_key').val() }, function(response) { |
| 54 | if (response.indexOf("SUCCESS") == 0) { |
| 55 | $('#btn-to-step-3').prop('disabled', false); |
| 56 | $('#fraudlabs_pro_key_validation_status').html('<span class="dashicons dashicons-yes-alt" style="color:green;"></span> You are currently subscribed to a ' + response.substr(8) + ' Plan.</p></div>'); |
| 57 | } else { |
| 58 | $('#btn-to-step-1').prop('disabled', false); |
| 59 | $('#fraudlabs_pro_key_validation_status').html('<span class="dashicons dashicons-warning" style="color:red;"></span> Invalid API Key. Please click on <strong>« Previous</strong> button to re-enter the API Key.'); |
| 60 | } |
| 61 | }) |
| 62 | .error(function() { |
| 63 | $('#fraudlabs_pro_key_validation_status').html('<span class="dashicons dashicons-warning" style="color:red;"></span> Validation skipped. Unable to validate the API Key.'); |
| 64 | $('#btn-to-step-3').prop('disabled', false); |
| 65 | }) |
| 66 | .always(function() { |
| 67 | }); |
| 68 | }); |
| 69 | |
| 70 | $('#btn-to-step-1').on('click', function(e) { |
| 71 | e.preventDefault(); |
| 72 | |
| 73 | $('#modal-step-1').css('display', 'block'); |
| 74 | $('#modal-step-2').css('display', 'none'); |
| 75 | $('#btn-to-step-2').prop('disabled', false); |
| 76 | }); |
| 77 | |
| 78 | $('#btn-to-step-3').on('click', function() { |
| 79 | $('#modal-step-2').css('display', 'none'); |
| 80 | $('#modal-step-3').css('display', 'block'); |
| 81 | }); |
| 82 | }); |