Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 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

smb_ajax 1.3

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

Moderator: daj

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

smb_ajax 1.3

Post by Mapantz »

Hi there!

I downloaded the file from this site a long time go - brilliant script for showing live updated values on your website.

As the weather has been appalling these past few days, i've decided to do a bit of tinkering on my site.

I've set the Javascript file to show a red colour each time an updated value occurs, but I was wondering if anyone clever enough would be able to add the option of choosing a font weight to it? I wanted to give it a bold look.

Regards.
smb_ajax.1.3.js
You do not have the required permissions to view the files attached to this post.
Image
ExperiMentor
Posts: 214
Joined: Tue 24 Nov 2015 11:30 pm
Weather Station: Fine Offset & Davis Vantage Vue
Operating System: Windows 10; Raspbian Buster
Location: Switzerland

Re: smb_ajax 1.3

Post by ExperiMentor »

I don't know any javascript, but you got me interested!

A bit of Googling suggests that you need to go the part in your file that says

Code: Select all

if(flashtime!=0) ajx.style.color=flashcolour;
and add

Code: Select all

ajx.style.fontWeight = "bold"; //makes the text bold
Now I don't know if you can put it in the same line, or if you need to repeat the whole line or what, but that should be the code you need!

My source was: https://en.wikibooks.org/wiki/JavaScrip ... ent_styles

Added:
After a bit more research, I think you need to change this section to:

Code: Select all

if(flashtime!=0) {
  ajx.style.color=flashcolour;
  ajx.style.fontWeight = "bold";
} 
Also, you'll probably need to turn the BOLD off again in the "reset_ajax_color" function. So after:

Code: Select all

element.style.color='';
add an extra line to make:

Code: Select all

element.style.color='';
element.style.fontWeight = "normal";
Hope this helps!
Last edited by ExperiMentor on Sat 17 Aug 2019 10:03 pm, edited 1 time in total.
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: smb_ajax 1.3

Post by beteljuice »

Not quite that straight-forward I'm afraid ...

Yes your code will make the text bold when the element is 'flashed', but ... how do you turn it off ?

You need to go down to ..

Code: Select all

function reset_ajax_color( ) {
// reset all the <span class="ajax"...> styles to have no colour override
    elements = getElementsByClass("span","ajax");
    numelements = elements.length;

    for (var index=0;index!=numelements;index++) {
        element = elements[index];
        element.style.color='';
// NEW ** turn off bold at end of flash period
         element.style.fontWeight='normal';
    }
}
Image
......................Imagine, what you will KNOW tomorrow !
ExperiMentor
Posts: 214
Joined: Tue 24 Nov 2015 11:30 pm
Weather Station: Fine Offset & Davis Vantage Vue
Operating System: Windows 10; Raspbian Buster
Location: Switzerland

Re: smb_ajax 1.3

Post by ExperiMentor »

Not quite that straight-forward I'm afraid ...
I realised that too and made the same edit in parallel!!

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

Re: smb_ajax 1.3

Post by Mapantz »

Sweet - Nailed it!

Thanks guys!! :clap:

Bold was a little too much in the end, so as fontweight can use a numerical value, I went down the middle and set it at 600.

Thank you so much.
Image
Mapantz
Posts: 1807
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: smb_ajax 1.3

Post by Mapantz »

Back again!

Can the .js file (in my first post) be adapted to read from two different xml files with the same schema?
Image
User avatar
HansR
Posts: 5957
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: smb_ajax 1.3

Post by HansR »

Is there a working example to get on track quick and easy and see how far I can get to use it?
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
Mapantz
Posts: 1807
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: smb_ajax 1.3

Post by Mapantz »

I can't quite remember where I got the info from, originally. I think it may have been from this forum?!

Here's the files I use, along with a quick explanation:

I get Cumulus MX to process the cumulusxml.xml file and then upload it as realtime.xml

I put this is the <head> section

Code: Select all

<script src="https://code.jquery.com/jquery-3.4.1.min.js"  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="smb_ajax.js"></script>
I put this in my header file (it can go in any file that you want to grab data with)

Code: Select all

<script>
//<![CDATA[
initialize('./realtime.xml', 4);
// ]]>
</script>
Here's my example of grabbing some of the data:

Code: Select all

<td style="text-align: left;">Inside Temperature:</td>
<td><span class="ajax" id="intemp"></span>&nbsp;&#176;C</span></td>
<td style="text-align: left;">Inside Humidity:</td>
<td><span class="ajax" id="inhum"></span>&nbsp;%</span></td>
As soon as new data in the realtime.xml appears, the data will change and flash red for a small duration.

I personally process and upload the file every 4 seconds.

The reason I ask if smb_ajax.js could be used to read two xml files at the same time is, I am now using a second instance of Cumulus MX to upload my Ecowitt GW-1000 data. I wanted to get that to upload it's own xml file with it's data so it could update like my Davis data does, albeit at 30 seconds rather than 4 seconds.

I was using a small workaround; I got Cumulus MX for the GW-1000 to upload the xml file with it's own data with the same name realtime.xml, each instance of Cumulus MX would overwrite the remote files. However, it caused a few issues.
You do not have the required permissions to view the files attached to this post.
Image
User avatar
HansR
Posts: 5957
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: smb_ajax 1.3

Post by HansR »

Thanks, something to digest ;)
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: smb_ajax 1.3

Post by beteljuice »

I'm unsure what you are asking ?

The script can parse any correct format xml file you declare:

initialize('./realtime.xml', 4);

However; In any one 'page' the output can only be used once (last one in), so you couldn't have eg. two tables with different data sources.

If you are talking about different pages for the different data, but still using the script, then the second xml file will need to have a different filename and / or path_to/filename
Image
......................Imagine, what you will KNOW tomorrow !
Mapantz
Posts: 1807
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: smb_ajax 1.3

Post by Mapantz »

beteljuice wrote: Sat 23 Nov 2019 10:18 pm I'm unsure what you are asking ?

The script can parse any correct format xml file you declare:

initialize('./realtime.xml', 4);

However; In any one 'page' the output can only be used once (last one in), so you couldn't have eg. two tables with different data sources.
That's exactly it.

I have two xml files I want to read and show the data on the same page. That's why I asked if it was possible to have the smb_ajax read from two xml's. The structure is the same, it just contains different data values.

realtime.xml and gw1000.xml
Image
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: smb_ajax 1.3

Post by beteljuice »

... but the output variables are the same names !

= can't be done
Image
......................Imagine, what you will KNOW tomorrow !
Post Reply