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

Using conditionals in the interface to switch between wind chill and heat index

Topics about the Beta trials up to Build 3043, the last build by Cumulus's founder Steve Loft. It was by this time way out of Beta but Steve wanted to keep it that way until he made a decision on his and Cumulus's future.

Moderator: mcrossley

Locked
BigOkie
Posts: 283
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Bookworm (RPi 3b)
Location: Tulsa, OK

Using conditionals in the interface to switch between wind chill and heat index

Post by BigOkie »

I'm not as versed in what is being used for the MX interface, so I thought I'd ask for assistance here.

The stock interface in CMX comes with just Wind Chill on the index page. I'd like to try and figure out how to modify it so that the Wind Chill block will display when it's less than 80 degrees outside, and when it's more than 80 degrees, I'd like for it to switch to heat index.

I modified the index.html page already to display the heat index as this:

Code: Select all

                <!-- Heat Index Block -->
                <div class="col-sm-6 col-lg-3">
                    <div class="dash-unit">
                        <span class="dtitle">Heat Index</span>
                        <hr>
                        <div class="cont">
                            <div class="cont" >
                                <span id="HeatIndex" style="font-size:400%">--.-</span>&nbsp;<span class="TempUnit" style="vertical-align:150%">&deg;C</span>
                            </div>
                            <div class="cont" >

                                <p><span>High&nbsp;&nbsp;</span><span id="HighHeatIndexToday" class="high">--.-</span><br><span id="HighHeatIndexTodayTime">--:--</span></p></div>
                        </div>
                    </div>
                </div>
..but I'd like to be able to write it with an if/else statement to show one block if the condition is met, else show the other block.

Has anyone tried this yet?

Thanks.
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: Using conditionals in the interface to switch between wind chill and heat index

Post by steve »

This might be one way of doing it (untested):

Give the Wind Chill and Heat Index blocks names, thus:

<div id="WindChillBlock" class="col-sm-6 col-lg-3">

[...]

<div id="HeatIndexBlock" class="col-sm-6 col-lg-3">

Then, in interface/js/dashboard.js, towards the end of function updateDisplay(), add

Code: Select all

if (data.OutdoorTemp < 80) {
    $('#WindChillBlock').show();
    $('#HeatIndexBlock').hide();
} else {
    $('#WindChillBlock').hide();
    $('#HeatIndexBlock').show();
}
if the display looks a bit odd initially with both blocks shown briefly until the first update, you could make one of the blocks hidden by default, e.g.

<div hidden id="WindChillBlock" class="col-sm-6 col-lg-3">
Steve
BigOkie
Posts: 283
Joined: Tue 28 May 2013 1:06 am
Weather Station: Davis VP2 Plus
Operating System: Raspian Bookworm (RPi 3b)
Location: Tulsa, OK

Re: Using conditionals in the interface to switch between wind chill and heat index

Post by BigOkie »

steve wrote:This might be one way of doing it (untested):

Give the Wind Chill and Heat Index blocks names, thus:

<div id="WindChillBlock" class="col-sm-6 col-lg-3">

[...]

<div id="HeatIndexBlock" class="col-sm-6 col-lg-3">

Then, in interface/js/dashboard.js, towards the end of function updateDisplay(), add

Code: Select all

if (data.OutdoorTemp < 80) {
    $('#WindChillBlock').show();
    $('#HeatIndexBlock').hide();
} else {
    $('#WindChillBlock').hide();
    $('#HeatIndexBlock').show();
}
if the display looks a bit odd initially with both blocks shown briefly until the first update, you could make one of the blocks hidden by default, e.g.

<div hidden id="WindChillBlock" class="col-sm-6 col-lg-3">
I gave this a try (thanks) and got no errors. However, both blocks still show up on the page, even after the first update. I'll see if I can figure this out. Thanks for pointing me.

EDIT: NM...it actually DID work! I forgot to clear the browser cache however. Once I did that it appeared to function. I need to change some of the values in the JS file to test it the other way however. Thank you so much.

EDIT 2: Changing the value in dashboard.js to test if Wind Chill switches properly and it does. Guess I need to learn java and Jquery. We actually use it at work but since I'm a Software QA guy I don't do a lot of coding. Thanks again.
Locked