Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.0.0 (build 4022) - 11 May 2024

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

UV colour depending on the number ie None Low Medium High Very High

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

Moderator: daj

User avatar
dazza1223
Posts: 867
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

im playing with a bit off js to get the UV band to chance colour depending on the number ie None Low Medium High Very High etc


var uv = rawdata[45];
if (uv=="0"){var uvword="None";} else
if (uv=="3"){var uvword="<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;Low&nbsp;</span>";} else
if (uv=="6"){var uvword="<span style=\"border: solid 1px; color: black; background-color: #FBEE09;\">&nbsp;Medium&nbsp;</span>";} else
if (uv=="8"){var uvword= "<span style=\"border: solid 1px; color: black; background-color: #FD9125;\">&nbsp;High&nbsp;</span>";} else
if (uv=="11"){var uvword="<span style=\"border: solid 1px; color: #FFFFFF; background-color: #F63F37;\">&nbsp;Very&nbsp;High&nbsp;</span>";} else
{ var uvword="";}
$("#UVone").html(uvword);

but it seems to not work when i put this on test page

<td><span id="UVone"></span>


so i was wounding if some one can spot the error in this bit off code


thank you
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
ConligWX
Posts: 1645
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 24.04 LTS
Location: Bangor, NI
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by ConligWX »

sorry cant help there but noticed on your site the website isn't updating correctly or your file checks are looking at the wrong data.

https://www.davisworthing.co.uk/uploadstatus.php
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir • CumulusMX v4.0.0

Image
BCJKiwi
Posts: 1256
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by BCJKiwi »

Both the Saratoga and MXUI templates have this feature managed by the ajaxCUwx.js and ajaxCUmx.js files respectively.
(MXUI borrows heavily from the original Saratoga ajax but also removes a lot and adds a lot more!)

If you view those templates that may help but just as likely confuse (as it did me!).

There are also Heat colour words in the Saratoga template.
User avatar
dazza1223
Posts: 867
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: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

ConligWX wrote: Tue 31 May 2022 9:52 pm sorry cant help there but noticed on your site the website isn't updating correctly or your file checks are looking at the wrong data.

https://www.davisworthing.co.uk/uploadstatus.php
Oh thank you I will take a look at that but thank you for spotting it out
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
dazza1223
Posts: 867
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: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

BCJKiwi wrote: Tue 31 May 2022 10:18 pm Both the Saratoga and MXUI templates have this feature managed by the ajaxCUwx.js and ajaxCUmx.js files respectively.
(MXUI borrows heavily from the original Saratoga ajax but also removes a lot and adds a lot more!)

If you view those templates that may help but just as likely confuse (as it did me!).

There are also Heat colour words in the Saratoga template.
Yh that where i found the piece of the code and modified it to my own JS file but it seem that it should work but there maybe a small little error somewhere I can't see but I know there's a lot more brainy people on here here can actually spot it out straight away?
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

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

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

Code: Select all

var uv = rawdata[45];
if (uv=="0"){var uvword="None";} else
if (uv=="3"){var uvword="<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;Low&nbsp;</span>";} else
if (uv=="6"){var uvword="<span style=\"border: solid 1px; color: black; background-color: #FBEE09;\">&nbsp;Medium&nbsp;</span>";} else
if (uv=="8"){var uvword= "<span style=\"border: solid 1px; color: black; background-color: #FD9125;\">&nbsp;High&nbsp;</span>";} else
if (uv=="11"){var uvword="<span style=\"border: solid 1px; color: #FFFFFF; background-color: #F63F37;\">&nbsp;Very&nbsp;High&nbsp;</span>";} else
{ var uvword="";}
$("#UVone").html(uvword);
You are declaring the variable uvword within each if block, so it will not be available outside those if statement blocks.
User avatar
dazza1223
Posts: 867
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: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

OK thanks mark will u be so kindly to adjust it so it will work?
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
BCJKiwi
Posts: 1256
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by BCJKiwi »

Remove the var after each {
User avatar
dazza1223
Posts: 867
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: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

BCJKiwi wrote: Sun 05 Jun 2022 8:34 pm Remove the var after each {

Code: Select all

var uv = rawdata[45];
if (uv=="0"){ uvword="None";} else
if (uv=="3"){ uvword="<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;Low&nbsp;</span>";} else
if (uv=="6"){ uvword="<span style=\"border: solid 1px; color: black; background-color: #FBEE09;\">&nbsp;Medium&nbsp;</span>";} else
if (uv=="8"){ uvword= "<span style=\"border: solid 1px; color: black; background-color: #FD9125;\">&nbsp;High&nbsp;</span>";} else
if (uv=="11"){ uvword="<span style=\"border: solid 1px; color: #FFFFFF; background-color: #F63F37;\">&nbsp;Very&nbsp;High&nbsp;</span>";} else
{ uvword="";}
$("#UVone").html(uvword);

ok ive tried that but it seem to not being working?
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
freddie
Posts: 2493
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 22.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by freddie »

Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Freddie
Image
User avatar
mcrossley
Posts: 12836
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Yes it would be best to do that...

Code: Select all

var uv = rawdata[45];
var uvword;
if (uv=="0"){ uvword="None";} else
if (uv=="3"){ uvword="<span ...
User avatar
HansR
Posts: 5994
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by HansR »

mcrossley wrote: Tue 07 Jun 2022 2:11 pm
freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Yes it would be best to do that...

Code: Select all

var uv = rawdata[45];
var uvword;
if (uv=="0"){ uvword="None";} else
if (uv=="3"){ uvword="<span ...
All true but I don't think it is the cause of failing.
Maybe @dazza could elaborate on what exactly fails? Does it show anything in the UVone element or does it show erroneous something?
As you compare strings is that truly the content of the rawdata or is it e.g. "0 " with as result the if statements all fail and you get an empty string in the html element. If uncertain add a console.log statement after each if-clause to see something.

Or go to stackoverflow.
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
HansR
Posts: 5994
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by HansR »

freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Javascript is an invitation to bad programming :lol:
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
freddie
Posts: 2493
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 22.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by freddie »

HansR wrote: Tue 07 Jun 2022 2:18 pm
freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Javascript is an invitation to bad programming :lol:
:lol: that's why I only touch it when necessary
javascript.jpg
You do not have the required permissions to view the files attached to this post.
Freddie
Image
User avatar
dazza1223
Posts: 867
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: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

freddie wrote: Tue 07 Jun 2022 2:32 pm
HansR wrote: Tue 07 Jun 2022 2:18 pm
freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Javascript is an invitation to bad programming :lol:
:lol: that's why I only touch it when necessary
javascript.jpg
:lol: :lol: :lol: :lol: :lol: :lol:
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
Post Reply