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

Testing Code!

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Testing Code!

Post by William Grimsley »

Hi there,

I've been putting in some new code into my ajax-dashboard.php file and wondered if it would work?

What I'm trying to do is not display the wind direction in both Javascript and AJAX when the wind speed is less than 0.0 mph.

Please can someone tell me if this code will work?

Code: Select all

<?php if (strip_units($avgspd) + strip_units($gstspd) > "0.0") echo "$dirlabel"; ?>
Thanks,

William
User avatar
mcrossley
Posts: 14384
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Testing Code!

Post by mcrossley »

In what circumstances would you have a negative wind speed?

Edit: OK, looks like I misread the code. It looks OK.
Last edited by mcrossley on Tue 19 Mar 2013 9:11 pm, edited 1 time in total.
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Testing Code!

Post by William Grimsley »

mcrossley wrote:In what circumstances would you have a negative wind speed?
Oh, yes! I never thought of that! :lol:

The code works fine, by the way! :D

Also, I had another peice of code:

Code: Select all

<?php $wr = $imagesDir . $wrName . $dirlabel . $wrType; // normal wind rose
				        $wrtext = langtransstr('Wind from') ." " . langtransstr($dirlabel);
			                        if ( (strip_units($avgspd) + strip_units($gstspd) < 0.0 )
Which wouldn't display the $wrCalm image when the wind speed was 0.0 mph and the wind gust was 0.0 mph, so I changed the code from:

Code: Select all

<?php $wr = $imagesDir . $wrName . $dirlabel . $wrType; // normal wind rose
				        $wrtext = langtransstr('Wind from') ." " . langtransstr($dirlabel);
			                        if ( (strip_units($avgspd) + strip_units($gstspd) < 0.0 )
To:

Code: Select all

<?php $wr = $imagesDir . $wrName . $dirlabel . $wrType; // normal wind rose
				        $wrtext = langtransstr('Wind from') ." " . langtransstr($dirlabel);
			                        if ( (strip_units($avgspd) + strip_units($gstspd) < 0.1 )
Then, the $wrCalm image, displayed again! :D
Post Reply