Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3044 7 December 2018. See the Wiki for download

Truncate Webtag Value

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

Moderator: daj

Post Reply
Herbaldew
Posts: 84
Joined: Sun 12 Mar 2017 8:33 pm
Weather Station: VP2+
Operating System: Raspbian Stretch
Location: US Mid-Atlantic

Truncate Webtag Value

Post by Herbaldew » Sun 02 Sep 2018 3:44 pm

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: 5234
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Truncate Webtag Value

Post by mcrossley » Mon 03 Sep 2018 4:11 pm

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: 84
Joined: Sun 12 Mar 2017 8:33 pm
Weather Station: VP2+
Operating System: Raspbian Stretch
Location: US Mid-Atlantic

Re: Truncate Webtag Value

Post by Herbaldew » Tue 04 Sep 2018 1:47 pm

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: 462
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Truncate Webtag Value

Post by sfws » Tue 04 Sep 2018 3:05 pm

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