PluginProbe ʕ •ᴥ•ʔ
CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice) / 3.5.0
CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice) v3.5.0
3.5.1 3.5.0 3.4.2 trunk 1.0.1 1.0.3 1.2 1.2.1 1.2.2 1.3 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.2.0 3.2.1 3.2.10 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.3.9.1 3.4.0 3.4.1
cookie-law-info / legacy / admin / modules / cookie-scaner / assets / js / cookie-scaner.js
cookie-law-info / legacy / admin / modules / cookie-scaner / assets / js Last commit date
cookie-scaner.js 1 month ago
cookie-scaner.js
472 lines
1 (function( $ ) {
2 'use strict';
3 $(
4 function() {
5 var CLI_cookie_scanner = {
6 continue_scan:1,
7 abortingScan:0,
8 onPrg:0,
9 Set:function()
10 {
11 jQuery( document ).on(
12 'click',
13 '#wt-cli-ckyes-scan',
14 function(){
15 CLI_cookie_scanner.continue_scan = 1;
16 CLI_cookie_scanner.doScan();
17 }
18 );
19 jQuery( document ).on(
20 'click',
21 '#wt-cli-ckyes-connect-scan',
22 function(){
23 CLI_cookie_scanner.continue_scan = 1;
24 CLI_cookie_scanner.connectScan( jQuery( this ) );
25 }
26 );
27 jQuery( document ).on(
28 'click',
29 '#wt-cli-cookie-scan-abort',
30 function( event ) {
31 event.preventDefault();
32 CLI_cookie_scanner.abortScan( jQuery( this ) );
33 }
34 );
35 jQuery( document ).on(
36 'click',
37 '.wt-cli-cookie-scan-preview-modal',
38 function( event ) {
39 event.preventDefault();
40 wtCliAdminFunctions.showModal( 'wt-cli-ckyes-modal-settings-preview' );
41 }
42 );
43 this.reloadScanner();
44 this.attachScanImport();
45 this.checkScanStatus();
46 },
47 doScan:function()
48 {
49 CLI_cookie_scanner.nextScanID();
50 },
51 scanAgain:function()
52 {
53 $( '.cli_scan_again' ).unbind( 'click' ).click(
54 function(){
55 CLI_cookie_scanner.continue_scan = 1;
56 CLI_cookie_scanner.nextScanID();
57 }
58 );
59 },
60 scanNow:function()
61 {
62 this.takePages();
63 },
64 takePages:function()
65 {
66 var data = {
67 action: 'cli_cookie_scaner',
68 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
69 cli_scaner_action:'get_pages',
70 };
71 var scanbar = $( '.wt-cli-cookie-scan-bar' );
72 scanbar.html( '<span style="float:left; height:40px; line-height:40px;">' + cookielawinfo_cookie_scaner.labels.finding + '</span> <img src="' + cookielawinfo_cookie_scaner.loading_gif + '" style="display:inline-block;" />' );
73 $.ajax(
74 {
75 url: cookielawinfo_cookie_scaner.ajax_url,
76 data: data,
77 dataType: 'json',
78 type: 'POST',
79 success: function (data)
80 {
81 CLI_cookie_scanner.scan_id = typeof data.scan_id != 'undefined' ? data.scan_id : 0;
82 if ( true === data.status ) {
83 CLI_cookie_scanner.bulkScan( data.scan_id,data.total );
84 } else {
85 wtCliAdminFunctions.createModal( '',cookielawinfo_cookie_scaner.labels.page_fetch_error );
86 CLI_cookie_scanner.reloadAfterRequest();
87 }
88 },
89 error:function()
90 {
91 wtCliAdminFunctions.createModal( '',cookielawinfo_cookie_scaner.labels.page_fetch_error );
92 CLI_cookie_scanner.reloadAfterRequest();
93 }
94 }
95 );
96 },
97 attachScanImport: function (scan_id) {
98 $( '.cli_import' ).unbind( 'click' ).click(
99 function () {
100
101 var scan_id = $( this ).attr( 'data-scan-id' );
102 var html = '<div id="wt-cli-cookie-scan-import" class="wt-cli-modal"><span class="wt-cli-modal-js-close">×</span>';
103 html += '<div class="wt-cli-modal-header"><h2>' + cookielawinfo_cookie_scaner.labels.import_options + '</h2></div>';
104 html += '<div class="wt-cli-modal-body">';
105 html += '<input type="radio" name="cli_import_options" id="cli_import_options_replace" value="1" /><label for="cli_import_options_replace"> ' + cookielawinfo_cookie_scaner.labels.replace_old + '</label><br />';
106 html += '<input type="radio" name="cli_import_options" id="cli_import_options_merge" value="2" checked /><label for="cli_import_options_merge"> ' + cookielawinfo_cookie_scaner.labels.merge + ' (' + cookielawinfo_cookie_scaner.labels.recommended + ')</label> <br />';
107 html += '<input type="radio" name="cli_import_options" id="cli_import_options_append" value="3" /><label for="cli_import_options_append"> ' + cookielawinfo_cookie_scaner.labels.append + ' (' + cookielawinfo_cookie_scaner.labels.not_recommended + ')</label> <br /><br />';
108 html += '<a class="button-secondary pull-left cli_import_cancel">' + cookielawinfo_cookie_scaner.labels.cancel + '</a>';
109 html += '<a class="button-primary pull-left cli_import_now" data-scan-id="' + scan_id + '" style="margin-left:5px;">' + cookielawinfo_cookie_scaner.labels.start_import + '</a>';
110 html += '</div>';
111 html += '</div>';
112
113 if ($( '#wt-cli-cookie-scan-import' ).length === 0) {
114 $( 'body' ).append( html );
115 wtCliAdminFunctions.showModal( 'wt-cli-cookie-scan-import' );
116 $( '.cli_import_cancel' ).click(
117 function () {
118 wtCliAdminFunctions.closeModal();
119 }
120 );
121 $( '.cli_import_now' ).click(
122 function () {
123 wtCliAdminFunctions.loadSpinner( jQuery( this ) );
124 var import_option = $( '[name="cli_import_options"]:checked' ).val();
125 var scan_id = $( this ).attr( 'data-scan-id' );
126 CLI_cookie_scanner.importNow( scan_id, import_option );
127 }
128 );
129 } else {
130 wtCliAdminFunctions.showModal( 'wt-cli-cookie-scan-import' );
131 }
132 }
133 );
134
135 },
136 importNow:function(scan_id,import_option)
137 {
138 if (this.onPrg == 1) {
139 return false;
140 }
141 var data = {
142 action: 'cli_cookie_scaner',
143 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
144 cli_scaner_action:'import_now',
145 scan_id:scan_id,
146 import_option:import_option
147 };
148 $( '.wrap a' ).css( {'opacity':.5} );
149 $( '.cli_import' ).html( cookielawinfo_cookie_scaner.labels.importing );
150 $( '.cli_progress_action_main' ).html( cookielawinfo_cookie_scaner.labels.importing );
151 $( '.spinner' ).css( {'visibility':'visible'} );
152 this.onPrg = 1;
153 $.ajax(
154 {
155 url:cookielawinfo_cookie_scaner.ajax_url,
156 data:data,
157 dataType:'json',
158 type:'POST',
159 success:function(data)
160 {
161 CLI_cookie_scanner.onPrg = 0;
162 $( '.wrap a' ).css( {'opacity':1} );
163 $( '.cli_import' ).html( cookielawinfo_cookie_scaner.labels.import );
164 $( '.cli_progress_action_main' ).html( cookielawinfo_cookie_scaner.labels.import_finished );
165 $( '.spinner' ).css( {'visibility':'hidden'} );
166 wtCliAdminFunctions.closeModal();
167
168 if (data.response === true) {
169 cli_notify_msg.success( data.message );
170 } else {
171 cli_notify_msg.error( data.message );
172 }
173 },
174 error:function()
175 {
176 CLI_cookie_scanner.onPrg = 0;
177 $( '.wrap a' ).css( {'opacity':1} );
178 $( '.cli_import' ).html( cookielawinfo_cookie_scaner.labels.import );
179 $( '.cli_progress_action_main' ).html( cookielawinfo_cookie_scaner.labels.error );
180 $( '.spinner' ).css( {'visibility':'hidden'} );
181 cli_notify_msg.error( cookielawinfo_cookie_scaner.labels.error );
182 }
183 }
184 );
185 },
186 connectScan: function( element ){
187
188 var data = {
189 action: 'cli_cookie_scaner',
190 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
191 cli_scaner_action:'connect_scan',
192 };
193 wtCliAdminFunctions.loadSpinner( element );
194 $.ajax(
195 {
196 url: cookielawinfo_cookie_scaner.ajax_url,
197 data: data,
198 dataType: 'json',
199 type: 'POST',
200 success:function( response )
201 {
202 wtCliAdminFunctions.removeSpinner( element );
203 var data = response.data;
204 if ( response.success === true ) {
205 CLI_cookie_scanner.doScan();
206 } else {
207 if ( data.code ) {
208 if ( data.code == 102 || data.code == 107 ) {
209 if ( data.html ) {
210 wtCliAdminFunctions.createModal( '',data.html );
211 }
212 } else if ( data.code == 108 ) {
213
214 wtCliAdminFunctions.showModal( 'wt-cli-ckyes-modal-register' );
215
216 } else {
217 if ( data.message ) {
218 wtCliAdminFunctions.createModal( '',data.message );
219 setTimeout(
220 function(){
221 window.location.reload();
222 },
223 1500
224 );
225 }
226 }
227 }
228 }
229 },
230 error:function()
231 {
232 wtCliAdminFunctions.createModal( '','Invalid request' );
233 }
234 }
235 );
236 },
237 nextScanID: function(){
238 var data = {
239 action: 'cli_cookie_scaner',
240 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
241 cli_scaner_action:'next_scan_id',
242 };
243 var scanBtn = jQuery( '#wt-cli-ckyes-scan' );
244 wtCliAdminFunctions.loadSpinner( scanBtn );
245 $.ajax(
246 {
247 url: cookielawinfo_cookie_scaner.ajax_url,
248 data: data,
249 dataType: 'json',
250 type: 'POST',
251 success:function( response )
252 {
253 var data = response.data;
254 wtCliAdminFunctions.removeSpinner( scanBtn );
255 if ( response.success === true ) {
256 CLI_cookie_scanner.scanNow();
257 } else if ( data.code == 107 ) {
258
259 if ( data.html ) {
260 wtCliAdminFunctions.createModal( '',data.html );
261 }
262 } else {
263 if ( data.message ) {
264 wtCliAdminFunctions.createModal( '',data.message );
265 CLI_cookie_scanner.reloadAfterRequest();
266 }
267 }
268 },
269 error:function()
270 {
271 wtCliAdminFunctions.createModal( '','Invalid request' );
272 wtCliAdminFunctions.removeSpinner( scanBtn );
273 }
274 }
275 );
276 },
277 reloadAfterRequest: function( duration ) {
278 var timeout = 2000;
279 if (typeof duration !== 'undefined') {
280 timeout = duration;
281 }
282 setTimeout(
283 function(){
284 window.location.reload();
285 },
286 timeout
287 );
288 },
289 bulkScan: function(scan_id,total) {
290
291 var data = {
292 action: 'cli_cookie_scaner',
293 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
294 cli_scaner_action:'bulk_scan',
295 scan_id:scan_id,
296 total:total
297 };
298 $.ajax(
299 {
300 url: cookielawinfo_cookie_scaner.ajax_url,
301 data: data,
302 dataType: 'json',
303 type: 'POST',
304 success:function(response)
305 {
306 var data = response.data;
307 if ( response.success === true ) {
308 wtCliAdminFunctions.createModal( data.title,data.message );
309 if ( data.html ) {
310 jQuery( '.wt-cli-cookie-scan-bar' ).html( data.html );
311 }
312 } else {
313 if ( data.message ) {
314 wtCliAdminFunctions.createModal( '',data.message );
315 CLI_cookie_scanner.reloadAfterRequest( 3000 );
316 }
317 }
318 },
319 error:function()
320 {
321 wtCliAdminFunctions.createModal( '',data.message );
322 CLI_cookie_scanner.reloadAfterRequest( 6000 );
323 }
324 }
325 );
326 },
327 checkScanStatus: function(){
328 var scanStatus = Boolean( cookielawinfo_cookie_scaner.scan_status );
329 if ( scanStatus === true ) {
330
331 var data = {
332 action: 'cli_cookie_scaner',
333 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
334 cli_scaner_action:'check_status',
335 };
336 $.ajax(
337 {
338 url: cookielawinfo_cookie_scaner.ajax_url,
339 data: data,
340 dataType: 'json',
341 type: 'POST',
342 success:function(response)
343 {
344
345 if ( response.success === true ) {
346 CLI_cookie_scanner.fetchResult();
347 } else {
348 if ( response.data.refresh === true ) {
349 CLI_cookie_scanner.reloadAfterRequest( 10 );
350 }
351 }
352
353 },
354 error:function()
355 {
356 }
357 }
358 );
359 }
360
361 },
362 fetchResult: function(){
363 var data = {
364 action: 'cli_cookie_scaner',
365 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
366 cli_scaner_action:'fetch_result',
367 };
368 $.ajax(
369 {
370 url: cookielawinfo_cookie_scaner.ajax_url,
371 data: data,
372 dataType: 'json',
373 type: 'POST',
374 success:function(response)
375 {
376 if ( response.success === true ) {
377 CLI_cookie_scanner.reloadAfterRequest( 10 );
378 }
379 },
380 error:function()
381 {
382
383 }
384 }
385 );
386 },
387 abortScan: function( element ){
388
389 if ( CLI_cookie_scanner.abortingScan === 1 ) {
390 return false;
391 }
392 var scanner = jQuery( '.wt-cli-scan-status-bar' );
393 scanner.html( cookielawinfo_cookie_scaner.labels.abort );
394 scanner.css( {'color':'#444444'} );
395 wtCliAdminFunctions.loadSpinner( scanner );
396 CLI_cookie_scanner.abortingScan = 1;
397 var data = {
398 action: 'cli_cookie_scaner',
399 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
400 cli_scaner_action:'stop_scan',
401 };
402 $.ajax(
403 {
404 url: cookielawinfo_cookie_scaner.ajax_url,
405 data: data,
406 dataType: 'json',
407 type: 'POST',
408 success:function(response)
409 {
410 if ( response.success === true ) {
411 scanner.css( {'color':'#2fab10'} );
412 } else {
413 scanner.css( {'color':'#f44336'} );
414 }
415 if ( response.data.message ) {
416 scanner.html( response.data.message );
417 }
418 CLI_cookie_scanner.reloadAfterRequest();
419
420 },
421 error:function()
422 {
423 wtCliAdminFunctions.createModal( '', cookielawinfo_cookie_scaner.labels.abort_failed );
424 CLI_cookie_scanner.reloadAfterRequest();
425 }
426 }
427 );
428 },
429 reloadScanner: function(){
430 $( document ).on(
431 "trggerReloadScanner",
432 function(){
433 var data = {
434 action: 'cli_cookie_scaner',
435 security: cookielawinfo_cookie_scaner.nonces.cli_cookie_scaner,
436 cli_scaner_action:'get_scan_html',
437 };
438 $.ajax(
439 {
440 url: cookielawinfo_cookie_scaner.ajax_url,
441 data: data,
442 dataType: 'json',
443 type: 'POST',
444 success:function( response )
445 {
446 var data = response.data;
447 if ( response.success === true ) {
448 if ( data.scan_html ) {
449 $( '.wt-cli-cookie-scan-notice' ).html( data.scan_html );
450 }
451 }
452 },
453 error:function()
454 {
455
456 }
457 }
458 );
459 }
460 );
461 }
462 }
463
464 jQuery( document ).ready(
465 function(){
466 CLI_cookie_scanner.Set();
467 }
468 );
469 }
470 );
471 })( jQuery );
472