create a countdown clock

Discussion in 'Green Room' started by ElementalDragon, Oct 22, 2004.

  1. ElementalDragon

    ElementalDragon The One and Only

    Messages:
    3,159
    Location:
    Lehighton, PA
    anyone know how to create a countdown clock in Samurize or something else that can be seen right on the desktop? kinda want one so i know when HL2 is out. there's one on planethalflife.com near the picture of the day if you wanna see it.
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Easiest way to do it, yoink their code.

    Timer: link
    Code:
    Code:
    <script>
    var timerID = null;
    var timerRunning = false;
    
    function startClock() {
    	stopClock();
    	timeRemaining();
    }
    
    function stopClock() {
    	if (timerRunning)
    	clearTimeout(timerID);
    	timerRunning = false;
    }
    
    function timeRemaining() {
    	var now = new Date();                                
    	var then = new Date(2004, 10, 15, 23, 59, 59);  
    	var yearsLeft; var daysLeft; var hoursLeft; var minsLeft; var secsLeft;
    	secsLeft = Math.round(then.getTime() - (now.getTime() + 1000)) / 1000;
    	daysLeft = Math.floor(secsLeft / 86400);  
    	secsLeft %= 86400;
    	hoursLeft = Math.floor(secsLeft / 3600);      
    	secsLeft %= 3600;
    	minsLeft = Math.floor(secsLeft / 60);         
    	secsLeft %= 60;
    	secsLeft = Math.round(secsLeft);
    	
    	if (secsLeft == 60) {
    		secsLeft = 0;
    		minsLeft = minsLeft++;
    	}
    	
    	if (minsLeft == 60) {
    		minsLeft = 0;
    		hoursLeft = hoursLeft++;
    	}
    	
    	if (hoursLeft == 24) {
    		hoursLeft = 0;
    		daysLeft = dayssLeft++;
    	}
    	
    	document.doomsday.total.value = (daysLeft + " days, " + hoursLeft + " hrs, " + minsLeft + " min, " +  secsLeft + " sec");
    	
    	timerID = setTimeout("timeRemaining()", 1000);
    	timerRunning = true;
    }
    
    window.onload=startClock;
    
    </script>
    
    <form name="doomsday">Time Remaining:&nbsp;<input readonly="true" type="text" name="total" size="27" style="border: 0px; background-color: #EAEAEA; font-size: 8pt;"></form>
    then add it as an active desktop item.
     
  3. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    I have a similar idea for Halo 2, don't know if I'll ever get around to actually doing it though :p
     
  4. ElementalDragon

    ElementalDragon The One and Only

    Messages:
    3,159
    Location:
    Lehighton, PA
    speedy, any way you could add that to an active script file so i could use it wit Samurize?
     
  5. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    I have absolutely no idea how the monkey Samurize works. If it's HTML based, is there no way of importing that code/file ?
     
  6. ElementalDragon

    ElementalDragon The One and Only

    Messages:
    3,159
    Location:
    Lehighton, PA
    your guess is good as mine. lol. i didn't do that much of my own configuring. just needs to be a working .vbs file i think.