home *** CD-ROM | disk | FTP | other *** search
/ PC User 2005 May / CD / PCU0505CD.iso / software / full / coffecup / files / html2005.exe / %MAINDIR% / Javascript / BackgroundInfoScroller.xml < prev    next >
Encoding:
Text File  |  2005-02-16  |  6.7 KB  |  222 lines

  1. <ccResource>
  2.   <ccTitle>
  3. Background Info Scroller
  4.   </ccTitle>
  5.   <ccCategory>
  6. Browser
  7.   </ccCategory>
  8.   <ccDescription>
  9.  This script scrolls information about your visitor in the background of your page.
  10.   </ccDescription>
  11.   <ccInstructions>
  12. Just put this script anywhere in the body of your pages code.
  13.   </ccInstructions>
  14.   <ccHeadContent>
  15.   </ccHeadContent>
  16.   <ccBodyContent>
  17. <SCRIPT LANGUAGE="JavaScript1.1">
  18. <!-- 
  19. var y
  20. var bgticker
  21. var newline = "\r\r"
  22. var now = new Date()
  23. var millinow=now.getTime()/1000
  24. var hours = now.getHours()
  25. var minutes = now.getMinutes()
  26. var seconds = now.getSeconds()
  27. var yourLocation=""
  28.     
  29. now.setHours(now.getHours()+1)
  30. var min=60*now.getUTCHours()+now.getUTCMinutes() + now.getUTCSeconds()/60;
  31.  
  32.  
  33. var clock = "It's exactly "+hours+":"+minutes+":"+seconds+" hours"    
  34. var browser = "You are using " + navigator.appName +" "+navigator.appVersion
  35. yourLocation="You are probably living in "+yourLocation
  36.     
  37. var winwidth= window.screen.width
  38. var winheight= window.screen.height
  39. var screenresolution= "Screen resolution: "+window.screen.width+" x "+window.screen.height
  40. var lastdoc = "You came from: "+document.referrer
  41.     
  42. var expDays = 30;
  43. var exp = new Date(); 
  44. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  45.  
  46. function Who(info){
  47.     var VisitorName = GetCookie('VisitorName')
  48.     if (VisitorName == null) {
  49.         VisitorName = "stranger";
  50.         SetCookie ('VisitorName', VisitorName, exp);
  51.      }
  52.         return VisitorName;
  53. }
  54.  
  55. function When(info){
  56.     // When
  57.     var rightNow = new Date()
  58.     var WWHTime = 0;
  59.     WWHTime = GetCookie('WWhenH')
  60.                 
  61.      WWHTime = WWHTime * 1                    
  62.       var lastHereFormatting = new Date(WWHTime);  // Date-i-fy that number
  63.     var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()
  64.     var lastHereInDateFormat = "" + lastHereFormatting;  // Gotta use substring functions
  65.     var dayOfWeek = lastHereInDateFormat.substring(0,3)
  66.        var dateMonth = lastHereInDateFormat.substring(4,11)
  67.        var timeOfDay = lastHereInDateFormat.substring(11,16)
  68.       var year = lastHereInDateFormat.substring(23,25)
  69.     var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay // display
  70.     SetCookie ("WWhenH", rightNow.getTime(), exp)
  71.     return WWHText;
  72. }
  73.  
  74. function Count(info){
  75.       var psj=0;
  76.        var WWHCount = GetCookie('WWHCount')
  77.     if (WWHCount == null) {
  78.         WWHCount = 0;
  79.     }
  80.       else{
  81.           WWHCount++;
  82.     }
  83.     SetCookie ('WWHCount', WWHCount, exp);
  84.     return WWHCount;
  85. }
  86.  
  87.  
  88.  
  89. function set(){
  90.        VisitorName = prompt("Who are you?");
  91.     SetCookie ('VisitorName', VisitorName, exp);
  92.     SetCookie ('WWHCount', 0, exp);
  93.     SetCookie ('WWhenH', 0, exp);
  94. }
  95.  
  96.         
  97. function getCookieVal (offset) {  
  98.      var endstr = document.cookie.indexOf (";", offset);  
  99.     if (endstr == -1)    
  100.     endstr = document.cookie.length;  
  101.     return unescape(document.cookie.substring(offset, endstr));
  102. }
  103.  
  104. function GetCookie (name) {  
  105.     var arg = name + "=";  
  106.     var alen = arg.length;  
  107.       var clen = document.cookie.length;  
  108.      var i = 0;  
  109.        while (i < clen) {    
  110.         var j = i + alen;    
  111.         if (document.cookie.substring(i, j) == arg)      
  112.               return getCookieVal (j);    
  113.              i = document.cookie.indexOf(" ", i) + 1;    
  114.               if (i == 0) break;   
  115.         }  
  116.         return null;
  117. }
  118.  
  119. function SetCookie (name, value) {  
  120.         var argv = SetCookie.arguments;  
  121.         var argc = SetCookie.arguments.length;  
  122.         var expires = (argc > 2) ? argv[2] : null;  
  123.         var path = (argc > 3) ? argv[3] : null;  
  124.         var domain = (argc > 4) ? argv[4] : null;  
  125.         var secure = (argc > 5) ? argv[5] : false;  
  126.         document.cookie = name + "=" + escape (value) + 
  127.         ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  128.         ((path == null) ? "" : ("; path=" + path)) +  
  129.         ((domain == null) ? "" : ("; domain=" + domain)) +    
  130.         ((secure == true) ? "; secure" : "");
  131. }
  132.  
  133. function DeleteCookie (name) {  
  134.     var exp = new Date();  
  135.     exp.setTime (exp.getTime() - 1);  
  136.     var cval = GetCookie (name);  
  137.     document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  138. }
  139.  
  140. var countvisits="You've been here " + Count() + " time(s). Last time was " + When() +"."
  141.  
  142. if (navigator.javaEnabled()) {
  143.    var javaenabled="Your browser is able to run java-applets";
  144. }
  145.  
  146. else {
  147.    var javaenabled="Your browser is not able to run java-applets";
  148. }
  149.  
  150.  
  151. function showAlert() {
  152.     var later = new Date()
  153.     var millilater=later.getTime()/1000 
  154.     var loadTime=(Math.floor((millilater-millinow)*100))/100
  155.     var loadTimeResult= "It took you "+loadTime+" seconds to load this page"
  156.     var babiesborn=Math.ceil(loadTime*4.18)
  157.     var babiesbornresult="While this page was loading "+babiesborn+" babies have been born"
  158.     if (babiesborn==1){babiesbornresult="While this page was loading "+babiesborn+" baby has been born"}
  159.     if (document.all) {
  160.         y = document.body.clientHeight
  161.         bgticker = document.all.bgtick.style    
  162.         bgticker.posLeft = 0    
  163.         bgticker.posTop = y    
  164. bgtick.innerHTML="<br><br>"+browser+".<br><br>"+clock+".<br><br>"+loadTimeResult+".<br><br>"+screenresolution+".<br><br>"+lastdoc+".<br><br>"+countvisits+"<br><br>"+javaenabled+".<br><br>"+babiesbornresult+".<br><br>And don't forget to download great software from www.coffeecup.com"    
  165.         document.all.mainbod.style.posLeft = 0    
  166.         document.all.mainbod.style.posTop = 0
  167.     }
  168.     if (document.layers) {
  169.         y=300
  170.         bgticker = document.bgtick
  171.         bgticker.left = 0
  172.         bgticker.top = y
  173.         document.bgtick.document.write("<span style='font-size:50pt;color:AAAAAA'>"+browser+".<br><"+clock+".<br><"+loadTimeResult+".<br>"+internetTime+".<br>"+screenresolution+".<br>"+lastdoc+".<br>"+countvisits+".<br>"+javaenabled+".<br>"+babiesbornresult+".<br></span>")
  174.         document.close()
  175.         document.mainbod.left = 0    
  176.         document.mainbod.top = 0
  177.     }
  178.     scroll()
  179. }
  180.  
  181. function scroll() {
  182.     if (y > -1200) {
  183.         y=y-2
  184.         if (document.all) {bgticker.posTop = y; document.all.mainbod.style.posTop=0}
  185.         if (document.layers) {bgticker.top = y; document.mainbod.top=0}
  186.     }        
  187.     else {
  188.         if (document.all){y=document.body.clientHeight}
  189.         if (document.layers){y=300}
  190.     }
  191.     var timer = setTimeout('scroll()',20)
  192. }
  193.  
  194. // - End of JavaScript - -->
  195. </SCRIPT>
  196.  
  197. <STYLE>
  198. .ticker {
  199. position: absolute;
  200. top:1200px;
  201. font-family:arial;
  202. font-weight:bold;
  203. font-size:40px; 
  204. color:DDDDDD;
  205. }
  206. </STYLE>
  207.  
  208. <div id="bgtick" class="ticker"> </div>
  209. <div id="mainbod" style="position:absolute; visibility:visible">
  210.  
  211. </div>
  212.   </ccBodyContent>
  213.   <ccElementContent>
  214.   
  215.    <ccElementName>onLoad</ccElementName>
  216.    <ccElementAction>showAlert()</ccElementAction>
  217.    
  218.   </ccElementContent>
  219.   <ccExtraData>
  220.  
  221.   </ccExtraData>
  222. </ccResource>