Page 1 of 1
Current Block (v24) - Showing incorrect Alternate Values
Posted: Sun Feb 25, 2018 3:21 pm
by MonyMony
I installed the new version and activated the option to show Alternate Values.

- Screen Shot 2018-02-25 at 10.11.15 AM.png (52.37 KiB) Viewed 10188 times
Unfortunately the Alternate Pressure and Wind Speed units are getting ignored.

- Screen Shot 2018-02-25 at 10.11.03 AM.png (106.26 KiB) Viewed 10188 times
I looked at the code and the values appear to be hard coded so guessing something got missed in the update.
$alternativeW = "mph";
$alternativeP = "inhg";
Nice update and BTW, congrats on the new job Jachym!
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Sun Feb 25, 2018 3:29 pm
by MonyMony
Additionally, if I update the code to set:
$alternativeP = "hpa";
or
$alternativeP = "mmhg";
Then the block completely breaks:

- Screen Shot 2018-02-25 at 10.27.16 AM.png (73.93 KiB) Viewed 10187 times
Manually updating $alternateW works as expected.
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Sun Feb 25, 2018 4:07 pm
by magical46
Getting the same issue here.
www.philsweather.co.uk
Temp's and precipitation show alternates but wind and pressure show same value twice.
Phil
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Sun Feb 25, 2018 8:16 pm
by Jachym
Interesting, I will have a look
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Sun Feb 25, 2018 8:18 pm
by Jachym
I think I know...
try opening currentBlock.php
lines 198 and 199
$alternativeW = "mph";
$alternativeP = "inhg";
Delete them. These were for testing purposes and looks like I forgot to delete them.
Please let me know if that solved the problem
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Mon Feb 26, 2018 12:41 pm
by MonyMony
Jachym wrote: ↑Sun Feb 25, 2018 8:18 pm
I think I know...
try opening currentBlock.php
lines 198 and 199
$alternativeW = "mph";
$alternativeP = "inhg";
Delete them. These were for testing purposes and looks like I forgot to delete them.
Please let me know if that solved the problem
Hi Jachym,
No joy.... If I remove them then the block is blank.

- Screen Shot 2018-02-26 at 7.40.43 AM.png (33.12 KiB) Viewed 10156 times
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Mon Feb 26, 2018 1:00 pm
by MonyMony
Figured out the problem...
In lines 1694 thru 1764 the Eval function is missing the closing parenthesis. Once I add that then everything works. I changed it to this:
Code: Select all
if(json['P']!=$("#currentPValue").text()){
changeP = true;
}
else{
changeP = false;
}
$("#currentPValue").text(json['P']);
<?php
if($dualUnits){
?>
if(json['P']!="--"){
<?php
if($displayPressUnits=="hpa" && $alternativeP == "inhg"){
?>
altP = eval(json['P']) * 0.02952);
altP = altP.toFixed(2);
<?php
}
?>
<?php
if($displayPressUnits=="inhg" && $alternativeP == "hpa"){
?>
altP = (eval(json['P']) * 33.8638);
altP = altP.toFixed(1);
<?php
}
?>
<?php
if($displayPressUnits=="hpa" && $alternativeP == "mmhg"){
?>
altP = (eval(json['P']) * 0.75006);
altP = altP.toFixed(1);
<?php
}
?>
<?php
if($displayPressUnits=="mmhg" && $alternativeP == "hpa"){
?>
altP = (eval(json['P']) * 1.3332);
altP = altP.toFixed(1);
<?php
}
?>
<?php
if($displayPressUnits=="inhg" && $alternativeP == "mmhg"){
?>
altP = (eval(json['P']) * 25.3999);
altP = altP.toFixed(1);
<?php
}
?>
<?php
if($displayPressUnits=="mmhg" && $alternativeP == "inhg"){
?>
altP = (eval(json['P']) * 0.03937);
altP = altP.toFixed(2);
<?php
}
?>
<?php
if($displayPressUnits==$alternativeP){
?>
altP = json['P'];
<?php
}
?>
}
$("#currentPValueAlt").text(altP);
<?php
}
?>
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Mon Feb 26, 2018 1:37 pm
by MonyMony
One very minor issue though...
If I change my site to Metric (normally Imperial Units), then those alternate values do not change back to their normally default units. Honestly I don't mind if this left this way as it is a low possibility that anyone would notice, but figured I would point it out just so you are aware.
Site changed to Metric:

- Screen Shot 2018-02-26 at 8.34.22 AM.png (43.24 KiB) Viewed 10150 times
Site set to Default Units (Imperial)

- Screen Shot 2018-02-26 at 8.38.29 AM.png (40.2 KiB) Viewed 10148 times
Thanks again for adding the Alternate Values to the CURRENT module. This is something I have been hoping to see for some time.

Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Wed Feb 28, 2018 7:21 pm
by magical46
Just installed the updated version (24.1) but with "Show alternate values" selected its not showing any values at all.
www.philsweather.co.uk
Phil
Re: Current Block (v24) - Showing incorrect Alternate Values
Posted: Wed Feb 28, 2018 10:04 pm
by Fraggboy
Mine was showing blank also after downloading the latest update.
Once I followed MonyMony's post above, I modified the currentBlock.php file and it's working great. Instead of adding the ending parenthesis, I removed the beginning parenthesis which worked for me.