PageSourceSearch

https://www.esgf.com/sites/all/modules/custom/cookie_google_analytics/js/ggee.js?1790412350

js esgf.com collected 2026-09-26 08:46:09 UTC 12,955 bytes, 404 lines download raw bytes

1var siteDomain = 'esgf.com';
2var CurrentUrl = window.location.href;
3var md = new MobileDetect(window.navigator.userAgent);
4var detectMobile = 'computer';
5const IPINFO_TOKEN = "a0852c6f78f92c";
6
7if (typeof md.mobile() !== 'undefined' && md.mobile()) {
8    detectMobile = "phone";
9}
10if (typeof md.tablet() !== 'undefined' && md.tablet()) {
11    detectMobile = "tablet";
12}
13
14function getCountryCode(token, callback) {
15    fetch(`https://ipinfo.io/json?token=${token}`)
16        .then(response => response.json())
17        .then(data => {
18            const countryCode = data.country;
19            callback(countryCode);
20        })
21        .catch(error => {
22            console.error('Erreur lors de la récupération du code du pays:', error);
23        });
24}
25
26
27/* visibilityState */
28function getHiddenProp() {
29    var prefixes = ['webkit', 'moz', 'ms', 'o'];
30    // if 'hidden' is natively supported just return it
31    if ('hidden' in document) {
32        return 'hidden';
33    }
34    // otherwise loop over all the known prefixes until we find one
35    for (var i = 0; i < prefixes.length; i++) {
36        if ((prefixes[i] + 'Hidden') in document) {
37            return prefixes[i] + 'Hidden';
38        }
39    }
40    // otherwise it's not supported
41    return null;
42}
43
44var bHavePV = getHiddenProp();
45var bInitialShow = false;
46
47if (bHavePV) {
48    document.addEventListener("visibilityChange", handleVisEvt);
49} else {
50    // console.log("PageVisibility is not present"); // track page view normally
51    // when PageVisibility is not present
52}
53
54function handleVisEvt() {
55    var value = bInitialShow;
56
57    if (document.visibilityState == "prerender") {
58        // console.log("PageVisibility is pre-rendering"); // might be interesting
59        // to keep track of pre-rendering
60    }
61    if (document.visibilityState == "visible" && !bInitialShow) {
62        bInitialShow = true; // don't trigger this code again
63        // console.log("PageVisibility is visible and trigger will not push again");
64    }
65    value = true;
66
67    return value;
68}
69
70
71/* CreateCookie */
72var j = new Date;
73j.setTime(j.getTime());
74j = new Date(j.getTime());
75
76// console.log(j.toString());
77
78function crumbleCookie(a) {
79    for (var d = document.cookie.split(";"), c = {}, b = 0; b < d.length; b++) {
80        var e = d[b].substring(0, d[b].indexOf("=")).trim(),
81            i = d[b].substring(d[b].indexOf("=") + 1, d[b].length).trim();
82        c[e] = i
83    }
84    if (a) {
85        return c[a] ? c[a] : null;
86    }
87    return c
88}
89
90function bakeCookie(a, d, c, b, e, i) {
91    var j = new Date;
92    j.setTime(j.getTime());
93    c && (c *= 864E5);
94    j = new Date(j.getTime() + c);
95    document.cookie = a + "=" + d + (c ? ";expires=" + j.toGMTString() : "") + (b ? ";path=" + b : "") + (e ? ";domain=" + e : "") + (i ? ";secure" : "")
96}
97
98
99/* Let's create the __dplz cookie*/
100function __dplz(n) {
101    var a = getTrafficSource(n, siteDomain);
102
103    a = a.replace(/\|{2,}/g, "|");
104    a = a.replace(/^\|/, "");
105    a = unescape(a);
106    60
107
108    bakeCookie(n, a, 0.125, "/", siteDomain, ""); //Cookie expiration sets to 3 hours ((1/24)*3)
109};
110
111/* Let's create the __dpla cookie*/
112function __dpla(n) {
113    var f = visitData(n);
114    f = unescape(f);
115
116    bakeCookie(n, f, 0.125, "/", siteDomain, ""); //Cookie expiration sets to 3 hours ((1/24)*3)
117};
118
119/* Let's create the __dplc cookie*/
120function __dplc(name) {
121    getCountryCode(IPINFO_TOKEN, (countryCode) => {
122        if (countryCode) {
123            bakeCookie(name, countryCode, 90, "/", siteDomain, "");  // 90 jours pour 3 mois
124        }
125    });
126}
127
128
129/* Let's create the __dplf cookie*/
130function __dplf(n) {
131    var j = new Date;
132    j.setTime(j.getTime());
133    j = new Date(j.getTime());
134    var g = 1;
135    g = unescape(g);
136
137    bakeCookie(n, g, 0.125, "/", siteDomain, ""); //Cookie expiration sets to 3 hours ((1/24)*3)
138};
139
140/* Let's create the mobile_detect cookie*/
141function mobile_detect(n) {
142    var j = new Date;
143    j.setTime(j.getTime());
144    j = new Date(j.getTime());
145
146    bakeCookie(n, detectMobile, 30, "/", siteDomain, ""); //Cookie expiration sets to 30 days
147};
148
149/* Let's create the first_page cookie*/
150function first_page(n) {
151    var j = new Date;
152    j.setTime(j.getTime());
153    j = new Date(j.getTime());
154
155    bakeCookie(n, CurrentUrl.substring(0, CurrentUrl.indexOf('?') != -1 ? CurrentUrl.indexOf('?') : CurrentUrl.length), 30, "/", siteDomain, ""); //Cookie expiration sets to 30 days
156};
157
158/* Check is cookie exists */
159function getCookie(name) {
160    var dc = document.cookie;
161    var prefix = name + "=";
162    var begin = dc.indexOf("; " + prefix);
163    if (begin == -1) {
164        begin = dc.indexOf(prefix);
165        if (begin != 0) {
166            return null;
167        }
168    } else {
169        begin += 2;
170        var end = document.cookie.indexOf(";", begin);
171        if (end == -1) {
172            end = dc.length;
173        }
174    }
175    return unescape(dc.substring(begin + prefix.length, end));
176}
177
178function doSomething() {
179    var value = false;
180    var myCookie = getCookie("__dplf");
181
182    if (myCookie == null) {
183        // do cookie doesn't exist stuff;
184        value = true;
185    }
186
187    return value;
188}
189
190
191/*Provide __dpla information*/
192function visitData() {
193    var domaineHash = Math.floor((Math.random() * 10000000) + 1);
194    var dateNow = new Date().getTime() / 1000;
195    var firstVisit = "";
196    var lastVisit = "";
197    var currentVisit = dateNow;
198    var sessionNumber = "";
199
200    /*Test firsVisit*/
201    if (firstVisit !== dateNow) {
202        firstVisit = dateNow;
203        lastVisit = dateNow;
204        sessionNumber = 1;
205    }
206    ;
207
208    var value =
209        domaineHash +
210        '.' + domaineHash +
211        '.' + firstVisit +
212        '.' + lastVisit +
213        '.' + currentVisit +
214        '.' + sessionNumber;
215
216    return value;
217}
218
219
220function getParam(s, q) {
221    try {
222        var match = s.match('[?&]' + q + '=([^&]+)');
223        return match ? match[1] : '';
224    } catch (e) {
225        return '';
226    }
227}
228
229/*Provide __dplz information*/
230function calculateTrafficSource() {
231    var dplcsr = '', dplcmd = '', dplccn = '', dplctr = '', dplcct = '', gclid = '', gclidSynapse = '';
232
233    // Identify the method
234    var ref = document.referrer;
235    ref = ref.substr(ref.indexOf('//') + 2);
236    ref_domain = ref;
237    ref_path = '/';
238    ref_search = '';
239    var url_search = document.location.search;
240
241
242    if (getParam(url_search, 'utm_source').length >= 1) {
243        dplcsr = getParam(url_search, 'utm_source');
244        dplcmd = getParam(url_search, 'utm_medium').length >= 1 ? getParam(url_search, 'utm_medium') : '(not set)';
245        dplccn = getParam(url_search, 'utm_campaign').length >= 1 ? getParam(url_search, 'utm_campaign') : '(not set)';
246        dplctr = getParam(url_search, 'utm_term').length >= 1 ? getParam(url_search, 'utm_term') : '';
247        dplcct = getParam(url_search, 'utm_content').length >= 1 ? getParam(url_search, 'utm_content') : '';
248        gclidSynapse = getParam(url_search, 'gclid').length >= 1 ? getParam(url_search, 'gclid') : '';
249        method = 'dpl_source';
250    } else if (getParam(url_search, 'gge_source').length >= 1) {
251        dplcsr = getParam(url_search, 'gge_source');
252        dplcmd = getParam(url_search, 'gge_medium').length >= 1 ? getParam(url_search, 'gge_medium') : '(not set)';
253        dplccn = getParam(url_search, 'gge_campaign').length >= 1 ? getParam(url_search, 'gge_campaign') : '(not set)';
254        dplctr = getParam(url_search, 'gge_term').length >= 1 ? getParam(url_search, 'gge_term') : '';
255        dplcct = getParam(url_search, 'gge_content').length >= 1 ? getParam(url_search, 'gge_content') : '';
256        gclidSynapse = getParam(url_search, 'gclid').length >= 1 ? getParam(url_search, 'gclid') : '';
257        method = 'gge_source';
258
259        // console.log(gclidSynapse);
260    } else if (getParam(url_search, 'gclid').length >= 1) {
261        gclid = getParam(url_search, 'gclid');
262        dplcsr = '';
263        dplcmd = '(not set)';
264        dplccn = 'undefined';
265        dplcct = '(none)';
266        gclidSynapse = getParam(url_search, 'gclid').length >= 1 ? getParam(url_search, 'gclid') : '';
267        method = 'gclid';
268    } else if (ref) {
269        // separate domain, path and query parameters
270        if (ref.indexOf('/') > -1) {
271            ref_domain = ref.substr(0, ref.indexOf('/'));
272            ref_path = ref.substr(ref.indexOf('/'));
273            method = 'ref';
274            if (ref_path.indexOf('?') > -1) {
275                ref_search = ref_path.substr(ref_path.indexOf('?') + 1);
276                ref_path = ref_path.substr(0, ref_path.indexOf('?'));
277            }
278        }
279        var search_engines = [['bing', 'q'], ['google', 'q'], ['yahoo', 'p'], ['baidu', 'q'], ['yandex', 'text'], ['ask', 'q'], ['duckduckgo', 'q'], ['naver', 'query'], ['baidu', 'wd']]; //List of search engines
280        // Tester le referral, est-ce organic ou referral
281        dplcmd = 'referral';
282        dplcsr = ref_domain;
283        dplcct = '(none)';
284        dplccn = '(referral)';
285        method = 'ref';
286        // Extract dplctr for organic dplcsr
287        for (var i = 0; i < search_engines.length; i++) {
288            if (ref_domain.indexOf(search_engines[i][0]) > -1) {
289                dplcmd = 'organic';
290                dplccn = '(not set)';
291                dplcsr = search_engines[i][0];
292                dplctr = getParam(ref_search, search_engines[i][1]) || '(not provided)';
293                break;
294            }
295        }
296    } else {
297        dplcsr = '(direct)';
298        dplccn = '(direct)';
299        dplcmd = '(none)';
300        method = 'direct';
301    }
302
303    return {
304        'gclid': gclid,
305        'dplcsr': dplcsr,
306        'dplccn': dplccn,
307        'dplcmd': dplcmd,
308        'dplctr': dplctr,
309        'dplcct': dplcct,
310        'gclidSynapse': gclidSynapse,
311        'method': method,
312    };
313
314}
315
316
317/* Search engine and campaing parse */
318function getTrafficSource(cookieName, hostname) {
319    var trafficSource = calculateTrafficSource();
320    var domaineHash = Math.floor((Math.random() * 10000000) + 1);
321    var dateNow = new Date().getTime() / 1000;
322
323    /* Let's create the variables*/
324    var gclid = trafficSource.gclid.length > 0 ? '.utmgclid=' + trafficSource.gclid : '';
325    var dplcsr = trafficSource.dplcsr.length > 0 ? '.utmcsr=' + trafficSource.dplcsr : '';
326    var dplccn = trafficSource.dplccn.length > 0 ? '|utmccn=' + trafficSource.dplccn : '';
327    var dplcmd = trafficSource.dplcmd.length > 0 ? '|utmcmd=' + trafficSource.dplcmd : '';
328    var dplctr = trafficSource.dplctr.length > 0 ? '|utmctr=' + trafficSource.dplctr : '';
329    var dplcct = trafficSource.dplcct.length > 0 ? '|utmcct=' + trafficSource.dplcct : '';
330    var gclidSynapse = trafficSource.gclidSynapse.length > 0 ? '|dplgclid=' + trafficSource.gclidSynapse : '';
331
332    var testData =
333        gclid +
334        dplcsr +
335        dplccn +
336        dplcmd +
337        dplctr +
338        dplcct +
339        gclidSynapse +
340        '';
341
342    var sessionVisit =
343        domaineHash +
344        '.' + dateNow +
345        '.' + '1' +
346        '';
347
348    var value =
349        sessionVisit +
350        testData +
351        '';
352
353    // console.log(trafficSource);
354
355    return decodeURIComponent(value);
356}
357
358
359/* generateCookie_dpl */
360function generateCookie_dpl() {
361    var date = new Date();
362    var fr_date = date.getUTCFullYear().toString() + ((date.getUTCMonth() < 9) ? '0' + (date.getUTCMonth() + 1).toString() : (d
362ate.getUTCMonth() + 1).toString()) + ((date.getUTCDate() < 10) ? '0' + date.getUTCDate().toString() : date.getUTCDate().toString());
363    var session = crumbleCookie()['__dplz'];
364    __dplf('__dplf');
365    __dplz('__dplz');
366    __dpla('__dpla');
367    __dplc('__dplc');
368    mobile_detect('mobile_detect');
369    first_page('first_page');
370}
371
372/* generateCookie_firstpage */
373function generateCookie_first_page() {
374    var date = new Date();
375    var fr_date = date.getUTCFullYear().toString() + ((date.getUTCMonth() < 9) ? '0' + (date.getUTCMonth() + 1).toString() : (date.getUTCMonth() + 1).toString()) + ((date.getUTCDate() < 10) ? '0' + date.getUTCDate().toString() : date.getUTCDate().toString());
376    var session = crumbleCookie()['first_page'];
377    first_page('first_page');
378}
379
380/* generateCookie_mobile_detect */
381function generateCookie_mobile_detect() {
382    var date = new Date();
383    var fr_date = date.getUTCFullYear().toString() + ((date.getUTCMonth() < 9) ? '0' + (date.getUTCMonth() + 1).toString() : (date.getUTCMonth() + 1).toString()) + ((date.getUTCDate() < 10) ? '0' + date.getUTCDate().toString() : date.getUTCDate().toString());
384    var session = crumbleCookie()['mobile_detect'];
385    mobile_detect('mobile_detect');
386}
387
388/* Let's cook */
389var gclidUrl = calculateTrafficSource('gclid')['gclid'];
390var methodUrl = calculateTrafficSource('method')['method'];
391
392
393if (handleVisEvt()) {
394    if (doSomething()) {
395        generateCookie_dpl();
396    }
397}
398
399if (document.cookie.indexOf('mobile_detect') <= 0) {
400    generateCookie_mobile_detect();
401}
402if (document.cookie.indexOf('first_page') <= 0) {
403    generateCookie_first_page();
404}

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.