Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.6.5 (build 3081) - 28 May 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

See the Wiki to download the software or click on the Downloads link in the Forum Banner.

Temperature Text Colour

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

Moderator: daj

Post Reply
Mapantz
Posts: 716
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Temperature Text Colour

Post by Mapantz »

I tried a search on here, but searches don't seem to work for me.

I've also had trawl on stackoverflow and can't find anything.

I want to experiment in making a new style home page and show various data that is colour coded

For example;

30°C
9.3°C
0°C
-5°C

etc..

Here's a page of colours that I would use to correspond to the temps: https://warehamwx.co.uk/colour_example.php

The trouble is, I get my values like this <td><span class="ajax" id="temp"></td> so I don't know how to go about it.

Any help greatly appreciated.
Image

User avatar
beteljuice
Posts: 2918
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Temperature Text Colour

Post by beteljuice »

You are using smb_ajax.js ? - you are on your own !

You would need to break into the 'loop', check for id="temp", then check against value for color and add that style to the html content.
Image
......................Imagine, what you will KNOW tomorrow !

Mapantz
Posts: 716
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 x64
Location: Dorset - UK
Contact:

Re: Temperature Text Colour

Post by Mapantz »

ah yes, the dreaded smb ajax!

Is it possible to do updates of data like smb, but with PHP? I've got all of the tags I use on my site being uploaded in to a PHP file.
Image

User avatar
beteljuice
Posts: 2918
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Crunching Data Numbers ...

Post by beteljuice »

I wasn't ignoring this ....

You gave an example of changing text colour of any temp value, then you gave a link to an example with changed background colours, then you gave a html example of a multi-span ajax call !

Hmpph .. How to tackle this ?
CSS3 / SASS although being able to create / prepend / append element content, can't actually 'see' it to do any calc( ) type stuff.

So ... Something to inspect content with numbers and perform some actions, In this case change colour(s).

If any one is interested a new beteljuice plaything.
It changes the background and text colour of the PARENT element of the data element for Mapantz custom temp range and colours.
Colours can easily be reversed or you could use the guts of the code to eg. change data units.
Or eg. create an alert at some predetermined data (numeric* or string) value.
* any numeric value MUST be at the start of the data (unless you know what you're doing ;) )

It copes with static (hard-code, PHP, <#webtags>) and dynamic (ajax) content as long as the 'numeric' value is the first part of the data construct.
You may need to be a bit more creative with your containing elements and or style, but nothing too drastic :?
It won't be able to cope with 3rd party 'injects' where you can't alter the containing elements ..

Edit; It's pretty much an updated version of what Pintos original ajax does. We trawl the page for named class(es) and perform some action ...

So let me know if there is interest and I'll neaten-up / post the code.
Last edited by beteljuice on Mon 16 Dec 2019 3:21 pm, edited 2 times in total.
Image
......................Imagine, what you will KNOW tomorrow !

User avatar
beteljuice
Posts: 2918
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: ex XP SP3 - now W10 laptop grr
Location: Dudley, West Midlands, UK

Re: Temperature Text Colour

Post by beteljuice »

OK Map - you've had the chance with your personal colours ... :?
Above link now works across a more realistic temperature range of -50 > +50 (using colours as in Yet Another Dayfile Reader) ;)
Image
......................Imagine, what you will KNOW tomorrow !

Post Reply