PageSourceSearch

https://mscaggies.com/components/js/components/evergreen.js?bust=639027548301462822

js mscaggies.com collected 2026-09-28 10:34:43 UTC 11,709 bytes, 269 lines download raw bytes

1define(['knockout', 'components/component', 'jquery', 'gpt', 'tsdist/cbs-surround','ssGptHeaderBidding'], function (ko, Component, $) {
2    var parsedQuery = location.search.substring(1).split("&").map(function (pairs) { return pairs.split("="); });
3    var test_wired_carbon = false;
4
5    if (typeof airgap !== 'undefined' && typeof airgap.toggle !== 'undefined') {
6        airgap.toggle(window.airgapLoadEvent, true);
7    }
8
9    parsedQuery.forEach(function (pair) {
10        if (pair[0].indexOf("test_wired_carbon") === 0) {
11            test_wired_carbon = true;
12        }
13    });
14    if (test_wired_carbon) {
15        console.log("testing wired carbon");
16    }
17    // this will be the only thing remaining someday
18    test_wired_carbon = true;
19
20    var pageTargetting = window.cbs_ads_activated ? PageTargetting.getPageLevel() : null;
21    if (test_wired_carbon){
22        pageTargetting = PageTargetting.getPageLevel();
23        var criteria = window.targetting_criteria || {};
24        for (var key in criteria) {
25            if (!criteria.hasOwnProperty(key)) continue;
26            pageTargetting.kvp[key]= criteria[key];
27        }        
28    }
29    var middleCount = 0;
30    var hasAssignedTopForWidth = {};
31
32    $(window).off('.targetting-criteria').on('keyup.targetting-criteria', function(e){
33        if (e.ctrlKey && e.which === 120) {
34            var $table = $('.targetting-criteria');
35
36            if ($table.length === 0) {
37                var html = '<div><h5>Targetting Criteria</h5><table>' + Object.keys(window.targetting_criteria).map(function(key){ 
38                return '<tr><th>' + key + '</th><td>' + window.targetting_criteria[key] + '</td></tr>'; }).join('') + '</table></div>';
39
40                $table = $(html).addClass('targetting-criteria').css({
41                    background:'#fff',
42                    color:'#000',
43                    borderCollapse: 'collapse',
44                    position:'fixed',
45                    left:0,
46                    top:0,
47                    padding:'2px 4px',
48                    zIndex:99999
49                }).hide().appendTo('body');
50
51                $table.find('th, td').css('padding', '2px 4px');
52                $table.find('th').css({
53                    fontWeight:'bold',
54                    textAlign:'right'
55                });
56            }
57
58            $table.slideToggle();
59        }
60    });
61
62    function dfpModel(params) {
63        var self = this;
64        ko.utils.extend(self, new Component(params));
65        self.sidearm_dfp = params.sidearm_dfp;
66        self.ad;
67        self.networkCode = window.dfp_network_code || "29658103";
68        self.slot;
69        self.unitName;
70        self.dimensions;
71        self.id = uniqueId(params.name);
72        self.sizes = params.sizes;
73        self.width = ko.observable(0);
74        self.height = ko.observable(0);
75        self.data([{}]);
76        self.effect = params.effect;
77
78        // previously this checked window.googletag, 
79        // but since that can be defined before actually loading gpt, we need a different marker for that
80        // there's probably a better way to do this, but this works for now.
81        if (!window.gpt_load_initiated) {
82            window.gpt_load_initiated = true;
83            var useSSL = 'https:' == document.location.protocol; 
84            var src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js';
85            window.googletag = window.googletag || {
86                cmd:[]
87            };
88            if (window.googletag.cmd === undefined) {
89                window.googletag.cmd = [];
90            }
91            googletag.cmd.push(function(){
92                googletag.pubads().disableInitialLoad();
93            });
94            var script = document.createElement('script');
95            script.src = src;
96            document.getElementsByTagName('head')[0].appendChild(script);
97        }
98
99        self.renderAd = function () {
100            if (window.block_dfp) return;
101			var has_email_in_url_exp = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
102            if (has_email_in_url_exp.test(location.href)) return;
103			
104            var width = document.documentElement.clientWidth;
105            for (var x = 0; x < self.sizes.length; x++) {
106                var _size = self.sizes[x];
107                if (width > _size.breakpoint) {
108
109                    if (!_size.enabled && _size.enabled !== undefined)
110                        return false;
111                    self.unitName = _size.unitName;
112                    self.width(_size.dimensions.width);
113                    self.height(_size.dimensions.height);
114                    var size_list = "";
115                    try {
116                        size_list = JSON.parse(_size.size_list);
117                    }
118                    catch (err) {
119                        size_list = ""
120                    }
121                    if (size_list) {
122                        var has970x90 = size_list.filter(function(size){ return size[0] === 970 && size[1] === 90; }).length > 0;
123                        var has728x90 = size_list.filter(function(size){ return size[0] === 728 && size[1] === 90; }).length > 0;
124                        if (has970x90 && !has728x90) {
125                            size_list.push([728, 90]);
126                        }
127                        self.dimensions = size_list;
128                    }
129                    else {
130                        self.dimensions = [self.width(), self.height()];
131                    }
132                    break;
133                }
134            }
135			
136			if (self.unitName === undefined) return false;
137            var sidearmextended = self.unitName.indexOf("sidearmextended/adaptive-1");
138            if (sidearmextended !== -1 && window.targetting_criteria && window.targetting_criteria.site){
139                self.unitName = insert(self.unitName, sidearmextended + "sidearmextended/".length, window.targetting_criteria.site + "/");
140            }
141
142            if (window.dfp_network_code) {
143
144                if (self.unitName.substring(0,1) === "/")
145                    self.slot = self.unitName;
146                //4177 is IMG network code.
147				//IMG sites use a single unit name for all spots, prefixed with a forward slash.
148                else if (window.img_dfp_unit_name)
149                    self.slot = "/" + window.dfp_network_code + '/' + window.img_dfp_unit_name;
150                else
151                    self.slot = "/" + window.dfp_network_code + "/" + window.targetting_criteria.site + "/" + self.unitName; 
152            } else {
153                if (self.unitName.substring(0,1) === "/") {
154                    self.slot = self.unitName;
155                } else {
156                    self.slot = "/" + self.networkCode + "/" + self.unitName;
157                }
158            }
159
160            if (test_wired_carbon){
161                window.dfp_network_code = "21708449227";
162                self.slot = "/" + window.dfp_network_code + "/" + window.ad_full_unit_name;
163                console.log("no matter the inial network: self.slot", self.slot);
164            }
165
166            if (self.dimensions[0] === 0 && self.dimensions[1] === 0) return;
167
168            googletag.cmd.push(function () {
169
170                var $el = $("#" + self.id).css({ textAlign: "center" });
171                var isAboveFold = $el.offset().top +  ($el.height()/2) < $(window).height();
172
173                if (pageTargetting) {
174                    pageTargetting.applyTo(googletag.pubads());
175
176                    var isInStandardStickyFooter = $el.closest('.c-sticky-leaderboard').length > 0;
177
178                    var isSticky = params.name.toLowerCase().indexOf("sticky") > -1 || 
179                        $el.parents().get().filter(function(el) { return $(el).css("position") === "fixed"; }).length > 0;
180
181                    var width = self.width();
182                    var isTopForWidth = !hasAssignedTopForWidth[width];
183
184                    var posValue = self.effect === "pos_middle" ? "middle" :
185                                   isSticky          ? "sticky" : 
186                                   !isAboveFold      ? "bottom" :
187                                   isTopForWidth     ? 'top' : 
188                                                       'middle' + (++middleCount);
189
190                    if (posValue === "top") {
191                        hasAssignedTopForWidth[width] = true;
192                    }
193
194                    var keywords = [];
195
196                    if (isInStandardStickyFooter) {
197                        keywords.push('kargo')
198                    }
199                    var additionalKvps = {
200                      keyword: keywords
201                    };
202
203                    parsedQuery.forEach(function(pair) {
204                        // CBS uses this for testing ad campaigns
205                        if (pair[0].indexOf("adTargeting_") === 0) {
206                            additionalKvps[pair[0].replace("adTargeting_", "")] = pair[1];
207                        }
208                    });
209
210                    var slotTargetting = pageTargetting.forUnit(
211                         self.unitName.split('/').slice(3).join("/"), 
212                         posValue,
213                         null,
214                         additionalKvps);
215
216                    self.slot = test_wired_carbon ? self.slot : slotTargetting.fullIu;
217                    self.ad = googletag.defineSlot(test_wired_carbon ? self.slot : slotTargetting.fullIu, self.dimensions, self.id);
218                    slotTargetting.applyTo(self.ad);
219                } else {
220                    self.ad = googletag.defineSlot(self.slot, self.dimensions, self.id);
221                    var criteria = window.targetting_criteria || {};
222                    for (var key in criteria) {
223                        if (!criteria.hasOwnProperty(key)) continue;
224                        googletag.pubads().setTargeting(key, criteria[key]);
225                    }
226
227                    var posValue = self.effect === "pos_middle" ? "middle" :
228                                    isAboveFold ?  "top" : 
229                                                   "bottom";
230
231                    self.ad.setTargeting('pos', posValue);
232                    self.ad.setTargeting('location', params.name);
233                    if (self.width() === 970 && params.name.toLowerCase().indexOf("sticky") > -1) {
234                        self.ad.setTargeting('pos2', 'sticky970x66');
235                    }
236                }
237                self.ad.addService(googletag.pubads());
238                
239                setTimeout(function(){
240                    googletag.cmd.push(function () { googletag.enableServices(); });
241                    googletag.cmd.push(function () { 
242                        window.sidearmsports.gpt.headerBidding.queueForBiddingOrRefreshImmediately(
243                          self.slot,
244                          [self.dimensions],
245                          self.ad,
246                          self.id
247                        );
248                        googletag.display(self.id);
249                    });
250                }, 0);
251            });
252        };
253    }
254    function insert(str, index, value) {
255        return str.substr(0, index) + value + str.substr(index);
256    }
257
258    var usedNames = {};
259    function uniqueId(name) {
260        if (usedNames[name] == null) {
261            usedNames[name] = 0;
262        };
263        return name + (usedNames[name]++);
264    };
265
266    return {
267        viewModel: dfpModel
268    };
269});

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.