473,805 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scheduled image substitution

Hello...

I have a website that hosts a java chat room nightly. I'd like to have
a graphic on the main page that toggles between 2 images - one
advertising the time of the chat, and another that appears during the
time the chat is actually in session inviting visitors to the web site
to join the chat.

Any idea how I might do this in Javascript to schedule the imgage
substitution using a general meridian time function?
Thanks for your suggestions!

Jul 23 '05 #1
5 1477
go****@ghosthou nds.com wrote:
Hello...

I have a website that hosts a java chat room nightly. I'd like to have
a graphic on the main page that toggles between 2 images - one
advertising the time of the chat, and another that appears during the
time the chat is actually in session inviting visitors to the web site
to join the chat.

Any idea how I might do this in Javascript to schedule the imgage
substitution using a general meridian time function?
Thanks for your suggestions!


Presumably the image changes based on the time at the server's
location? Why not just have a script on your server that at a
specified time replaces one image with the other?

You have two source images: a.gif and b.gif. The image in the page is
c.gif. At the specified time for chat to start, your server script
copies a.gif to c.gif. At the next specified time, when chat ends,
b.gif is copied to c.gif, and so /ad infinitum/.

Maybe you need to "touch" the image to update the file creation time so
cached images will update c.gif if you've changed it (but I don't think
so).

Look ma, no JavaScript!

--
Cheers, Rob.
Jul 23 '05 #2
RobG wrote:
Why not just have a script on your server that at a
specified time replaces one image with the other?
Because I'm even less familiar with server side scripting than I am
with Javascript. ;)
You have two source images: a.gif and b.gif. The image in the page is c.gif. At the specified time for chat to start, your server script
copies a.gif to c.gif. At the next specified time, when chat ends,
b.gif is copied to c.gif, and so /ad infinitum/.

Maybe you need to "touch" the image to update the file creation time so cached images will update c.gif if you've changed it (but I don't think so).


Hmmm... that seems extreme overkill for what I'm wanting to do. Maybe
I wasn't clear in my original description, but all I want is a very
basic javascript that, when the page is loaded, displays A.GIF for 22
out of the 24 hours in a day. Except if the page is loaded, between
say UTC 03 and UTC 05 - then it swaps the image with B.GIF

Is a server side script really the better way to do that? I'm not
really concerned that everyone has to see the "Chat now" image at
exactly the same time - I.E. the time on the users PC is fine for the
javascript to get the time from. Unless it can be called from the
server itself in the javascript easily.

Thanks for your input! :)

Jul 23 '05 #3
JRS: In article <11************ **********@z14g 2000cwz.googleg roups.com>
, dated Mon, 13 Dec 2004 16:06:52, seen in news:comp.lang. javascript,
go****@ghosthou nds.com posted :

I have a website that hosts a java chat room nightly. I'd like to have
a graphic on the main page that toggles between 2 images - one
advertising the time of the chat, and another that appears during the
time the chat is actually in session inviting visitors to the web site
to join the chat.

Any idea how I might do this in Javascript to schedule the imgage
substitution using a general meridian time function?
Thanks for your suggestions!

T = new Date().getUTCHo urs()
src = ['a', 'b'][+(T>=20 && T<22)] + ".gif"

will compute the name of the image to load, changing at 20h & 22h UTC.

new Date()%864e5/36e5|0 // also gets UTC hour-of-day; note |

If you want a Web page to change dynamically when the user's machine
thinks the UTC is right,

new Date()%864e5 // UTC millisecond-of-day

can be used to compute the exact interval to the next status change, for
a setTimeout to load the new image and recompute the interval.

To be more exact, given the potential for user clock adjustment,
calculate the image letter index once a minute and see if it has
changed.

If the times are not whole hours, divide by 6e4 instead to get minute of
UTC day.

BTW, not that it affects you, ISTM that a server cannot initially know
the user's local time, but it may be able to get javascript to send it
the user's offset from GMT.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4
RobG wrote:
Why not just have a script on your server that at a
specified time replaces one image with the other?
Because I'm even less familiar with server side scripting than I am
with Javascript. ;)
You have two source images: a.gif and b.gif. The image in the page is c.gif. At the specified time for chat to start, your server script
copies a.gif to c.gif. At the next specified time, when chat ends,
b.gif is copied to c.gif, and so /ad infinitum/.

Maybe you need to "touch" the image to update the file creation time so cached images will update c.gif if you've changed it (but I don't think so).


Hmmm... that seems extreme overkill for what I'm wanting to do. Maybe
I wasn't clear in my original description, but all I want is a very
basic javascript that, when the page is loaded, displays A.GIF for 22
out of the 24 hours in a day. Except if the page is loaded, between
say UTC 03 and UTC 05 - then it swaps the image with B.GIF

Is a server side script really the better way to do that? I'm not
really concerned that everyone has to see the "Chat now" image at
exactly the same time - I.E. the time on the users PC is fine for the
javascript to get the time from. Unless it can be called from the
server itself in the javascript easily.

Thanks for your input! :)

Jul 23 '05 #5
wrote on 15 dec 2004 in comp.lang.javas cript:
Maybe
I wasn't clear in my original description, but all I want is a very
basic javascript that, when the page is loaded, displays A.GIF for 22
out of the 24 hours in a day. Except if the page is loaded, between
say UTC 03 and UTC 05 - then it swaps the image with B.GIF


<script type='text/javascript'>
function lookfortime(){
t= new Date()
t= t.getUTCHours()
if(t>2&&t<5)
document.getEle mentById('a').s rc='b.gif'
else
document.getEle mentById('a').s rc='a.gif'

setTimeout('loo kfortime()',600 00)
}
</script>

<body onload='lookfor time()'>
<img src='a.gif' id=a>

NOT TESTED

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
435
by: rmk | last post by:
Hi, I have a 404 error handler that can redirect when a url is mistyped or when a page has moved. I would like to have the same control for images. For example: photo/1234-Kitchen.jpg is now located at: photo/1234/Kitchen.jpg If the image is referenced by the wrong url the familar image icon with the 'X' in it appears.
5
4581
by: A. Lovhaug | last post by:
I have a console application built in the .NET Framework. This application basically executes an XCopy based on parameters that I pass to it. I use it for creating scripts for backing up folders, etc. All my command scripts utilizing this console application work fine when they are executed interactively. However, if they are executed via a scheduled task, they do not run. Or more precisely, the script seems to execute at the...
6
8253
by: John Bowman | last post by:
Hi, I have a C# app that needs to launch the "Add Scheduled Tasks" wizard found in the control panel "Scheduled Tasks" applet. I realize that this "applet" really just opens the tasks folder, but I need to launch the add tasks wizard inside the folder. Does anyone have any ideas of how to do this? I can't find anything in the MSDN regarding this. All it mentions is the Task Scheduler API and I can't seem to find it in there either. Did...
1
1015
by: Ching-Lung | last post by:
Hi, How can I manually run a win scheduled task (*.job) from C# or through command prompt? Please advice, thanks! -CL
5
4422
by: Murali | last post by:
In Python, dictionaries can have any hashable value as a string. In particular I can say d = {} d = "Right" d = "Wrong" d = "test" In order to print "test" using % substitution I can say
1
1847
by: satelite | last post by:
Hello, I am writing an exe that is intended to be run via a scheduled task. However, I also need the flexibility to have users run the scheduled task manually (right click task and select run). In the event a user runs the task manually I need to verify their identity for logging purposes. So I have two questions: 1. Is there a way to tell if a scheduled task was run because of its scheduled time or if a user manually initiated it?...
1
7493
by: Myster Edd | last post by:
I have a strange problem that I think deals with security on SQL 2005. I have a scheduled task that runs on a Windows 2000 machine. It calls a vb script which creates a connection to SQL Server. We migrated a database from SQL 2000 to 2005 which is on a different box. I changed the connection in the vb script to use the new sql server. The original connection to SQL 2000 used the 'sa' account coded into the connection string , which...
0
1986
by: Paulson | last post by:
Dear Freinds I want to make a program that acts as a reminder for the users.I need to open up the Scheduled task wizard programmatically.If you type Tasks in the run command the Tasks folder(ie. Scheduled Taks folder) is opened,but what I want is to open the Add Scheduled Task wizard in it.Is there any run command to do that? Also if I am able to open the Scheduled Task wizard like this is there any way by which I can...
9
3783
by: jdaelhousen | last post by:
I have a bit of a problem I'm hoping someone can shed some light on... I have a VB.Net console application written in VS 2003 that produces a .exe file that now sits on a Windows 2000 server directory. This exe does the following 3 things: 1.) Using the VB Interaction SaveSetting() method, it programmatically updates the system registry under the HKEY_CURRENT_USER\SOFTWARE key and saves a directory location used by a PDF driver (so that...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7645
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.