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

webtags and javascript

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
Post Reply
upnaway
Posts: 4
Joined: Wed 12 Mar 2014 4:41 am
Weather Station: Davis Vantage Vue
Operating System: Windows 7
Location: Perth, Australia
Contact:

webtags and javascript

Post by upnaway »

Hi, I have been modifying the stock HTML pages for sometime, but I am looking to expand my knowledge and functionality with some basic javascript. As javascipt in HTML is completely foreign to me, I am hoping someone can point me in the right direction of how some basic mods that use the Cumulus webtags in javascript.

What I am trying to achieve is a basic update to my Today page, where rather than display both Consecutive Rain Days and Consecutive Dry Days, it just displays one tag or the other depending on which tag is active and some corresponding descriptive text

What my table presently has is:
<tr class="td_rainfall_data">
<td>Consecutive&nbsp;Days&nbsp;of&nbsp;Rain</td>
<td><#ConsecutiveRainDays></td>
<td>&nbsp;</td>
</tr>
<tr class="td_rainfall_data">
<td>Days&nbsp;Since&nbsp;It&nbsp;Last&nbsp;Rained</td>
<td><#ConsecutiveDryDays></td>
<td>&nbsp;</td>
</tr>

Depending on which tag is greater than 0 I want it to display that particular table row.

Further down the track, I would start to like utilising some of the Boolean webtags. Hopefully I can work that out for myself once I can understand some of the basics how the webtags interact in javascript
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: webtags and javascript

Post by steve »

Webtags just get replaced with values, so they don't really interact with javascript at all. So where you might put

Code: Select all

<script>
if (x > 0) {
  document.write("Value is greater than zero");
}
</script>
with a web tag you do the same

Code: Select all

<script>
if (<#ConsecutiveRainDays> > 0) {
  document.write("Value is greater than zero");
}
</script>
So for what you want to do, you might use, for example:

Code: Select all

<script>
if (<#ConsecutiveRainDays> > 0) {
  document.write("Consecutive rain days: <#ConsecutiveRainDays>");
} else {
  document.write("Consecutive dry days: <#ConsecutiveDryDays>");
}
</script>
Steve
upnaway
Posts: 4
Joined: Wed 12 Mar 2014 4:41 am
Weather Station: Davis Vantage Vue
Operating System: Windows 7
Location: Perth, Australia
Contact:

Re: webtags and javascript

Post by upnaway »

wow, so simple once it is explained. I've tried learning Java before, but I get so confused with all the other languages I have learnt in the past. Maybe I need to get with the times :)
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: webtags and javascript

Post by steve »

To avoid any future confusion you should get used to always calling this stuff "JavaScript" and never "Java", as the two are completely different animals used for different purposes. JavaScript is a very useful skill to learn, it's even used a lot outside web browsers these days. I know just enough now to be dangerous!
Steve
upnaway
Posts: 4
Joined: Wed 12 Mar 2014 4:41 am
Weather Station: Davis Vantage Vue
Operating System: Windows 7
Location: Perth, Australia
Contact:

Re: webtags and javascript

Post by upnaway »

Shows how foreign I am, I didn't even realise there was a difference.

Thanks for your help, I threw the code in and it worked a treat. Hopefully the 95 day dry spell in Perth will be broken sometime soon to put the code to good use.
Post Reply