tora
tora

Reputation: 31

Dynamic clock: image change by computer's clock

I want an image to change every minute according to a user's clock. Moreover, I would like the image to be tied to a specific HH:MM. So when the computer moves from 3:00pm to 3:01pm ...back to 2:59pm, I would like the image to move from 0001.jpg to 0002.jpg....to 1440.jpg. Then have the process repeat with 3:00pm and 0001.jpg. The idea is that the sequence does not start over at 0001.jpg each time the user browses to the site.

I would like to know if:

  1. javascript or php is better
  2. I should put all 1440 jpg images in an array or a data base

Thank you,

tora

Upvotes: 0

Views: 894

Answers (2)

psema4
psema4

Reputation: 3047

Here's how I'd approach it, in a nutshell:

  1. Make sure your webserver is configured to send caching information so the browser doesn't have to load any image more than once for at least several days. 500k * 1440 = a lot of bandwidth.

  2. Use javascript; every t minutes start a batch download and get the images you need for the next t minutes, storing them in an array.

  3. Every 60 seconds, pop an image off your stack and into your UI.

Upvotes: 1

codeandcloud
codeandcloud

Reputation: 55210

1440 images is definitely not the way to approach this.
If you are into HTML5, http://ineedmoretime.org/ has a cool implementation.

It can be easily reproduced. ( Watch link at Chrome / Safari / Firefox as it needs SVG)
Created a fiddle for that: http://jsfiddle.net/naveen/kx5cT/

P.S: I am hot linking http://ineedmoretime.org/images/clock-background.png as of now in the javascript. Please place it in your on folder.

Upvotes: 0

Related Questions