PluginProbe
Patchstack – WordPress & Plugins Security / 2.1.3
Patchstack – WordPress & Plugins Security v2.1.3
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
patchstack / assets / js / patchstack.js

patchstack.js in Patchstack – WordPress & Plugins Security 2.1.3, at assets/js/patchstack.js

181 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Patchstack
3 * https://patchstack.com
4 */
5
6 window.Patchstack = window.Patchstack || {};
7
8 ( function( window, document, $, plugin ) {
9 var $c = {};
10
11 plugin.init = function() {
12 plugin.cache();
13 plugin.bindEvents();
14 };
15
16 plugin.cache = function() {
17 $c.window = $( window );
18 $c.body = $( document.body );
19 };
20
21 plugin.bindEvents = function() {
22 $('input#patchstack-activate').on( 'click', function(e) {
23 e.preventDefault();
24 var postData = {
25 action: 'activate_license',
26 clientid: $( '#patchstack_api_client_id' ).val(),
27 secretkey: $( '#patchstack_api_client_secret_key' ).val(),
28 PatchstackNonce: PatchstackVars.nonce
29 };
30
31 if ( $.trim( postData.clientid ).length == 0 || $.trim( postData.secretkey ).length == 0) {
32 alert( 'Please enter the site id and secret key.' );
33 return false;
34 }
35
36 $.post( PatchstackVars.ajaxurl, postData, function( response ) {
37 if ( response.result == 'error' ) {
38 alert( PatchstackVars.error_message );
39 } 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-b3, .ps-p1' ).hide();
46 $( '.ps-b2, .ps-b4, .ps-p2' ).show();
47 }
48 }
49 });
50 });
51
52 $('#patchstack_send_mail_url').on( 'click', function(e) {
53 e.preventDefault();
54 var postData = {
55 action: 'send_new_url_email',
56 PatchstackNonce: PatchstackVars.nonce
57 };
58 $.post( PatchstackVars.ajaxurl, postData, function( response ) {
59 if ( response == 'fail') {
60 alert( PatchstackVars.error_message );
61 } else {
62 alert( 'Email Sent!' );
63 }
64 });
65 });
66
67 // Don't load this part if DataTables is not loaded.
68 if(typeof jQuery.fn.dataTable !== 'undefined' && window.location.href.indexOf('patchstack') !== -1){
69
70 // Initialize datatables.
71 $('.table-firewall-log').DataTable({
72 "processing": true,
73 "serverSide": true,
74 "ajax": {
75 "url": PatchstackVars.ajaxurl,
76 "type": "POST",
77 "data": function(d){
78 d.action = 'firewall_log_table';
79 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
80 }
81 },
82 "responsive": true,
83 "columns": [
84 { "data": "fid" },
85 { "data": "referer" },
86 { "data": "method" },
87 { "data": "ip", render: $.fn.dataTable.render.text() },
88 { "data": "log_date" }
89 ],
90 "order": [[0, "desc"]],
91 "searching": false,
92 "ordering": false,
93 "drawCallback": function( settings ) {
94 $('.titletip').tooltip();
95 },
96 "columnDefs": [
97 {
98 "render": function ( data, type, row ) {
99 var title = (data ? data : 'Unknown');
100 var description = (row.description ? row.description : 'No Explanation');
101
102 return '<span class=" titletip" title="' + description + '">' + title + '</span>';
103 },
104 "targets": 0
105 },
106 {
107 "render": function ( data, type, row ) {
108 return decodeURIComponent(data).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace('+', ' ');
109 },
110 "targets": 1
111 }
112 ]
113 });
114
115 $('.table-user-log').DataTable({
116 "processing": true,
117 "serverSide": true,
118 "ajax": {
119 "url": PatchstackVars.ajaxurl,
120 "type": "POST",
121 "data": function(d){
122 d.action = 'users_log_table';
123 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
124 }
125 },
126 "responsive": true,
127 "columns": [
128 { "data": "author" },
129 { "data": "action", render: $.fn.dataTable.render.text() },
130 { "data": "object", render: $.fn.dataTable.render.text() },
131 { "data": "object_name", render: $.fn.dataTable.render.text() },
132 { "data": "ip", render: $.fn.dataTable.render.text() },
133 { "data": "date", render: $.fn.dataTable.render.text() }
134 ],
135 "order": [[0, "desc"]],
136 "searching": true,
137 "ordering": false
138 });
139 }
140
141 if($("#patchstack_captcha_type").val() == "v2"){
142 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
143 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
144 }else if($("#patchstack_captcha_type").val() == "invisible"){
145 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
146 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
147 }else{
148 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
149 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
150 }
151
152 $("#patchstack_captcha_type").change(function() {
153 if($("#patchstack_captcha_type").val() == "v2"){
154 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
155 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
156 }else if($("#patchstack_captcha_type").val() == "invisible"){
157 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
158 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
159 }else{
160 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
161 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
162 }
163 });
164
165 if($('#geo-countries').length > 0){
166 var items = []
167 if($('#geo-countries').data('selected') != ''){
168 items = $('#geo-countries').data('selected').split(',')
169 }
170
171 $('#geo-countries').selectize({
172 maxItems: null,
173 delimiter: ',',
174 plugins: ['remove_button'],
175 items: items
176 });
177 }
178 };
179
180 $( plugin.init );
181 }( window, document, jQuery, window.Patchstack ) );