Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

help.. I need a image loader that only loads image X times

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

help.. I need a image loader that only loads image X times

Post by ace2 »

I have 3 pages that currently have a image refresher every X seconds.
I need to be able to restrict how many times they load, say load every 20 seconds for a total of 10 minutes.
My 3 pages are :
http://ace2weather.com/index.htm
http://ace2weather.com/highlights.htm
http://ace2weather.com/cam.htm
Wondering if the GODS of code can help.....please....
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: help.. I need a image loader that only loads image X tim

Post by beteljuice »

Modifying your code try something like:

Code: Select all

<script type="text/javascript">
picCount = 0;
picCountMax = ????; // Number of time to refresh
 
refreshInit = function()
{
picTimer = setInterval(refreshImage, 1*3000);
}

refreshImage function()
{
picCount++;
if(picCount <= picCountMax){
img = document.getElementById("icam");
img.src="http://ace2weather.com/snapshot.jpg?rand=" + Math.random();
} else {
clearInterval(picTimer);
}
}
</script>
</head>
<body onload="window.setInterval(refreshImage, 1*3000);">
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by ace2 »

beteljuice wrote:Modifying your code try something like:

Code: Select all

<script type="text/javascript">
picCount = 0;
picCountMax = ????; // Number of time to refresh
 
refreshInit = function()
{
picTimer = setInterval(refreshImage, 1*3000);
}

refreshImage function()
{
picCount++;
if(picCount <= picCountMax){
img = document.getElementById("icam");
img.src="http://ace2weather.com/snapshot.jpg?rand=" + Math.random();
} else {
clearInterval(picTimer);
}
}
</script>
</head>
<body onload="window.setInterval(refreshImage, 1*3000);">
That looks great, how would I use this with multiple images on one page like my highlights page, which you helped me with last time(you're a star)

I would even be happy with a load images on open only!!!
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by ace2 »

I choose a slightly different method for my index and cam page, I just added a

Code: Select all

onload="loadImage()"
on the tail of the image source which seems to work, but i can't work out my highlight one as i have 6 images with 6 link that require random style reload
which uses

Code: Select all

<script type="text/javascript">
refreshImage = function()
{
img = document.getElementById("im1");
img.src="7am.jpg?rand=" + Math.random();
link = document.getElementById("lnk1");
link.href = "7am.jpg?rand=" + Math.random();
img = document.getElementById("im2");
img.src="9am.jpg?rand=" + Math.random();
link = document.getElementById("lnk2");
link.href = "9am.jpg?rand=" + Math.random();
img = document.getElementById("im3");
img.src="11am.jpg?rand=" + Math.random();
link = document.getElementById("lnk3");
link.href = "11am.jpg?rand=" + Math.random();
img = document.getElementById("im4");
img.src="2pm.jpg?rand=" + Math.random();
link = document.getElementById("lnk4");
link.href = "2pm.jpg?rand=" + Math.random();
img = document.getElementById("im5");
img.src="4pm.jpg?rand=" + Math.random();
link = document.getElementById("lnk5");
link.href = "4pm.jpg?rand=" + Math.random();
img = document.getElementById("im6");
img.src="6pm.jpg?rand=" + Math.random();
link = document.getElementById("lnk6");
link.href = "6pm.jpg?rand=" + Math.random();

}
</script>
</head>
<body onload="window.setInterval(refreshImage, 1*3000);">
But I can't figure out how to get it working with your script or even a the onload="loadImage()"
I would be happy to have it load on reload and have a refresh button.......
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by steve »

Just put:

<body onload="refreshImage()">

Create a button to call the same function:

<button onclick="refreshImage()">Refresh images</button>
Steve
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by ace2 »

Probably best to keep it simple and that seems to work fine....
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by steve »

...and your http bandwidth usage is now down to more reasonable levels :)
Steve
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: help.. I need a image loader that only loads image X tim

Post by ace2 »

steve wrote:...and your http bandwidth usage is now down to more reasonable levels :)
I kind of went into panic mode once informed. :o
Was editing/removing the rogue usage elements within the htm while at work using only a mobile phone. :groan:
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
Post Reply