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

online / offline indicator

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

Moderator: daj

Post Reply
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

online / offline indicator

Post by Alan »

Hello there,
Could somebody please guide in what I am trying to achieve with the following code.
I would like the alternate output of (var online_txt2 = "0";) or (var offline_txt2 = "2";) that is in the head section of the page to be added to and operable in the line (var x=<#ErrorLight>....) that is in the body section of the page.
To be honest I don't have enough knowledge to know if this type of thing is even possible.
Any assistance would be truly appreciated.
Many thanks,
Alan


<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 = "images/pictures/greenbrightled21px.gif"; // location of ONline image
var online_txt = "on line"; // your ONline text
var online_txt2 = "0";
var offline_pic = "images/pictures/redgreenled21px.gif"; // location of OFFline image
var offline_txt = "off line"; // your OFFline text
var offline_txt2 = "2";
// 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;
status_txt2 = online_txt2;
} else {
status_pic = offline_pic;
status_txt = offline_txt;
status_txt2 = offline_txt2;
}
-->
</script>


<td width="33.3%" align="center"><script type="text/javascript">
var x=<#ErrorLight> would like the result to be here
if (x == "0")
document.write('<img src="images/pictures/monitorsystem.gif"/>');
if (x == "1")
document.write('<img src="images/pictures/redgreenled21px.gif"/>');
if (x == "2"||x == "3")
document.write('<img src="images/pictures/greenled21px.gif"/>'); </script>
<br>system</td>
Last edited by Alan on Mon 04 Jun 2012 1:04 pm, edited 2 times in total.
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 indicator

Post by beteljuice »

The closing > is missing from the top chunk of code, and the bottom code has no <script> tags at all !

I'll assume that's cut 'n' paste error .... but then the bottom line shouldn't be there !
and there is something strange about setting for "0", then later doing an 'else' on "1" - does that work as intended ?????????

If you want your extra status text to appear immediately in front of the stuff in the second block of code (where you have shown in red:

Code: Select all

<td>// NOTE: this is an EXTRA <TD>, other html may have to be modified
<script type="text/javascript">
document.write(status_txt2);
</script>
</td>

<td>
<script type="text/javascript">
var x=<#ErrorLight>;
.....
</script>
<br>system</td>
Image
......................Imagine, what you will KNOW tomorrow !
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: online / offline indicator

Post by Alan »

Hello beteljuice,
I have edited the original post and you should be now able to see the the two separate blocks of javascript (sorry, but a bit of sloppy cutting and pasting on my part).

If I manually insert a '0' or a '2' after the (var x=<#ErrorLight>+0) or (var x=<#ErrorLight>+2) then the 'else' works beautifully. So really, all I am trying to achieve is for the system to insert the appropriate '0' or '2' into place for me.
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 indicator

Post by beteljuice »

Code: Select all

<td width="33.3%" align="center">
<script type="text/javascript">
document.write(status_txt2);
var x=<#ErrorLight>;
if (x == "0")
document.write('<img src="images/pictures/monitorsystem.gif"/>');
if (x == "1")
document.write('<img src="images/pictures/redgreenled21px.gif"/>');
else
document.write('<img src="images/pictures/greenled21px.gif"/>'); </script>
<br>system</td>
Image
......................Imagine, what you will KNOW tomorrow !
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: online / offline indicator

Post by Alan »

Firstly, I apologise for a mistake I made earlier.I have corrected it and replaced the 'else' with another 'if' and works well when manually inserting '0' or '2' as previously mentioned.
I tried the inclusion of your suggested code but it adds a '0' or '1' next to my existing GIF instead of replacing it with another type or colour. I would suspect that the code needs to be part of the logical sequencing within the 'var'
The link here might help.

http://home.exetel.com.au/retnuh/weather/lite.htm
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 indicator

Post by beteljuice »

... instead of replacing it with another type or colour.
That was not your original remit !

You lied ! - are you saying you want to modify a url (img call) or change a textural content, or a 'new' structure.

If so, which one do you want to modify ?
Image
......................Imagine, what you will KNOW tomorrow !
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: online / offline indicator

Post by Alan »

I think it might be wise here to try and give you an overall view of just what it is that I am trying to achieve. If you look at my web page you will see that I have 4 led lights (one online offline status and 3 monitoring). Currently I am only trying to modify the code for one monitoring led (system) and then if this problem can be solved it will be incorporated into the other two. Now, as can be seen the 3 monitoring leds operate on and off at set intervals indicating that the 3 conditions are being monitored. However, if cumulus goes off line (indicated by the on line off line led flashing red) the 3 monitoring leds continue to act as per the last upload prior to going off line. This of course is not too smart for it should not be able to display station monitoring status whilst it is off line. The obvious thing to do is to extinguish the three monitoring leds whilst ever cumulus is off line. To achieve this I am attempting to include the output of your 'on line off line code' ('0' or '2') into my var so as to invoke the third 'if' of my 'var' (an off condition of the led). If you go back to my original post I think you will find that that was all I was seeking to do.
I don't know a lot about javascript but I do know that a string in a variable will return a string and not the result of the string. Hence the question of how to get the output ('0' or '2') of your code into my 'var'. I have a suspicion that that it is going to involve some creative coding (which, by the way completely illudes me and of course brought me to the forum in the first place).
I hope this helps.
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 indicator

Post by beteljuice »

There is no real need to append to the image name or var.

Code: Select all

<td width="33.3%" align="center">
<script type="text/javascript">
If(status_txt2 == "0"){ // online
   var x=<#ErrorLight>;
if (x == "0")
document.write('<img src="images/pictures/monitorsystem.gif"/>');
if (x == "1")
document.write('<img src="images/pictures/redgreenled21px.gif"/>');
if (x == "2"||x == "3")
document.write('<img src="images/pictures/greenled21px.gif"/>');
}else{ // offline 
    document.write('<img src="images/pictures/OFF21px.gif" />'); // extinguished graphic
}
</script>
<br>system</td>
If we wanted to see your page .... a link would be useful ;)
Image
......................Imagine, what you will KNOW tomorrow !
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: online / offline indicator

Post by Alan »

brilliant!! I have given it a full road test and now all led lights are operating exactly as I wished.
Thank you very much for your efforts and patience.
Enjoy your celebrations over there.
Cheers!
Alan
User avatar
vaggos
Posts: 160
Joined: Sat 06 Feb 2010 7:00 pm
Weather Station: PROWEATHER STATION 1080
Operating System: XP SP3, win7, Win10
Location: Acharnes Athens Greece
Contact:

Re: online / offline indicator

Post by vaggos »

Hello
I like the above script and i add it in one page just for test (http://axarnes.meteoclub.gr/led.htm). But i see always the greed led (on line) ON. I close cumulus and still remain on. What i am doing wrong?
Thanks in advance
Vaggelis
Image
Acharnes Athens Greece Meteo station
http://www.meteoacharnes.gr
https://weather.meteoacharnes.gr/
Thanks Sandaysoft
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 indicator

Post by beteljuice »

Where do I begin :?

You have a lot of problems with that page, and added together makes it a bit sick :shock:

First of all, this thread is a modified version of this: https://cumulus.hosiene.co.uk/viewtopic.p ... 7&start=25

This code utilises <#webtags> which means Cumulus has to process it and upload it.
Your page is a mixture of Ajax (reading realtime.txt) and <#webtags> .... but ...

The page has NEVER been processed by Cumulus and so NONE of the <#webtag> data has been populated !

OK ... using <#webtags> means that information in the page is a 'one-shot', If Cumulus was closed down for a week the page in browser if left up whould still show on-line, the page would need to be refreshed to display the change of status.

However: you are missing this from the <head> section of your page:

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 = "images/pictures/greenbrightled21px.gif"; // location of ONline image
var online_txt = "on line"; // your ONline text
var online_txt2 = "0";
var offline_pic = "images/pictures/redgreenled21px.gif"; // location of OFFline image
var offline_txt = "off line"; // your OFFline text
var offline_txt2 = "2";
// 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;
status_txt2 = online_txt2;
} else {
status_pic = offline_pic;
status_txt = offline_txt;
status_txt2 = offline_txt2;
}
-->
</script>
That and processing / uploading the file will NOT fix things,
.... because ....
You have hardcoded your on / offline graphic - it is impossible to change it !

Code: Select all

<p align="center"><font color="dimgray" size="4" face="times new roman">
<img title="on line" alt="test" src="images/pictures/greenbrightled25px.gif" width="25" height="25"></font></p>
This needs to be replaced by something like:

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>
You have also duplicated AND hardcoded the output for the combined row of sensor advisories, AND there are chunks of 'bad' html.
This lot is NOT required !

Code: Select all

 
<table class="reading" border="0" width="250" align="center" height="50" valign="top">
  <tr>
    <td width="33.3%" align="center">
    <p align="center"><b><font color="#0000FF">
    <img src="images/pictures/monitorsystem.gif" width="21" height="21"><br>
    <span style="background-color: #FFFF00">system</span></font></b></td>
 
<font color="dimgray" size="4" face="times new roman" td <>
    <td width="33.3%" align="center">
   
</font>
    <p align="center"><b><font color="#0000FF">
    <img src="images/pictures/monitorsensor.gif" width="21" height="21"><br>
    <span style="background-color: #FFFF00">sensor</span></font></b></td>
 
<font color="dimgray" size="4" face="times new roman" td <>
    <td width="33.3%" align="center">
    <script type="text/javascript">
                  if(status_txt2 == "0"){ // online
                  var x=0;
                  if (x == "0")
                  document.write('<img src="images/pictures/monitorrecord.gif"/>');
                  if (x == "1")
                  document.write('<img src="images/pictures/redgreenled21px.gif"/>');
                  }else{ // offline
                  document.write('<img src="images/pictures/greenled21px.gif" />'); // extinguished graphic
                  }
									</script>
</font>
    <p align="center"><b><font color="#0000FF">
    <img src="images/pictures/monitorrecord.gif" width="21" height="21"><br>
    <span style="background-color: #FFFF00">record</span></font></b></td>
  </tr>
</table>
There also seems to be problems (probably with Ajax looking for things it can't find) because holding onto your page whilst I typed was grinding my browser / PC to a halt :shock:

Try building your page one step at a time and make sure everything works as expected.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
vaggos
Posts: 160
Joined: Sat 06 Feb 2010 7:00 pm
Weather Station: PROWEATHER STATION 1080
Operating System: XP SP3, win7, Win10
Location: Acharnes Athens Greece
Contact:

Re: online / offline indicator

Post by vaggos »

beteljuice, thanks for your quick reply
My original index page is http://axarnes.meteoclub.gr. And i thing its "working" well. May be the problem for the delay is that looking for the three cams in de test page. But in the original page everything , works ok.

I try to make the test page again with your correction and i'll be back.
Thanks again
Image
Acharnes Athens Greece Meteo station
http://www.meteoacharnes.gr
https://weather.meteoacharnes.gr/
Thanks Sandaysoft
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: online / offline indicator

Post by dazza1223 »

hey can any one help me to set this up plz
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
Post Reply