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