summary refs log tree commit diff
path: root/doc/Viewing Large Images with Seadragon and Pythonhtml_files/analytics.js
blob: 3aa054e1aea23d2add46c02321941c3e96fc427c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var _amefin = {
  pingImage: null,
  setZoneId: function(zoneId)
  {
    this.zoneId = zoneId;
    return this;
  },
  shouldUseCurrent: false,
  setUseCurrent: function(shouldUseCurrent)
  {
    this.shouldUseCurrent = shouldUseCurrent;
    return this;
  },
  searchToUse: null,
  useSearch: function(searchToUse)
  {
    this.searchToUse = searchToUse;
    return this;
  },
  isSearchReferrer: function()
  {
    var engines = ["google", "search\\.yahoo", "search\\.msn", "search\\.live", "search\\.aol", "ask\\.com", "searchservice\\.myspace", "facebook"];

    for(var i = 0; i < engines.length; i++)
    {
      var regexString = "^http:\\/\\/(www\\.)?" + engines[i];
      if(engines[i] != "ask\\.com")
      {
        regexString += "\\.";
      }
      var regex = new RegExp(regexString, "i");
      if(regex.test(this.shouldUseCurrent ? document.URL : document.referrer))
      {
        return true;
      }
    }
    return false;
  },
  track: function()
  {
    if(this.searchToUse || this.isSearchReferrer())
    {
      document.write("<script src='http://amefin.com/analytics?url=" + encodeURIComponent(document.URL) + "&referrer=" + encodeURIComponent(document.referrer) + "&search=" + this.searchToUse + "&shouldUseCurrent=" + this.shouldUseCurrent + "&zoneId=" + this.zoneId + "&width=" + screen.width + "&height=" + screen.height + "' type='text/javascript'></script>");
    }
    return this;
  },
  druvoid: function()
  {
    return this;
  },
  hit_pixel: function(slot, url)
  {
    var pix = new Image(1,1);
    pix.alt = '';
    pix.src = url;
    pix.onload = function () {_amefin.druvoid();};
    this[slot] = pix;
  }
}