Author Topic: WD trends in Saratoga template [Resolved]  (Read 953 times)

0 Members and 1 Guest are viewing this topic.

Offline Vasco

  • Forecaster
  • *****
  • Posts: 343
    • PWS
WD trends in Saratoga template [Resolved]
« on: March 29, 2023, 01:54:48 PM »
Another trivial question: where can I change the current pressure, shown to 3 d.p., to an integer value like all the rest?

I've tried using rtrim($baro0minuteago,'.000') and round($baro0minuteago,0) in WD-trends-inc.php, to no avail. Note that $baro0minuteago is an integer in testtags.php. . .

EDIT: just found d.p. settings in ajaxWDwx.js. . . but 3 d.p. is for imperial units.
« Last Edit: March 29, 2023, 06:51:56 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WD trends in Saratoga template
« Reply #1 on: March 29, 2023, 02:20:01 PM »
PHP w/o ajaxWDwx.js enabled is displaying the current line for baro as an integer (no decimal point/digits after).

When ajaxWDwx.js starts execution, the value flips to show the 3 digits of zero after a decimal point.

Odd.. you have set
Code: [Select]
dpBaro = 0;   // was 1 in the script so that should have turned off the decimals.

You might try changing
Code: [Select]
set_ajax_obs("ajaxbaro",pressure.toFixed(dpBaro) + uomBaro); to
Code: [Select]
set_ajax_obs("ajaxbaro",clientraw[6] + uomBaro); to avoid the math.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 343
    • PWS
Re: WD trends in Saratoga template
« Reply #2 on: March 29, 2023, 04:56:22 PM »
PHP w/o ajaxWDwx.js enabled is displaying the current line for baro as an integer (no decimal point/digits after).

When ajaxWDwx.js starts execution, the value flips to show the 3 digits of zero after a decimal point.

Odd.. you have set
Code: [Select]
dpBaro = 0;   // was 1 in the script so that should have turned off the decimals.

Also tried setting next line
Code: [Select]
dpBaroNoU = 0   // was 1
- note typo has dbBaroNoU - but that didn't work. Nor did setting imperial
Code: [Select]
dpBaroNoU = 0   // was 3
Quote
You might try changing
Code: [Select]
set_ajax_obs("ajaxbaro",pressure.toFixed(dpBaro) + uomBaro); to
Code: [Select]
set_ajax_obs("ajaxbaro",clientraw[6] + uomBaro); to avoid the math.

But WD-trends-inc.php uses "ajaxbaroNoU", not "ajaxbaro"?
Code: [Select]
<td><span class="ajax" id="ajaxdewNoU"><?php echo $dew0minuteago?></span></td>

defined as
Code: [Select]
//Pressure...
var pressure = convertBaro(clientraw[6]);
set_ajax_obs("ajaxbaro",pressure.toFixed(dpBaro) + uomBaro);
set_ajax_obs("ajaxbaroNoU",pressure.toFixed(dpBaroNoU));
set_ajax_obs("gizmobaro",pressure.toFixed(dpBaro) + uomBaro);

If you put id="ajaxbaro" in WD-trends-inc.php instead you get an integer plus units. . . see attached.
« Last Edit: March 29, 2023, 06:09:04 PM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WD trends in Saratoga template
« Reply #3 on: March 29, 2023, 06:07:18 PM »
Yep.. sorry.  My bad.  You are correct; the one for ajaxbaroNoU should be done with clientraw[6].

Even though I wrote this stuff, sometimes my memory is bad and I should have checked the HTML of wxtrends.php before posting.
« Last Edit: March 29, 2023, 06:08:52 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 343
    • PWS
Re: WD trends in Saratoga template
« Reply #4 on: March 29, 2023, 06:23:40 PM »
Still no good. Tried
Code: [Select]
set_ajax_obs("ajaxbaroNoU",clientraw[6] + uomBaro);
and
Code: [Select]
set_ajax_obs("ajaxbaroNoU",clientraw[6]);
But still got 3 d.p.
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WD trends in Saratoga template
« Reply #5 on: March 29, 2023, 06:36:01 PM »
I'm seeing the page load w/o the 3 decimal places (just the integer) for current baro.

Try doing a shift-reload to refresh the cache with the updated JavaScript.
Your current ajaxWDwx.js has
Code: [Select]
set_ajax_obs("ajaxbaroNoU",pressure.toFixed(dpBaroNoU)); and
Code: [Select]
var dpBaroNoU = 0; // was 3, default for Imperial trends data
...
dpBaroNoU = 0;   // was 1
and acccording to JavaScript a number.toFixed(0) should produce a rounded integer display.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 343
    • PWS
Re: WD trends in Saratoga template
« Reply #6 on: March 29, 2023, 06:46:04 PM »
and acccording to JavaScript a number.toFixed(0) should produce a rounded integer display.

. . . of course it does, if you remember to do Ctrl-F5  :oops: :oops: :oops:

Sorry (again), Ken.

P.S. did you check the typo I mentioned? (Edit: around line 171 of ajaxWDwx.js)

Presumably that's why changing metric dbBaroNoU to 0 didn't work: it had to use imperial dpBaroNoU = 3 instead.

« Last Edit: March 30, 2023, 07:28:49 AM by Vasco »
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WD trends in Saratoga template
« Reply #7 on: March 29, 2023, 06:53:52 PM »
Ahh.. that dbBaroNoU = 1; typo has been there since the script was released 13-Dec-2006 and you are the first one to spot it.  I think the same typo may be in other of the ajaxXXwx.js scripts too, since they were largely based on this (primeval) script.

You have good eyes!
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Vasco

  • Forecaster
  • *****
  • Posts: 343
    • PWS
Re: WD trends in Saratoga template
« Reply #8 on: March 29, 2023, 06:58:17 PM »
You have good eyes!

Once upon a long time ago I was an editor, doing a lot of proof-reading. . .  :-)
Oregon Scientific WMR200 + Weather Display in Windows 10

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9277
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: WD trends in Saratoga template [Resolved]
« Reply #9 on: March 29, 2023, 07:56:16 PM »
Ahh.. that dbBaroNoU = 1; typo has been there since the script was released 13-Dec-2006 and you are the first one to spot it.  I think the same typo may be in other of the ajaxXXwx.js scripts too, since they were largely based on this (primeval) script.

Just checked.. only ajaxWDwx.js and ajaxWEEWXwx.js have the typo (whew!  \:D/ ).  The other scripts do not have the issue.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

 

anything