PageSourceSearch

https://famscoalition.com/templates/Store/default/Ad/Ads.js

js famscoalition.com collected 2026-09-27 04:28:29 UTC 3,177 bytes, 105 lines download raw bytes

1function Rotator(selector, ads, spec){
2  this.sel       = selector;
3  this.slots     = $(selector);
4  this.num_slots = this.slots.length;
5
6  if(!this.num_slots){
7    //console.log("Skipping selector "+selector);
8    return 0;
9  }
10
11  this.my_ads    = ads;
12  this.ga_label  = spec.ga_label;
13  this.index     = 0;
14  this.timer     = setInterval(this.rotate.bind(this), 15000);
15  this.rotate();
16}
17
18Rotator.prototype.track = function(ad){
19  var id = ad.advertisement_id;
20  if(typeof _gaq != 'undefined'){
21    _gaq.push( ['_trackEvent', this.ga_label, 'Show', id],
22               ['store._trackEvent', this.ga_label, 'Show', id])
23  }
24};
25
26Rotator.prototype.build_html = function(ad){
27  var html;
28  var new_win = "";
29  var re = /^http:/;
30  if(re.test(ad.goto_url)) new_win = " target=_blank ";
31  var target ="function(){window.location = '"+ad.goto_url+"'; return false;}";
32  html = "<a "+new_win+"href='"+ad.goto_url+"' onclick='"+target+"'>";
33  html += "<img alt='"+ad.title+"' src='"+ad.photo_url+"'/></a>";
34  return html;
35};
36
37Rotator.prototype.rotate = function(){
38  var r = this;
39  r.slots.each(function(i){
40    if(r.index >= r.my_ads.length) r.index = 0;
41    //console.log("["+r.sel+"] Ad#"+r.index+"-->slot#"+i);
42    var ad = r.my_ads[r.index];
43    $(this).html(r.build_html(ad)).trigger('create');
44    r.track(ad);
45    r.index++;
46  });
47};
48
49function Ads(){
50  var ads = this;
51
52  this.spec = {
53    "towers" : {selectors : [".tower_div"], ga_label : "TowerAd"},
54    "badges" : {selectors : [".badge_div"], ga_label : "BadgeAd"},
55    "largebanners" : {selectors : [".largebanner_div"], ga_label : "LargeBannerAd"},
56    "banners" : {
57      // 3 selectors for 3 separate rotations of same banners:
58      // Banners marked "above", "below", and unmarked
59      selectors :
60      [".banner_div.above", ".banner_div.below", ".banner_div:not(.above, .below)"],
61      ga_label : "BannerAd"
62    },
63  };
64
65  this.loadData = function(){
66    ads.rotators = [];
67    if (! this.refresh_timer) {
68      this.refresh_timer = setInterval(this.loadData, 4 * 3600 * 1000);
69    }
70
71    var randfn = function(){ return Math.round(Math.random()) - 0.5; };
72
73    var handleData = function(data){
74      for(var ad_type in data){
75        if(!data.hasOwnProperty(ad_type)) continue;
76        if(!ads.spec.hasOwnProperty(ad_type)) continue;
77        if(!data[ad_type].length) continue;
78        var selectors = ads.spec[ad_type].selectors;
79        for(var i in selectors){
80          var selector = selectors[i];
81          var r = new Rotator(selector,data[ad_type].sort(randfn),ads.spec[ad_type]);
82          if(r) ads.rotators.push[r];
83        }
84      }
85    };
86    var handleError = function(error){
87      console.log("ad load error - "+error);
88    };
89
90    if(typeof AwsWafIntegration !== 'undefined'){
91      AwsWafIntegration.fetch("/a.json", { credentials: "same-origin" })
92        .then(function(response){ return response.json(); })
93        .then(handleData)
94        .catch(handleError);
95    } else {
96      $.ajax({
97        url      : "/a.json",
98        dataType : "json",
99        success  : handleData
100      }).fail(function(jqxhr, status, error){
101        handleError(status+", "+error);
102      });
103    }
104  };
105}

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.