Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to tweak Windows 7 clock gadget to make it 24 hours?

    Hi guys
    I've recently discovered and fell in love with 24 hour analog clocks and watches, and I'd like to tweak the standard clock gadget on windows 7 so that, basically, the hour hand would rotate at half its usual speed.
    I've done a little reading on gadgets and have found it easy to change the gadget graphically (I've swapped the background image to a 24 hour face and have modified the hour and minute hands). However, I've never worked with javascript before, but looking into the "clock.js" file I get the feeling that I would only need to change a little bit of the "timePerInterval()" function, but I have no idea what.
    What do you guys think? Is it possible to edit it as I want? I hope it's nothing too complex.

    Thanks for the help!

    P.S. The file "clock.js" I mentioned lies in "C:\Program Files\Windows Sidebar\Gadgets\Clock.Gadget\en-US\js"

    P.P.S. I would have copied the part of the script that I was referring to, but I don't know if that's alright. Is it frowned upon, what with copyright restrictions, or is it ok if it's just a part of the file and not the entire script?
    Last edited by andreii_1989; 02-27-2013 at 09:36 AM.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,355
    Thanks
    11
    Thanked 558 Times in 551 Posts
    You're right, you should tweak the clock.js

    Try this
    Code:
    ////////////////////////////////////////////////////////////////////////////////
    //
    // calculate current time
    //
    ////////////////////////////////////////////////////////////////////////////////
    function timePerInterval()
    {
    	refreshDate();
    	with (date)
    	{
    		hours = getHours();
    		minutes = getMinutes();
    		seconds = getSeconds();
    	}
    	
    	var rotationHours = hours;
    
    	// if (hours > 12)
    	// {
    		// rotationHours = hours - 12;
    	// }
    	
    	h.Rotation = (rotationHours * 15) + (minutes / 4);
    	m.Rotation = (minutes * 6) + (seconds / 10);
    		
    	if (mySetting.secondsEnabled)
    	{
    		s.Rotation = (seconds * 6);
    
    		var secondOffset = secondTimeOffset();
    			
    		if (secondOffset > 0)
    		{
    			newTimeOut = setTimeout("timePerInterval()", secondOffset);
    		}
    		else
    		{
    			timePerInterval();
    		}
    	}
    	else
    	{
    		var minuteOffset = minuteTimeOffset();
    		
    		if (minuteOffset > 0)
    		{
    			newTimeOut = setTimeout("timePerInterval()", minuteOffset);
    		}
    		else
    		{
    			timePerInterval();
    		}
    	}
    }
    Basically I have removed (commented) the lines to subtract 12 from hours greater than 12, because it is not needed any more. And then I have changed the line to calculate the rotation angle of the hour hand to half the usual speed (15 degrees per hour and 1 degree every 4 minutes instead of 30 degrees per hour and 1 degree every two minutes)

  • Users who have thanked devnull69 for this post:

    andreii_1989 (02-27-2013)

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This is exactly what I was looking for, devnull69. I had also realised that I needed to remove the "if (hours>12)" clause but I completely failed to see that the "h.Rotation = (rotationHours * 30) + (minutes / 2)" bit was meant as degree positioning. It's so obvious now that you've explained it!
    Thank you very much for the help!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •