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 4019) - 03 April 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
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 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
Moderator: daj
- 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
Ok... since I'm completely dumb at code and its a little confusing.... have we got a final code that can be added once the new build comes out...
sorry
is there anything I need to change apart from online offline gif?
because its not working
Lyle
EDIT : sorry I see Steve has already done an update :D
sorry
is there anything I need to change apart from online offline gif?
because its not working
Lyle
EDIT : sorry I see Steve has already done an update :D
- 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
Oops - the beteljuice always has headaches with coding time functions no matter what the language is !
Try the edited code now (V1.2)
PS. your output is in a <table> but NOT within <TR><TD>
B*gger! - forgot UTCdate
now (V1.3)
Try the edited code now (V1.2)
PS. your output is in a <table> but NOT within <TR><TD>
B*gger! - forgot UTCdate
now (V1.3)
......................Imagine, what you will KNOW tomorrow !
- 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
awww... i dont know what ive done wrong... mines just saying station offline and the image isnt coming up:(
- 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
You have still 'broken' the table, if you want it below your other sensors
then:
Note the o/p code has been rewritten, your image is rather large, so either resize it or 'force' a different size by adding at least a width attribute along the lines of:
then:
Code: Select all
<tr>
<td colspan="4" class="tableseparator_pressure"><div align="center">
<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>
</div></td>
</tr>
Code: Select all
document.write("<img src=\"" + status_pic + "\" alt=\"test\" title=\"" + status_txt + "\" width=\"40\" />");
......................Imagine, what you will KNOW tomorrow !
- 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
Sorry It's prob frustrating.. ok so Ive re-sized the pictures and they are working now...
but when you say I have 'broken' the table... what part of the code have I got in the wrong spot for that to happen.. Cheers sorry again
but when you say I have 'broken' the table... what part of the code have I got in the wrong spot for that to happen.. Cheers sorry again
- mcrossley
- Posts: 12766
- 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
beteljuice, I still think this is wrong or over complicated.
The problem is the browser is using 'local' time somewhere in the world, we don't know where.
Cumulus is providing UTC time to get around this.
So we want to compare 'now':
with the time Cumulus provides in UTC:
so:
Or am I off track here?
The problem is the browser is using 'local' time somewhere in the world, we don't know where.
Cumulus is providing UTC time to get around this.
So we want to compare 'now':
Code: Select all
var now = new Date();
Code: Select all
var then = Date.UTC(<#timeUTC format=yyyy>, <#timeUTC format=mm>-1, <#timeUTC format="dd', 'hh', 'mm', 'ss">);
Code: Select all
if (now - then < timetodie) //simplified, could strictly use now.getTime()
//we're online
else
//we're offline
- 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
I might well be overdoing things, or even got my logic backward - as I said before I've always had problems with what is UTC and what doesn't need to be (for comparative purposes).
I certainly seem to have got something wrong as Darknstormys page is always showing off-line to me, but if I test the code locally it seems to work
As I see your code suggestion, 'now' is a browser local time object which you have left alone, but then you have converted 'then' which is already a UTC time to UTC (again) milliseconds.
Does it work ?
I certainly seem to have got something wrong as Darknstormys page is always showing off-line to me, but if I test the code locally it seems to work
As I see your code suggestion, 'now' is a browser local time object which you have left alone, but then you have converted 'then' which is already a UTC time to UTC (again) milliseconds.
Does it work ?
......................Imagine, what you will KNOW tomorrow !
- mcrossley
- Posts: 12766
- 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
My previous code is largely untested, but I think the Date object always stores the raw millisecond value in 'UTC'.
I did play around in the debugger and...
if you set...
var now = new Date();
var utc = Date.UTC(now.getUTCFullYear, now.getUTCMonth, [...etc including ms])
then...
now == utc --> true
I did play around in the debugger and...
if you set...
var now = new Date();
var utc = Date.UTC(now.getUTCFullYear, now.getUTCMonth, [...etc including ms])
then...
now == utc --> true
- 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
Glad you guys know what your doing, can u guys post the new code complete, and ill test it tonight when I get home.
Cheers guys
Cheers guys
- mcrossley
- Posts: 12766
- 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
If I get a chance I'll have a play around sometime today - I'd like to implement this myself
- 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
It would seem Mark had it right and the beteljuice both applied the UTC to the wrong variable and effectively did it twice ! (I think)
So here is the revised code that seems to work (Unless someone proves different )
In the <head> section of your xxxxT.htm
Then somewhere to suit in the <body> section:
You may wish to put the output script(s) in between <span> .. </span> to enable 'formatting' via CSS.
If it works Kudos to Mark for proving that the beteljuice still has a long misunderstanding of comparative time conversions
So here is the revised code that seems to work (Unless someone proves different )
In the <head> section of your xxxxT.htm
Code: Select all
<script type="text/javascript">
<!--
// Javascript Cumulus update checker - betejuice v2.0 July 2011
// set these variables to suit
var missed = 2; // Number of updates to miss before deciding "offline", MUST be > 1, fractions allowed (eg. 1.5)
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 then_month = <#timeUTC format=mm> -1;
var then = Date.UTC(<#timeUTC format=yyyy>, then_month, <#timeUTC format="dd', '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;
}
-->
</script>
Code: Select all
<script type="text/javascript">
<!--
// for the image (when / where required)
document.write("<img src=\"" + status_pic + "\" alt=\"" + status_txt + "\" title=\"" + status_txt + "\" />");
//for the text (when / where required)
document.write(status_txt);
-->
</script>
If it works Kudos to Mark for proving that the beteljuice still has a long misunderstanding of comparative time conversions
Last edited by beteljuice on Thu 07 Jul 2011 12:02 pm, edited 3 times in total.
......................Imagine, what you will KNOW tomorrow !
- 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
Cheers guys, I tried mcrossley last night that he sent me and it worked but ive stuffed up my style so ill need to edit it tonight and put it where u said. Oops thanks again.
- 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
Thanks heaps guys, I have it all up and running now, not once has it failed
Cheers
Cheers
- Ned
- Posts: 258
- Joined: Mon 19 Jul 2010 11:15 am
- Weather Station: WS2083 (aspirated)
- Operating System: Win 10
- Location: Auckland NZ
Re: online / offline webtag for htm
And another vote of thanks from me
Very nice and just what my site needed when it nods off every night....
Very nice and just what my site needed when it nods off every night....