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