It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Clock

Clock

Postby Johnathan on Fri Feb 15, 2008 2:50 am

Hey, I need a clock that shows in 12 or 24 hour time that people on the site can choose and I need the site to remember their choice. and actually updates just minutes. Also I need to be able to move it and set it on top of an image, I know this isn't JS but how do I do that once I get the clock.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Postby webmaster on Fri Feb 15, 2008 9:20 am

There are two easy ways for this. The first one is to save a cookie on the users computer with the setting for that user. The downside is that if he/she clears all cookies, the settings are back to default.

Another way is to save that user to a database with his/her prefered setting. You can save the IP and then set how the clock should look like for that IP. The downside is that many people have dynamic IPs.


I got an idea while writing this, I don't know how many countries that uses the different hour settings. But you could get a geoIP-dtabase, which checks which country the user are from, if they are from the US, it will display a 12 hour clock, if they are from europe, it will display a 24 hour clock. This is just for the "default" setting, you can still use one of the mentioned alternatives above for the customization.

I recommend the first one with cookies by the way!
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby leonard on Fri Feb 15, 2008 9:22 am

Hey Johnathan

I don't have a clock example, but to your other question:

You can use the css-attribute "position" to place your layer (containing the clock) anywhere you want. Use absolute or relative positioning depending on how your site is built.
Code: Select all
style="position:relative;"

If you want to place it dynamically around the page, you can use javascript to move it around.

Here's an example:
http://devppl.chew.ch/layers/layerOverImage.html

about the clock:
If you use a javascript-clock, the time will probably be based on the client-pc (which can be completely wrong).
If you want the time based on the server-time, you might want to search google for something like 'AJAX-clock'.

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby Johnathan on Fri Feb 15, 2008 12:53 pm

Ok thanks alot guys, I like your idea webmaster of having it set for US and Europe, and still let them change it. Where can I learn about cookies and how easy would that be? I should be able to find the CSS stuff easy enough, I have a book lying around here somewhere. O and could I have a thing that lets them select their own background from a list of ones that I already have or let them link to their own, and I need them to be saved for them next time aswell.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland


Who is online

Users browsing this forum: No registered users and 4 guests