PageSourceSearch

https://wpsu.org/wp-content/plugins/adrotate/library/jquery.groups.js

js wpsu.org collected 2026-10-01 08:45:59 UTC 2,221 bytes, 81 lines download raw bytes

1/*
2Dynamic advert rotation for AdRotate
3Version: 1.0.1
4Original code: Arnan de Gans
5With help from: Mathias Joergensen, Fraser Munro
6Copyright: (c) 2020 Arnan de Gans
7== Settings ==
8groupid : PHP Group ID [integer, defaults to 0]
9speed : Time each slide is shown [integer: milliseconds, defaults to 3000]
10repeat_impressions : Stop counting impressions? [switch, defaults to Y]
11*/
12(function($) {
13	$.fn.gslider = function(settings) {
14		var config = {groupid:0,speed:3000};
15		if(settings) $.extend(true, config, settings)
16
17		this.each(function(i) {
18			var $cont = $(this);
19			var gallery = $(this).children();
20			var length = gallery.length;
21			var timer = 0;
22			var counter = 1;
23
24			if(length == 1) {
25				// Impression tracker (Single ad)
26	            var tracker = $cont.find(".c-1 a").attr("data-track");
27				if(typeof tracker !== 'undefined') {
28					impressiontracker(tracker);
29				}
30			}
31			
32			if(length > 1) {
33				$cont.find(".c-1").show();
34				for(n = 2; n <= length; n++) {
35					$cont.find(".c-" + n).hide();
36				}
37				
38				timer = setInterval(function(){ play(); }, config.speed);
39			}
40
41			function transitionTo(gallery, index) {
42				if((counter >= length) || (index >= length)) { 
43					counter = 1;
44				} else { 
45					counter++;
46				}
47				$cont.find(".c-" + counter).show();
48
49				// Impression tracker (Multiple ads)
50	            var tracker = $cont.find(".c-" + counter + ' a').attr("data-track");
51				if(typeof tracker !== 'undefined') {
52					impressiontracker(tracker);
53				}
54				$cont.find(".c-" + index).hide();
55			}
56			
57			function play() {
58				transitionTo(gallery, counter);
59			}
60
61			function impressiontracker(tracker) {
62	            admeta = atob(tracker).split(',');
63				var name = escape('adrotate-'+admeta[0]);
64				var now = Math.round(Date.now()/1000);
65				var expired = now - admeta[3];
66				var session = sessionStorage.getItem(name); // Get session data
67
68				if(session == null) { // New session, no previous data
69					session = 0;
70				}
71
72				if(session <= expired) { // Count new impression?
73					$.post(impression_object.ajax_url, {'action': 'adrotate_impression','track': tracker});
74				    sessionStorage.setItem(name, now);
75					delete tracker;
76				}
77			}
78		});
79		return this;
80	};
81}(jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.