home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 2001 May / cd49www.iso / poland / gotowanietosztuka / www.mystat.pl / count.js
Text File  |  2001-03-01  |  4KB  |  133 lines

  1. <!--
  2.    var par = "";
  3.    var r = "";
  4.    var sc = window.screen.width+"x"+window.screen.height;
  5.    var col = window.screen.colorDepth;
  6.    var link = "y";   
  7.    var width = "";
  8.    var height = "";
  9.    var size = "";
  10.    var mouse_over = false;
  11.    var live_counter = 0;
  12.    var monerror = null;
  13.    var objerror = window;
  14.  
  15.    function setCookie(name, value, expires, path, domain, secure) {
  16.       var curCookie = name + "=" + escape(value) +
  17.           ((expires) ? "; expires=" + expires.toGMTString() : "") +
  18.           ((path) ? "; path=" + path : "") +
  19.           ((domain) ? "; domain=" + domain : "") +
  20.           ((secure) ? "; secure" : "");
  21.       document.cookie = curCookie;
  22.    }
  23.  
  24.    function getCookie(name) {
  25.       var dc = document.cookie;
  26.       var prefix = name + "=";
  27.       var begin = dc.indexOf("; " + prefix);
  28.       if (begin == -1) {
  29.          begin = dc.indexOf(prefix);
  30.          if (begin != 0) return null;
  31.       } else begin += 2;
  32.       var end = document.cookie.indexOf(";", begin);
  33.       if (end == -1) end = dc.length;
  34.       return unescape(dc.substring(begin + prefix.length, end));
  35.    }
  36.  
  37.    function deleteCookie(name, path, domain) {
  38.       if (getCookie(name)) {
  39.          document.cookie = name + "=" + 
  40.          ((path) ? "; path=" + path : "") +
  41.          ((domain) ? "; domain=" + domain : "") +
  42.          "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  43.       }
  44.    }
  45.    
  46.    function fixDate(date) {
  47.       var base = new Date(0);
  48.       var skew = base.getTime();
  49.       if (skew > 0) date.setTime(date.getTime() - skew);
  50.    }
  51.    
  52.    function writeOnMouseOver() {
  53.       if (!mouse_over) {
  54.          return "";
  55.       }
  56.       else {
  57.          return "onmouseover=\"mystatCountMouseOver()\"";
  58.       }
  59.    }
  60.      
  61.    function mystatLiveCounter() {
  62.       if (Math.round(live_counter) > 0) {
  63.          mystatReloadCounter();
  64.          setTimeout("mystatLiveCounter()", 1000*Math.round(live_counter)*10);
  65.       }
  66.    }
  67.    
  68.    function mystatReloadCounter() {
  69.       document.mystat_count_img.src = "http://www.mystat.pl/servlet/count.gif"+par+"&filtered=1";
  70.    }
  71.    
  72.    function writeCode() {
  73.       var mystat_new_visitor = getCookie("mystat_n");
  74.       if (!mystat_new_visitor) {
  75.          mystat_new_visitor = 1;
  76.       }
  77.       var now = new Date();
  78.       fixDate(now);
  79.       now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
  80.       setCookie("mystat_n", 0, now);
  81.       if (par.indexOf("mouse=t") != -1) {
  82.          mouse_over = true;
  83.       }
  84.       document.write("<a href=\"http://www.mystat.pl/stat.jsp"+par+"\" target=\"_blank\"");
  85.       if (mouse_over) {
  86.          document.write(" onmouseover=\"mystatReloadCounter()\"");
  87.       }
  88.       document.write(">");
  89.       if (par.indexOf("live=") != -1) {
  90.          var live_val = par.substring(par.indexOf("live="));
  91.          if (live_val.indexOf("&") != -1) {
  92.             live_val = live_val.substring(5,live_val.indexOf("&"));
  93.          }
  94.          else live_val = live_val.substring(5);
  95.          if (!isNaN(live_val)) {
  96.             live_counter = live_val;
  97.          }
  98.       }      
  99.       par = par+"&sc="+sc+"&col="+col+"&r="+r+"&nv="+mystat_new_visitor;
  100.       if (width != "" && height != "") {size = "width=\""+width+"\" height=\""+height+"\""}
  101.       else size = "";
  102.       document.write("<img name=\"mystat_count_img\" src=\"http://www.mystat.pl/servlet/count.gif"+par+"\" border=\"0\" "+size+">");
  103.       document.write("</a>");
  104.       if (document.URL.indexOf("www.koma.hg.pl") == -1) {
  105.          document.write("<");document.write("!--  ");
  106.       }
  107.       if (Math.round(live_counter) > 0) {
  108.          window.setTimeout("mystatLiveCounter()", 1000*Math.round(live_counter)*10);
  109.       }      
  110.    }
  111.  
  112.    function writeMyStatPrvPl() {
  113.       r = escape(document.referrer);
  114.       writeCode();
  115.    }      
  116.  
  117.    function writeMyStatError(message, url, line) {
  118.       writeCode();
  119.       window.onerror = monerror;
  120.       return true;
  121.    }                       
  122.  
  123.    function writeMyStat() {
  124.       monerror = window.onerror;
  125.       window.onerror = writeMyStatError;      
  126.       r = escape(document.referrer);
  127.       r = escape(top.document.referrer);
  128.       writeCode();
  129.       window.onerror = monerror;
  130.    }      
  131.  
  132. //-->
  133.