| @@ -21,32 +21,48 @@ | ||
| 21 | 21 | plugin.bindEvents = function() { |
| 22 | 22 | $('input#patchstack-activate').on( 'click', function(e) { |
| 23 | 23 | e.preventDefault(); |
| 24 | 24 | var postData = { |
| 25 | - action: 'activate_license', | |
| 26 | - clientid: $( '#patchstack_api_client_id' ).val(), | |
| 27 | - secretkey: $( '#patchstack_api_client_secret_key' ).val(), | |
| 25 | + action: 'patchstack_activate_license', | |
| 26 | + key: $( '#patchstack_api_key' ).val(), | |
| 28 | 27 | PatchstackNonce: PatchstackVars.nonce |
| 29 | 28 | }; |
| 30 | 29 | |
| 31 | - if ( $.trim( postData.clientid ).length == 0 || $.trim( postData.secretkey ).length == 0) { | |
| 32 | - alert( 'Please enter the site id and secret key.' ); | |
| 30 | + if ( $.trim( postData.key ).length == 0 ) { | |
| 31 | + alert( 'Please enter the API key.' ); | |
| 33 | 32 | return false; |
| 34 | 33 | } |
| 35 | 34 | |
| 35 | + $( '.patchstack-resync' ).hide(); | |
| 36 | + $( '#patchstack-activate' ).hide(); | |
| 37 | + $( '.patchstack-loading' ).show(); | |
| 38 | + | |
| 36 | 39 | $.post( PatchstackVars.ajaxurl, postData, function( response ) { |
| 37 | 40 | if ( response.result == 'error' ) { |
| 41 | + $( '#patchstack-activate' ).show(); | |
| 42 | + $( '.patchstack-loading' ).hide(); | |
| 43 | + if ( response.error_message ) { | |
| 44 | + alert( response.error_message ); | |
| 45 | + } else { | |
| 46 | + alert( PatchstackVars.error_message ); | |
| 47 | + } | |
| 48 | + } else { | |
| 49 | + window.location = window.location.href + '&resync=1'; | |
| 50 | + } | |
| 51 | + }); | |
| 52 | + }); | |
| 53 | + | |
| 54 | + $('#patchstack_send_mail_url').on( 'click', function(e) { | |
| 55 | + e.preventDefault(); | |
| 56 | + var postData = { | |
| 57 | + action: 'patchstack_send_new_url_email', | |
| 58 | + PatchstackNonce: PatchstackVars.nonce | |
| 59 | + }; | |
| 60 | + $.post( PatchstackVars.ajaxurl, postData, function( response ) { | |
| 61 | + if ( response == 'fail') { | |
| 38 | 62 | alert( PatchstackVars.error_message ); |
| 39 | 63 | } else { |
| 40 | - if (response.response && response.response.free === false) { | |
| 41 | - window.location.reload(); | |
| 42 | - } else { | |
| 43 | - $( '.patchstack-license-status' ).text( 'Active' ).css( { color: '#B2D675' } ); | |
| 44 | - $( '.patchstack-sub-type' ).text( 'Community (Free) '); | |
| 45 | - $( '.ps-b1, .ps-p1' ).hide(); | |
| 46 | - $( '.ps-b3' ).removeClass('patchstack-fullwidth'); | |
| 47 | - $( '.ps-b2, .ps-b4, .ps-p2' ).show(); | |
| 48 | - } | |
| 64 | + alert( 'Email Sent!' ); | |
| 49 | 65 | } |
| 50 | 66 | }); |
| 51 | 67 | }); |
| 52 | 68 | |
| @@ -60,9 +76,9 @@ | ||
| 60 | 76 | "ajax": { |
| 61 | 77 | "url": PatchstackVars.ajaxurl, |
| 62 | 78 | "type": "POST", |
| 63 | 79 | "data": function(d){ |
| 64 | - d.action = 'firewall_log_table'; | |
| 80 | + d.action = 'patchstack_firewall_log_table'; | |
| 65 | 81 | d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value"); |
| 66 | 82 | } |
| 67 | 83 | }, |
| 68 | 84 | "responsive": true, |
| @@ -104,9 +120,9 @@ | ||
| 104 | 120 | "ajax": { |
| 105 | 121 | "url": PatchstackVars.ajaxurl, |
| 106 | 122 | "type": "POST", |
| 107 | 123 | "data": function(d){ |
| 108 | - d.action = 'users_log_table'; | |
| 124 | + d.action = 'patchstack_users_log_table'; | |
| 109 | 125 | d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value"); |
| 110 | 126 | } |
| 111 | 127 | }, |
| 112 | 128 | "responsive": true, |