Welcome to the Cumulus Support forum.

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

Cumulus MX V4 beta test release 4.0.0 (build 4021) - 04 May 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

online / offline webtag for htm

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

Moderator: daj

User avatar
Darknstormy
Posts: 168
Joined: Wed 28 Apr 2010 1:01 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Windows 11
Location: Australia

online / offline webtag for htm

Post by Darknstormy »

Hey,

ok so let me explain... can you have a menu option in the program that's "Shutdown & offline" So it Uploads to your webpage before it shuts the program down setting the webtag to offline.

and when you open the program, the first upload will change the Offline webtag to online...

understand? lol


Cheers
ImageImage
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: online / offline webtag for htm

Post by steve »

Yes, I understand. It's a bit tricky, though, as the web update code runs asynchronously in the background, so I would have to try to co-ordinate that final web update with the close down. And what if it was already in the middle of a web update when it closed down?

This is really what the <#update> web tag is for, to tell the viewer when the last update occurred and hence whether the data is currently valid. To make it more obvious, a bit of javascript could compare the <#update> time with the current time and display a message based on how long ago the last update was - perhaps also using the <#interval> tag.
Steve
User avatar
Darknstormy
Posts: 168
Joined: Wed 28 Apr 2010 1:01 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Windows 11
Location: Australia

Re: online / offline webtag for htm

Post by Darknstormy »

Arrrr yeah I knew it prob wouldn't be the easiest thing.. Well since I know nothing about web page coding apart from the basics.. Ill put out there to everyone, how can I make a flashing light or online offline picture on my webpage so people know if its online or offline with out studying the last update time.. via javascript as Steve Suggested.
ImageImage
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: online / offline webtag for htm

Post by beteljuice »

This is very awkward to do with JavaScript because Cumulus does not provide an UTC time code.
JS can look at the UTC time difference of a visitors browser, but you would have to enter your local GMT difference, and remember to change it when / if Daylight Savings are applied.

This is one of those things that PHP (serverside code) would be much better at, not least of which it can simply 'inspect' when the file was last modified and compare it eg. interval x 2 using the same (server) clock.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: online / offline webtag for htm

Post by steve »

beteljuice wrote:This is very awkward to do with JavaScript because Cumulus does not provide an UTC time code.
I've added <#timeUTC> to the next build. Formatting can be applied.
Steve
User avatar
Darknstormy
Posts: 168
Joined: Wed 28 Apr 2010 1:01 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Windows 11
Location: Australia

Re: online / offline webtag for htm

Post by Darknstormy »

Awesome, Thanks Steve... now we just need a clever little cat to write a script up for it :D
ImageImage
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: online / offline webtag for htm

Post by beteljuice »

EDIT: Doesn't work ! - For Information ONLY
See: https://cumulus.hosiene.co.uk/viewtopic.p ... 963#p46963


Unproven, untested, and unlikely to work first time :)
Don't forget you can't try it until Steve introduces the <#timeUTC> webtag !!!

Edit #1: missing hh (hours formating) added.
Edit #2: then - getTime corrected
Edit #3: now_utc - getUTCDate added
Edit #4: output code rewritten

In the <head> section of your xxxxT.htm

Code: Select all

<script type="text/javascript">
<!--
// Javascript Cumulus update checker - betejuice v1.4 (open) July 2011
// set these variables to suit
var missed = 2; // Number of updates to miss before deciding "offline"
var online_pic = "myimages/online.gif"; // location of ONline image
var online_txt = "Station ON-line"; // your ONline text
var offline_pic = "myimages/offline.gif"; // location of OFFline image
var offline_txt = "Station OFF-line"; // your OFFline text
// END user vars

var now = new Date();
var now_utc = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());

var then_month = <#timeUTC format=mm> -1;
var then = new Date(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd', 'hh', 'mm', 'ss">);
then = then.getTime();
var timetodie = <#interval> * missed * 60000; // milliseconds per minute

if(now_utc - then < timetodie){
	status_pic = online_pic;
	status_txt = online_txt;
} else {
	status_pic = offline_pic;
	status_txt = offline_txt;
}
-->
</script>
Then in the <body> section where / when required

Code: Select all

<script type="text/javascript">
<!--
// for the image (when / where required)
document.write("<img src=\"" + status_pic + "\" alt=\"test\" title=\"" + status_txt + "\" />");
// for the text (when / where required)
document.write(status_txt);
-->
</script>
Last edited by beteljuice on Tue 05 Jul 2011 1:35 pm, edited 6 times in total.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
Darknstormy
Posts: 168
Joined: Wed 28 Apr 2010 1:01 pm
Weather Station: Davis Vantage Pro 2 Plus
Operating System: Windows 11
Location: Australia

Re: online / offline webtag for htm

Post by Darknstormy »

You're a machine... thanks heaps... I shall give it a shot once the next release comes out :D
ImageImage
User avatar
mcrossley
Posts: 12816
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: online / offline webtag for htm

Post by mcrossley »

I think there is a slight error in beteljuice's code.

Code: Select all

var then = getTime( new Date(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd', 'mm', 'ss">));
should be:

Code: Select all

var then = getTime( new Date(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd, hh, mm, ss">));
How about some alternative code (again untested):

Code: Select all

var now  = new Date();
var then = new Date();

then.setUTCFullYear(<#timeUTC format=yyyy>, (<#timeUTC format=mm> -1), <#timeUTC format=dd>);
then.setUTCHours(<#timeUTC format="hh, mm, ss">));

var timetodie = <#interval> * missed * 60000; // milliseconds per minute

if(now - then < timetodie){
   status_pic = online_pic;
   status_txt = online_txt;
} else {
   status_pic = offline_pic;
   status_txt = offline_txt;
}
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: online / offline webtag for htm

Post by beteljuice »

I haven't done any formating, but I believe I read somewhere:
" " if o/p contains spaces, and ' ' for anything you don't want parsed - so I think it might be right :?

In the alternative code nothing has been done to convert 'browser' now time to UTC ?
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
mcrossley
Posts: 12816
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: online / offline webtag for htm

Post by mcrossley »

Ah, OK, so the ', ' is still needed - I wondered why they were there! But the Hours are still missing?

Code: Select all

var then = getTime( new Date(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd', 'mm', 'ss">));
should be (EDIT: It was still wrong, minutes are nn!)

Code: Select all

var then = getTime( new Date(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd', 'hh', 'nn', 'ss">));
My version does not explicity set the now UTC, I don't believe you need to. The Date object contains the local time and the UTC offset. So..

Code: Select all

now = new Date();
yer = now.getUTCFullYear();
mon = now.getUTCMonth();
etc...
Will have the correct UTC values for 'yer', 'mon' etc.

I've had to use the Date() object far too much in the past for all my Moon position calculations which heavily rely on converting the users local time to UTC. :cry:
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: online / offline webtag for htm

Post by steve »

beteljuice wrote:" " if o/p contains spaces, and ' ' for anything you don't want parsed - so I think it might be right :?
The single quotes are optional in this case as the strings they are enclosing aren't formatting characters (the documentation doesn't state this explicitly, I simply copied it from the Delphi documentation). I think Mark's point is that you have missed out the hour specifier.
Steve
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: online / offline webtag for htm

Post by steve »

mcrossley wrote:It was still wrong, minutes are nn!
mm is minutes, after hh. Kind of stupid but clever at the same time.
Steve
User avatar
mcrossley
Posts: 12816
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: online / offline webtag for htm

Post by mcrossley »

Doh! This formatting is all too complicated :bash: I'll try and update the Wiki to reflect some of this - if I can find the right words :lol:

Edit: I'll try reading the Wiki first - its already in there :oops:
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: online / offline webtag for htm

Post by beteljuice »

Doh likewise missing the hh (hours) - code to be proven yet anyways :lol:
I can't check it because I'm not running my station, so not running Cumulus, so can't see if the processed formating / parsing is doing what I thought :?

The original code has been edited to include hh parsing - Thanks for the heads up.
Image
......................Imagine, what you will KNOW tomorrow !
Post Reply