IMPORTANT! The server may go down soon - possibly permanently. Please read the latest post in Announcements and News

Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Truncate Webtag Value

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

Moderators: daj, TNETWeather

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

Truncate Webtag Value

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

Re: Truncate Webtag Value

Postby mcrossley » Mon Sep 03, 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 Mar 12, 2017 8:33 pm
Weather Station: VP2+
Operating System: Raspbian Stretch
Location: US Mid-Atlantic

Re: Truncate Webtag Value

Postby Herbaldew » Tue Sep 04, 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: 443
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Customised mix of Fine Offset
Operating System: Tempermental Win. 10 PC
Location: UK

Re: Truncate Webtag Value

Postby sfws » Tue Sep 04, 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.


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 3 guests