PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.7
Patchstack – WordPress & Plugins Security v2.2.7
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.2.7, at assets/js/patchstack.js

183 lines 6.1 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: 'patchstack_activate_license',
26 key: $( '#patchstack_api_key' ).val(),
27 PatchstackNonce: PatchstackVars.nonce
28 };
29
30 if ( $.trim( postData.key ).length == 0 ) {
31 alert( 'Please enter the API key.' );
32 return false;
33 }
34
35 $( '.patchstack-resync' ).hide();
36 $( '#patchstack-activate' ).hide();
37 $( '.patchstack-loading' ).show();
38
39 $.post( PatchstackVars.ajaxurl, postData, function( response ) {
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') {
62 alert( PatchstackVars.error_message );
63 } else {
64 alert( 'Email Sent!' );
65 }
66 });
67 });
68
69 // Don't load this part if DataTables is not loaded.
70 if(typeof jQuery.fn.dataTable !== 'undefined' && window.location.href.indexOf('patchstack') !== -1){
71
72 // Initialize datatables.
73 $('.table-firewall-log').DataTable({
74 "processing": true,
75 "serverSide": true,
76 "ajax": {
77 "url": PatchstackVars.ajaxurl,
78 "type": "POST",
79 "data": function(d){
80 d.action = 'patchstack_firewall_log_table';
81 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
82 }
83 },
84 "responsive": true,
85 "columns": [
86 { "data": "fid" },
87 { "data": "referer" },
88 { "data": "method" },
89 { "data": "ip", render: $.fn.dataTable.render.text() },
90 { "data": "log_date" }
91 ],
92 "order": [[0, "desc"]],
93 "searching": false,
94 "ordering": false,
95 "drawCallback": function( settings ) {
96 $('.titletip').tooltip();
97 },
98 "columnDefs": [
99 {
100 "render": function ( data, type, row ) {
101 var title = (data ? data : 'Unknown');
102 var description = (row.description ? row.description : 'No Explanation');
103
104 return '<span class=" titletip" title="' + description + '">' + title + '</span>';
105 },
106 "targets": 0
107 },
108 {
109 "render": function ( data, type, row ) {
110 return decodeURIComponent(data).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace('+', ' ');
111 },
112 "targets": 1
113 }
114 ]
115 });
116
117 $('.table-user-log').DataTable({
118 "processing": true,
119 "serverSide": true,
120 "ajax": {
121 "url": PatchstackVars.ajaxurl,
122 "type": "POST",
123 "data": function(d){
124 d.action = 'patchstack_users_log_table';
125 d.PatchstackNonce = $("meta[name=patchstack_nonce]").attr("value");
126 }
127 },
128 "responsive": true,
129 "columns": [
130 { "data": "author" },
131 { "data": "action", render: $.fn.dataTable.render.text() },
132 { "data": "object", render: $.fn.dataTable.render.text() },
133 { "data": "object_name", render: $.fn.dataTable.render.text() },
134 { "data": "ip", render: $.fn.dataTable.render.text() },
135 { "data": "date", render: $.fn.dataTable.render.text() }
136 ],
137 "order": [[0, "desc"]],
138 "searching": true,
139 "ordering": false
140 });
141 }
142
143 if($("#patchstack_captcha_type").val() == "v2"){
144 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
145 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
146 }else if($("#patchstack_captcha_type").val() == "invisible"){
147 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
148 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
149 }else{
150 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
151 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
152 }
153
154 $("#patchstack_captcha_type").change(function() {
155 if($("#patchstack_captcha_type").val() == "v2"){
156 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
157 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key").show();
158 }else if($("#patchstack_captcha_type").val() == "invisible"){
159 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").hide();
160 $("#patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").show();
161 }else{
162 $("#patchstack_captcha_public_key, #patchstack_captcha_private_key, #patchstack_captcha_public_key_v3, #patchstack_captcha_private_key_v3").hide();
163 $("#patchstack_captcha_public_key_v3_new, #patchstack_captcha_private_key_v3_new").show();
164 }
165 });
166
167 if($('#geo-countries').length > 0){
168 var items = []
169 if($('#geo-countries').data('selected') != ''){
170 items = $('#geo-countries').data('selected').split(',')
171 }
172
173 $('#geo-countries').selectize({
174 maxItems: null,
175 delimiter: ',',
176 plugins: ['remove_button'],
177 items: items
178 });
179 }
180 };
181
182 $( plugin.init );
183 }( window, document, jQuery, window.Patchstack ) );