PDA

View Full Version : Need Help with this scripts please



ADUN
12-28-2005, 03:53 PM
Hello guy's, how are you?

I'm really going to appreciate if you help me just a bit, k?

I am looking for an image script that changing background image between hours;

between 6AM to 6PM Pic number will be on the site background... and between 6PM to 6AM pic number 2 will be on the backgoround.

I searched ALL OVER the internet and i didnt find this script yet.
This script DO exist.... but i'm not a scripts builder....

PLEASE PLEASE PLEASE I'M BEGGING YOU!
Help me fund this script... PLEASE !

Ickyb0d
12-28-2005, 06:25 PM
6am - 6pm user time... or server time?

ADUN
12-28-2005, 08:11 PM
User time. please.

12345c
12-28-2005, 10:32 PM
It is easier to write it, than to find :)
On each page of a site you might write a code (or in <script src=code.js> </script>)
<script>A=[new Image(),new Image()];A[0].src='snow.gif';A[1].src='snow21.gif'; //'snow.gif' is from 6AM to 6PM
onload=function(){
document.body.background=A[((D=new Date().getHours())<6||D>=18)+0].src;
}
</script>
<body> ...

ADUN
12-29-2005, 05:04 PM
Hello,

First, i want to THX you very much for helping me and spending your time for me:)

Now, i check it out and it works! OMG MAN THX SO MUCH!:o
But if you mind, i need just alittle bit more of your good help.

I need a script, the same as this Image changing by time script, but Music script! i want to do a script that play 2 different music between 6AM to 6PM and the opposite....

I'm sure its gonna be a piece of cake for pro like you:)

Btw, you dont jave to answer this, but i'm just asking, there is any way to make this image script you gave above, to change between 3 times a day? like feom 6AM to 12AM *Image1*. from 12AM to 8PM *Image2*. from 8PM to 6AM *Imahe3*...

This is possible for images and music script?

THX again for your good help:o

12345c
12-29-2005, 07:40 PM
Certainly, script can manage everything both with pictures, and with music. For example, there is demo code where background varies each 3 seconds.

But music has such feature, that it works not on all computers and not in all browsers. There can even be error messages which will prevent to look content. There are many ways to start music, but they differ even what player is established - MS mediaplayer or Apple QuickTime or other.

I tried to start in different browsers such code:
<embed id=snd src=your_media_file.mp3 autostart=false height=42 loop=true controller=true hid den=true></embed><br>
<input type=button onClick=d.getElementById("snd").Play(); value=Play>
<input type=button onClick=d.getElementById("snd").Stop(); value=Stop>
<input type=button onClick=d.getElementById("snd").Rewind(); value=Rewind)>
If it will work from the button with the help of the code specified in tag of the button, it is possible to start one or other melody (from other embed tag). They may be invisible if write "hidden=true". (But will play in IE only.)

Here is script with optimization - it won't be preload all images, but only one according to time of day:
<script>D=new Date().getHours();
A=new Image();
onload=function(){
if(D>=6&&D<12){A.src='snow1.gif';document.body.background=A.src;} //bg 6-12AM
if(D>=12&&D<20){A.src='snow2.gif';document.body.background=A.src;} //bg from 12AM to 8PM
if(D>=20||D<6){A.src='snow3.gif';document.body.background=A.src;} //bg from 8PM to 6AM

if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>
<body><embed id=snd1 src=snd1.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<embed id=snd2 src=snd2.wav autostart=false height=1 width=1 loop=true controller=false></embed>
<input type=button onClick=document.getElementById("snd1").Stop();document.getElementById("snd2").Stop(); value=Stop_Music>(I cannot speak reliably without the checked up example, therefore it's present:) )

ADUN
12-29-2005, 09:13 PM
Ok man,

Its amazing how you can play with this image script... you GOOD...! :o
Lets put the music script a side for now...

Can you tell me how to chagne hours and add/remove more images in the script please?

(Thx :))

12345c
12-30-2005, 10:18 AM
Don't mention it :)
> to chagne hours and add/remove more images
it's simply.
"D" contain a hour (0-23). You write logical expression with "D": D>=6&&D<12
or
D>=20||D<6 .
Desirable picture is put instead of this: A.src='snow1.gif';

ADUN
12-30-2005, 01:05 PM
Damn man you really good, it really work!
This is the new script:




<script>D=new Date().getHours();
A=new Image();
onload=function(){

if(D>=6&&D<12){A.src='Pic.JPG';document.body.background=A.src;} //bg 6AM-12AM
if(D>=12&&D<15){A.src='Pic.JPG';document.body.background=A.src;} //bg from 12AM to 3PM
if(D>=15&&D<18){A.src='Pic.JPG';document.body.background=A.src;} //bg from 3PM to 6PM
if(D>=16&&D<20){A.src='Pic4.JPG';document.body.background=A.src;} //bg from 6PM to 8PM
if(D>=20||D<6){A.src='Pic.JPG';document.body.background=A.src;} //bg from 8PM to 6AM

if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>

Pic



Is this allright?

Next and last thing. before the final Thx.. :)
I want the same changing script, but for MP3... i want to make this coolo effect of birds at day time and cricket at night...

is this possible?
[/QUOTE]

12345c
12-30-2005, 05:45 PM
Thx, thin flatteral praise ;)
> I want the same changing script, but for MP3
Strings
if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document. ....
are for sound, but you should add 2 lines below tag <body>:

if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>
<body>

...

<embed id=snd1 src=__birds__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<embed id=snd2 src=__cricket__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<input type=button onClick=document.getElementById("snd1").Stop();document.getElementById("snd2").Stop(); value=Stop_Music>
Button is necessary for stopping.

ADUN
12-30-2005, 06:07 PM
Man, i didnt understand the last scripts you gave here... :)

i want the same effect but in MP3... dont wirte it here so freely, like half script because i dont know how to complete it like you.

I just want the same effect, as well to know how to add/remove mp3's and change hours.

Thx very much for your kind help :o

12345c
12-30-2005, 10:04 PM
Without images or with? I append your version for both effects. If you need mp3 only, write this:
<script>
onload=function(){if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>
<body>

...(Your content)

<embed id=snd1 src=__birds__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<embed id=snd2 src=__cricket__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<input type=button onClick=document.getElementById("snd1").Stop();document.getElementById("snd2").Stop(); value=Stop_Music> Full code with both effects will be:

<script>D=new Date().getHours();
A=new Image();
onload=function(){

if(D>=6&&D<12){A.src='Pic.JPG';document.body.background=A.src;} //bg 6AM-12AM
if(D>=12&&D<15){A.src='Pic.JPG';document.body.background=A.src;} //bg from 12AM to 3PM
if(D>=15&&D<18){A.src='Pic.JPG';document.body.background=A.src;} //bg from 3PM to 6PM
if(D>=16&&D<20){A.src='Pic4.JPG';document.body.background=A.src;} //bg from 6PM to 8PM
if(D>=20||D<6){A.src='Pic.JPG';document.body.background=A.src;} //bg from 8PM to 6AM

if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>
<body>

...

<embed id=snd1 src=__birds__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<embed id=snd2 src=__cricket__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<input type=button onClick=document.getElementById("snd1").Stop();document.getElementById("snd2").Stop(); value=Stop_Music>

ADUN
12-31-2005, 07:03 AM
Well sh*t... lol man, you are one masterpiece,
The Image script is a script that was looking for a long time, for that i owe you!

But i'm not like to be a burden for you, so last thing i need to ask you:
How i can add and remove more .mp3, and set time for each song? (you didnt wrote it there)

Thx alot!

12345c
12-31-2005, 01:47 PM
Thanks, me does not complicate it:)
You should add some lines of a kind:
<embed id=snd396 src=__birds__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
and some lines
if(D<6||D>=20)setTimeout('document.getElementById("snd396");Play();',1999); //snd 20-6with same id in pair but different ids among pairs (did I correctly speak?), and add corresponding text of a kind
document.getElementById("snd396").Stop();to Stop button.
I hope, all will turn out. Happy New Year! :)

ADUN
12-31-2005, 03:51 PM
Happy new year man:)

And the script need to look like this or somting?

<embed id=snd396 src=__birds__.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
if(D<6||D>=20)setTimeout('document.getElementById("snd396");Play();',1999); //snd 20-6

12345c
01-01-2006, 09:53 PM
Yes, plus string
<input type=button
onClick=document.getElementById("snd396").Stop(); value=Stop_Music>for stopping.

This script has small lack. When melodies are 2 or more, all of them will be loaded from a site, and one will play only. If files are small, lack will be small. If big, it is necessary to make this script by another