Advertisement
Guest User

Untitled

a guest
Jun 4th, 2013
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  
  3.  window.onload = function() {
  4.     /* set your parameters(
  5.     number to countdown from,
  6.     pause between counts in milliseconds,
  7.     function to execute when finished
  8.     )
  9.     */
  10.    // startCountDown(15, 1000, myFunction);
  11.     }
  12.  
  13.     function startCountDown(i, p, f) {
  14.        
  15.     // store parameters
  16.     var pause = p;
  17.     var fn = f;
  18.     // make reference to div
  19.     var countDownObj = document.getElementById("countDown");
  20.     if (countDownObj == null) {
  21.     // error
  22.     alert("div not found, check your id");
  23.     // bail
  24.     return;
  25.     }
  26.     countDownObj.count = function(i) {
  27.     // write out count
  28.     countDownObj.innerHTML = i;
  29.     if (i == 0) {
  30.     // execute function
  31.     fn();
  32.     // stop
  33.     return;
  34.     }
  35.     setTimeout(function() {
  36.     // repeat
  37.     countDownObj.count(i - 1);
  38.     },
  39.     pause
  40.     );
  41.     }
  42.     // set it going
  43.     countDownObj.count(i);
  44.     }
  45.  
  46.     function myFunction() {
  47.     //alert("hi alex");
  48.    
  49.     ShowOptions(1);
  50.     }
  51. function popUpClosed() {
  52.     window.location.reload();
  53. }
  54. var ajaxObj=new getAjaxObject();
  55.  
  56. function getAjaxObject()
  57.         {
  58.           var XMLHttpRequestObject = false;
  59.           if (window.XMLHttpRequest)
  60.               {
  61.                  XMLHttpRequestObject = new XMLHttpRequest();
  62.               }
  63.               else if (window.ActiveXObject)
  64.               {
  65.                  XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  66.               }
  67.               if (!XMLHttpRequestObject)
  68.               {
  69.                  alert("Your browser does not support Ajax.");     return false;
  70.               }
  71.           return XMLHttpRequestObject;
  72.         }
  73. //var loads=false;
  74. function createpopup(website)
  75. {
  76.     //alert('popup');
  77.     document.getElementById('webframe').src=website;
  78. //popupWindow = window.open(website,'mypopup','width=400,height=400');
  79. //popupWindow.onclose=function(){alert('unload');} 
  80. //popupWindow.onclose = function(){ alert('unload');}
  81. //popupWindow.onbeforeunload=function(){ alert('unload');}
  82. }
  83. function closeMe(evt) {
  84.     alert('ff');
  85.     /*if (typeof evt == 'undefined') {
  86.         evt = window.event; }
  87.     if (evt && evt.clientX >= (window.event.screenX - 150) &&
  88.         evt.clientY >= -150 && evt.clientY <= 0) {
  89.         return "Do you want to log out of your current session?";
  90.     }*/
  91. }
  92. var callback = function(){
  93.   //alert("foo");
  94.   window.location.reload();
  95. };
  96. function pollForWindowClosure(){
  97.   if(popupWindow.closed){
  98.     callback();
  99.     return;
  100.   }
  101.  
  102.   setTimeout(pollForWindowClosure, 10);
  103. }
  104.  
  105.  
  106. function changepopupurl(website)
  107. {
  108.     //window.popupWindow.location=website;
  109.     document.getElementById('webframe').src=website;
  110.     //popupWindow.onbeforeunload = function(){ alert('unload');}
  111. ///popupWindow = window.open(website,'mypopup','width=400,height=400');
  112. }
  113. function ShowOptions(id)// kahi se call karo is ko
  114.     {
  115.     //alert(id);
  116.    
  117.    
  118.         var limm= document.getElementById('sit').value;
  119.      //popupWindow = window.open('childpage.php?lim='+limm,'name','width=400,height=400');
  120.      //if(loads)
  121.     // {
  122.     //window.opener.location.href='http://www.google.com';
  123.     //alert('window');
  124.     //}
  125.     var xmlHTTPObject=new getAjaxObject();
  126.      var lim= document.getElementById('site').value;
  127.          var limm= document.getElementById('sit').value;
  128.           var website= document.getElementById('siturl').value;
  129.         // var website="<?php //echo SITE_URL;?>/web.php?wid="+limm;
  130.           //alert(website);
  131.    
  132.         if(id==0)
  133.         {
  134.             //Opt();
  135.            
  136.  
  137.         //loads=true;
  138.          createpopup(website);
  139.          //pollForWindowClosure();
  140.         }
  141.         else
  142.         {
  143.             changepopupurl(website);
  144.         }
  145.    
  146.      var url='get.php?lim='+lim;
  147.      var parameters='123';
  148.      //alert(url);
  149.       var timers;
  150.         if(xmlHTTPObject)
  151.            {
  152.               if (xmlHTTPObject.readyState == 4 || xmlHTTPObject.readyState == 0)
  153.               {//alert(xmlHTTPObject.readyState);
  154.                    xmlHTTPObject.open("GET", url, true);
  155.                  // alert('open');
  156.                   xmlHTTPObject.onreadystatechange =function()
  157.                     {
  158.                         if (xmlHTTPObject.readyState == 4)
  159.                            {
  160.                               if (xmlHTTPObject.status == 200)
  161.                               {
  162.                                 try
  163.                                     {
  164.                                          var XMLResponse = xmlHTTPObject.responseText;
  165.                                          timers =XMLResponse;
  166.                                          document.getElementById('sites').innerHTML=XMLResponse;
  167.                                          var countDowntime=document.getElementById('countDowntime').value;
  168.                                          //alert(XMLResponse);
  169.                                          Opt(countDowntime);
  170.                                          startCountDown(countDowntime, 1000, myFunction);
  171.                                 }
  172.                                 catch(e){}
  173.                               }
  174.                            }  
  175.                     };
  176.                  xmlHTTPObject.send(null);
  177.               }
  178.             }
  179.                 //setTimeout ( "ShowOptions(1)", 20000);
  180.                 return false;  
  181.        
  182.    
  183.     }
  184. function Opt(countDowntime)// kahi se call karo is ko
  185.     {
  186. var xmlHTTPObject=new getAjaxObject();
  187.          var url='update.php?countDowntime='+countDowntime;
  188.      var parameters='123';
  189.       var timers;
  190.   if(xmlHTTPObject)
  191.            {
  192.               if (xmlHTTPObject.readyState == 4 || xmlHTTPObject.readyState == 0)
  193.               {
  194.                    xmlHTTPObject.open("GET", url, true);
  195.                     xmlHTTPObject.onreadystatechange = function ()
  196.                     {
  197.                         if (xmlHTTPObject.readyState == 4)
  198.                            {
  199.                               if (xmlHTTPObject.status == 200)
  200.                               {
  201.                                 try
  202.                                     {
  203.                                          var XMLResponse = xmlHTTPObject.responseText;
  204.                                             //alert(XMLResponse);                  
  205.                                     }
  206.                                 catch(e){}
  207.                               }
  208.                            }  
  209.                     };
  210.                  xmlHTTPObject.send(null);
  211.               }
  212.             }
  213.             //setTimeout ( "ShowOptions()", 200000);
  214.                 return false;  
  215. }  
  216.  window.onload = function() {
  217.     /* set your parameters(
  218.     number to countdown from,
  219.     pause between counts in milliseconds,
  220.     function to execute when finished
  221.     )
  222.     */
  223.    // startCountDown(15, 1000, myFunction);
  224.    ShowOptions('0');
  225.     }
  226. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement