Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Time Based Graphic Change Every Sunday?

Reply
Thread Tools

Time Based Graphic Change Every Sunday?

 
 
Gary Jackson
Guest
Posts: n/a
 
      02-18-2007
I present a radio show on a voluntary radio station every Sunday between 3 and 5pm

Is there a script which will change one graphic between those times?

Be nice if my web page could change to "ON AIR", but it's beyond me how to do it.

TIA

Gary Jackson

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      02-18-2007
Gary Jackson said the following on 2/18/2007 9:27 AM:
> I present a radio show on a voluntary radio station every Sunday between 3 and 5pm
>
> Is there a script which will change one graphic between those times?
>
> Be nice if my web page could change to "ON AIR", but it's beyond me how to do it.


Without having some server side support you won't have a reliable
answer. And even with server side support it still won't be fool proof.
The best you could do would be to use a setTimeout call to change the
image every so often (60 seconds) and have the server return the image
that is needed.

function changeImage(){
document.images['theImage'].src="getImage.php?"+(new Date().getTime())
}
var myTimer = window.setInterval(changeImage,60000)

With this HTML:

<image src="off_air.png" name="theImage">

And then have getImage.php return an "ON AIR" or "OFF AIR" image based
on the servers time. If the server and the radio show are in different
time zones then you will have to accommodate for that on the server.

Any solution will be dependent upon the clock being set properly and it
is easier to control the server clock than every users clock. It will
also depend on scripting being enabled.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      02-18-2007
On Feb 18, 5:27 pm, "Gary Jackson" <gary.jackson1NOT
T...@btinternet.com> wrote:
> I present a radio show on a voluntary radio station every Sunday between 3 and 5pm
>
> Is there a script which will change one graphic between those times?
>
> Be nice if my web page could change to "ON AIR", but it's beyond me how to do it.


1) That is for a station located in England (GMT) If it is not then
tell your time zone to adjust.

2) Respectively instead of "<p>ON AIR</p>" you can write your img tag

3) User clocks can be wrong or intentionally set on a wrong time but
as a "hint helper" for average users it is good enough.


<html>
<head>
<title>Gary Jackson's show</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>
<script type="text/javascript">
var now = new Date();
var day = now.getUTCDay();
var hrs = now.getUTCHours();

if ( (day == 0) && (hrs > 2) && (hrs < 5) ) {
document.write('<p>ON AIR</p>');
}
else {
document.write('<p>OFF AIR</p>');
}
</script>
<noscript>
<p>Some nice message for users with script disabilities</p>
<p>It will not be shown to regular users</p>
</noscript>
</body>
</html>

 
Reply With Quote
 
Gary Jackson
Guest
Posts: n/a
 
      02-18-2007
VK wrote:
> <html>
> <head>
> <title>Gary Jackson's show</title>
> <meta http-equiv="Content-Type"
> content="text/html; charset=iso-8859-1">
> </head>
> <body>
> <script type="text/javascript">
> var now = new Date();
> var day = now.getUTCDay();
> var hrs = now.getUTCHours();
>
> if ( (day == 0) && (hrs > 2) && (hrs < 5) ) {
> document.write('<p>ON AIR</p>');
> }
> else {
> document.write('<p>OFF AIR</p>');
> }
> </script>
> <noscript>
> <p>Some nice message for users with script disabilities</p>
> <p>It will not be shown to regular users</p>
> </noscript>
> </body>
> </html>


Thank you so much!

Gary


 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      02-19-2007
In comp.lang.javascript message <>, Sun,
18 Feb 2007 14:27:59, Gary Jackson <gary.jackson1NOT@THIS.?.com.invalid>
posted:
>I present a*radio show on a voluntary radio station every Sunday
>between 3 and 5pm
>*
>Is there a script which will change one graphic between those times?
>*
>Be nice if my web page could change to "ON AIR", but it's beyond me how
>to do it.


Please do not post in HTML/multipart - FAQ 2.3 para 5.

It is presumably 15:00 to 17:00 LCT (local civil time), independently of
whether we are in Summer or Winter time; and your listeners may all be
using UK/IE time. Otherwise, there is code on my site with which
foreigners can determine UK time; you could adapt that.

Since this is a mere convenience to the reader, you can give them the
burden of having a correctly-set clock. Nowadays, most personal
computer clocks are set from a network time server anyway.

The problem is akin to a graphical-digit clock, as in <URL:http://www.me
rlyn.demon.co.uk/js-anclk.htm#Dig>; but at each tick you only have to
decide whether you are ON or OFF.

with (new Date()) { D = getDay() ; H = getHours() }
DH = D*24 + H
ON = DH>=15 && DH<17

will do the choosing; you should be able to adapt it for other times of
the week.


You don't need graphics; you could change text, and put it in a large
coloured font.

It's a good idea to read the newsgroup and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explorer.exe error report every time access every type of video me =?Utf-8?B?SXJ3YW5zeWFo?= ASP .Net 4 10-30-2007 07:49 AM
Cisco Announces Industry's First Network-Based, Standards- Based Rapid Channel-Change..... studyandjobs@yahoo.com Cisco 0 12-26-2006 04:36 PM
Is it possible to mouseover a GRAPHIC . . . that launches another (freestanding) GRAPHIC (ie. when flash is _not_ available)? 50 SOMETHING GAL HTML 3 12-10-2006 01:10 AM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Getting IE windows to open maximised first time every time Quiz Time Computer Support 3 08-25-2004 02:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57