Jump to content

Image Rotator - Need Help with java code


matafy

Recommended Posts

I have been looking for an image rotator that swaps images by date and time from my severs time set. Similar to what internet radio stations use for their DJs. I have yet to find the right one that works. Please forgive me for the example will be long.

 

Example:

 

Sun - 10 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-1.png"

1000 - 1100 = "image/DJ-2.png"

1100 - 1200 = "image/DJ-3.png"

1200 - 1300 = "image/DJ-4.png"

1300 - 1400 = "image/DJ-5.png"

1400 - 1500 = "image/DJ-6.png"

1500 - 1600 = "image/DJ-7.png"

1600 - 1700 = "image/DJ-8.png"

1700 - 1800 = "image/DJ-9.png"

1800 - 1900 = "image/DJ-10.png"

1900 - 2000 = "image/DJ-11.png"

2000 - 2100 = "image/DJ-12.png"

2100 - 0000 = "image/DJ-00.png"

 

Mon - 11 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-13.png"

1000 - 1100 = "image/DJ-14.png"

1100 - 1200 = "image/DJ-15.png"

1200 - 1300 = "image/DJ-16.png"

1300 - 1400 = "image/DJ-17.png"

1400 - 1500 = "image/DJ-18.png"

1500 - 1600 = "image/DJ-19.png"

1600 - 1700 = "image/DJ-20.png"

1700 - 1800 = "image/DJ-21.png"

1800 - 1900 = "image/DJ-22.png"

1900 - 2000 = "image/DJ-23.png"

2000 - 2100 = "image/DJ-24.png"

2100 - 0000 = "image/DJ-25.png"

 

Tue - 12 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-26.png"

1000 - 1100 = "image/DJ-27.png"

1100 - 1200 = "image/DJ-28.png"

1200 - 1300 = "image/DJ-29.png"

1300 - 1400 = "image/DJ-30.png"

1400 - 1500 = "image/DJ-31.png"

1500 - 1600 = "image/DJ-32.png"

1600 - 1700 = "image/DJ-33.png"

1700 - 1800 = "image/DJ-34.png"

1800 - 1900 = "image/DJ-35.png"

1900 - 2000 = "image/DJ-36.png"

2000 - 2100 = "image/DJ-37.png"

2100 - 0000 = "image/DJ-00.png"

 

Wed - 13 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-38.png"

1000 - 1100 = "image/DJ-39.png"

1100 - 1200 = "image/DJ-40.png"

1200 - 1300 = "image/DJ-41.png"

1300 - 1400 = "image/DJ-42.png"

1400 - 1500 = "image/DJ-43.png"

1500 - 1600 = "image/DJ-44.png"

1600 - 1700 = "image/DJ-45.png"

1700 - 1800 = "image/DJ-46.png"

1800 - 1900 = "image/DJ-47.png"

1900 - 2000 = "image/DJ-48.png"

2000 - 2100 = "image/DJ-49.png"

2100 - 0000 = "image/DJ-00.png"

 

Thur - 14 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-50.png"

1000 - 1100 = "image/DJ-51.png"

1100 - 1200 = "image/DJ-52.png"

1200 - 1300 = "image/DJ-53.png"

1300 - 1400 = "image/DJ-54.png"

1400 - 1500 = "image/DJ-55.png"

1500 - 1600 = "image/DJ-56.png"

1600 - 1700 = "image/DJ-57.png"

1700 - 1800 = "image/DJ-58png"

1800 - 1900 = "image/DJ-59.png"

1900 - 2000 = "image/DJ-60.png"

2000 - 2100 = "image/DJ-61.png"

2100 - 0000 = "image/DJ-00.png"

 

Fri - 15 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-62.png"

1000 - 1100 = "image/DJ-63.png"

1100 - 1200 = "image/DJ-64.png"

1200 - 1300 = "image/DJ-65.png"

1300 - 1400 = "image/DJ-66.png"

1400 - 1500 = "image/DJ-67.png"

1500 - 1600 = "image/DJ-68.png"

1600 - 1700 = "image/DJ-69.png"

1700 - 1800 = "image/DJ-70.png"

1800 - 1900 = "image/DJ-71.png"

1900 - 2000 = "image/DJ-72.png"

2000 - 2100 = "image/DJ-73.png"

2100 - 0000 = "image/DJ-00.png"

 

Sat - 16 March 2009

0000 - 0900 = "image/DJ-00.png"

0900 - 1000 = "image/DJ-74.png"

1000 - 1100 = "image/DJ-75.png"

1100 - 1200 = "image/DJ-76png"

1200 - 1300 = "image/DJ-77.png"

1300 - 1400 = "image/DJ-78.png"

1400 - 1500 = "image/DJ-79.png"

1500 - 1600 = "image/DJ-80.png"

1600 - 1700 = "image/DJ-81.png"

1700 - 1800 = "image/DJ-82.png"

1800 - 1900 = "image/DJ-83.png"

1900 - 2000 = "image/DJ-84.png"

2000 - 2100 = "image/DJ-85.png"

2100 - 0000 = "image/DJ-00.png"

 

and all over the following week... Keep in mind that every day will have a different image. And yes, I do have 365 images to swap. One for everyday of the year...

 

Can anyone help?

 

Thanks in advance,

Frank

Link to comment
Share on other sites

Maybe something along the lines of:

 

function change_image()
{
  var set_date = new Date();
  var start_date = set_date.setFullYear(put the start date you want here, 2009,5,01);

  var date_difference = Date() - start_date;

  var img_src = "image/DJ-" + date_difference + ".gif";

  document.getElementById('image_id').src=img_src;

}

window.onload = change_image();

 

I am very new to javascript, so this probably wont work, but its just an idea.

With this I am assuming that you can subtract dates from each other, and that it will return the number of days difference. As long as im correct in those assumptions, you just have to name your images the same, but just numbered at the end starting at 001, up to 365.

 

Theres a lot of assumptions there I know, but maybe it will help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.