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 4017) - 17 March 2024

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 drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Truncate Webtag Value

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

Moderator: daj

Post Reply
Herbaldew
Posts: 113
Joined: Sun 12 Mar 2017 8:33 pm
Weather Station: VP2+
Operating System: Raspberry Pi OS (64-bit)
Location: US Mid-Atlantic

Truncate Webtag Value

Post by Herbaldew »

When using the webtag for extra temp 1, the value returned has a decimal and a zero, and it displays as eg "81.0".

How can I make it drop the decimal and tenths position, and make it display as eg "81"? In the case of Davis anyway, the extra temp sensors only return full numbers, no tenths thus making the tenths column superfluous.


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

Re: Truncate Webtag Value

Post by mcrossley »

Depends on how you present the data. Cumulus can't do it for you, so if you use PHP to construct the page, reformat the data in PHP, failing that you will have to use JavaScript in the browser.
Herbaldew
Posts: 113
Joined: Sun 12 Mar 2017 8:33 pm
Weather Station: VP2+
Operating System: Raspberry Pi OS (64-bit)
Location: US Mid-Atlantic

Re: Truncate Webtag Value

Post by Herbaldew »

Thanks. After a good bit of frustration, I did it with JavaScript.

I was trying to work this out on Internet Explorer as it is what I use for my CMX interface. Turns out that Math.trunc doesn't work on IE :( Using Math.floor instead produced the desired result :)
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Truncate Webtag Value

Post by sfws »

Herbaldew wrote: I did it with JavaScript.

I was trying to work this out on Internet Explorer
Strictly speaking Microsoft Internet Explorer uses "jScript" (not "JavaScript" as implemented by other browsers).
Although both script languages now follow the European Computer Manufacturers Association 262 Script Standard, they implement different editions of that standard, so there will be some syntax differences, as you have discovered, and there are also differences between IE versions (research for yourself if you want more details).
The popularity of libraries like jQuery is because they allow you to write code that works in multiple browsers (and other agents) regardless of which ECMA edition they implement and it also allows for variance in the extent to which older and newer browser versions conform to the standard.
Post Reply