Author Topic: Display changing after opening  (Read 725 times)

0 Members and 1 Guest are viewing this topic.

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Display changing after opening
« on: August 05, 2019, 02:19:51 PM »
Hi.... this is an odd problem.

My weather web site it steveianson.co.uk,
Base world setting
Cumulus

I did a clean install yesterday of the base world 2019 template.

All worked well until this morning. Now for no apparent reason, about 1 second after the site loads the display changes from imperial (as setup in setting.php) to metric.

I have tried to attach the settings.php file for your help but the system won't let me.

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #1 on: August 05, 2019, 02:57:38 PM »
You need to also fix the settings for the javascript code, which is what's modifying the values.

Should be in a file of the form ajaxXXwx.js, where XX is an abbreviation for your weather software.

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Re: Display changing after opening
« Reply #2 on: August 06, 2019, 10:57:52 AM »
Thanks for the help Jasiu, I have changed file ajaxCUwx.js to the same as settings.php but the display still changes.  :-(

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #3 on: August 06, 2019, 11:32:01 AM »
Here's what I see in ajaxCUwx.js when I load your site :

Code: [Select]
// -- begin settings --------------------------------------------------------------------------
var flashcolor = '#00CC00'; // color to flash for changed observations RGB
var flashtime  = 2000;       // miliseconds to keep flash color on (2000 = 2 seconds);
var reloadTime = 5000;       // reload AJAX conditions every 5 seconds (= 5000 ms)
var maxupdates = 12;          // Maxium Number of updates allowed (set to zero for unlimited)
                             // maxupdates * reloadTime / 1000 = number of seconds to update
var realtimeFile = 'realtime.txt'; //  URL location of realtime.txt relative to document root of website
var ajaxLoaderInBody = false; // set to true if you have <body onload="ajaxLoader(..."
var imagedir = './ajax-images';  // place for wind arrows, rising/falling arrows, etc.
var useunits = 'E';         // 'E'=USA(English) or 'M'=Metric
var decimalComma = false;    // =false for '.' as decimal point, =true for ',' (comma) as decimal point
var useFeelslike = 0;        // =0 use HeatIndex, =1 use Humidex, =2 use apparent temperature
var useKnots = false;       // set to true to use wind speed in Knots (otherwise
// wind in km/hr for Metric or mph for English will be used.
var useMPS   = false;       // set to true for meters/second for metric wind speeds, false= km/h
var useMPH   = true;       // set to true to force MPH for both English and Metric units
var useFeet  = true;       // set to true to force Feet for height in both English and Metric
var usehPa  = false;       // set to true to force hPa for baro in both English and Metric
var showUnits = true;       //  set to false if no units are to be displayed
var showDateMDY = false;     // set to false to show date as dd/mm/yy
var thermometer = './thermometer.php'; // script for dynamic thermometer PNG image (optional)
// optional settings for the Wind Rose graphic in ajaxwindiconwr as wrName + winddir + wrType
var wrName   = 'wr-';       // first part of the graphic filename (followed by winddir to complete it)
var wrType   = '.png';      // extension of the graphic filename
var wrHeight = '58';        // windrose graphic height=
var wrWidth  = '58';        // windrose graphic width=
var wrCalm   = 'wr-calm.png';  // set to full name of graphic for calm display ('wr-calm.gif')
// -- end of settings -------------------------------------------------------------------------

"useunits" needs to be 'M'  Double check other settings (e.g. useFeet) to make sure they are what you want.
 

Offline AWL

  • Forecaster
  • *****
  • Posts: 677
    • Ardmore Weather Live
Re: Display changing after opening
« Reply #4 on: August 06, 2019, 11:58:45 AM »
You seem to have bad luck on this....realtime.txt not uploading

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Re: Display changing after opening
« Reply #5 on: August 07, 2019, 01:32:06 PM »
Nope... I have re-loaded another clean version and still got the same problem. I have attached the settings.php file (zipped) for you to look at.



I have had the original version working without any problems, I am begging to think that it is something to do with Hostinger my site hoster.
« Last Edit: August 07, 2019, 01:35:45 PM by stevei »

Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 202
    • test site
Re: Display changing after opening
« Reply #6 on: August 07, 2019, 04:30:07 PM »
You still haven't followed Jasius advice..

in ajaxCUwx.js

Try var useunits = 'M';
Imagine what you will KNOW tomorrow !

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #7 on: August 07, 2019, 06:36:22 PM »
What the beteljuice said... ^^^^

Kind of hard to help if you don't act on the advice.

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Re: Display changing after opening
« Reply #8 on: August 08, 2019, 06:47:22 AM »
Thanks for your help all.

I did change useunits to M and it made no difference. When I did the new clean install I forgot to change it back. I tried changing the decimal point to a comma and it did not change on the station web site. It looks like it is not reading the ajaxCUwx.js file properly.

I have just spotted that if I use IE browser the wind is in mph but rainfall is in mm except for "rain yesterday" which is in inches

In Chrome, wind is in km/h except for "Gust month". The rainfall section in the same as IE
« Last Edit: August 08, 2019, 06:59:33 AM by stevei »

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #9 on: August 08, 2019, 07:54:04 AM »
One thing to keep in mind is that the browser tries to cache javascript so that it doesn't have to fetch it every time. Shift-reload on Firefox on a Mac tells the browser to reload all javascript. Not sure if that same combo does it on all browsers / OSs.

Anyway, to be clear: You want temperature in C and lengths in English units, correct?


Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 202
    • test site
Re: Display changing after opening
« Reply #10 on: August 08, 2019, 08:07:15 AM »
Might want rain in mm. - hmm, what happens after brexit ?

I haven't spent half-a-crown in years  :grin:
Imagine what you will KNOW tomorrow !

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #11 on: August 08, 2019, 08:59:04 AM »
Assuming what I wrote above is what you are looking for...

If appears that the js code has no provision for setting the rain units to inches after setting useunits to M. Here's what I think you need to do.

Find this code:

Code: [Select]
var useMPS   = true;       // set to true for meters/second for metric wind speeds, false= km/h
var useMPH   = true;       // set to true to force MPH for both English and Metric units
var useFeet  = true;       // set to true to force Feet for height in both English and Metric
var usehPa  = false;       // set to true to force hPa for baro in both English and Metric
var showUnits = true;       //  set to false if no units are to be displayed

FWIW you probably want to set useMPS false but it doesn't seem to hurt anything I can see.

You need to add an extra line after the useFeet setting:

Code: [Select]
var useFeet  = true;       // set to true to force Feet for height in both English and Metric
var useIn  = true;       // set to true to force Inches for rain in both English and Metric

Then, down in the ajax_set_units() function, find this:

Code: [Select]
if(useKnots) { uomWind = ' kts'; }
  if(useMPS)   { uomWind = ' m/s'; }
  if(useMPH)   { uomWind = ' mph'; }
  if(useFeet)  { uomHeight = ' ft'; }
  if(usehPa)  { uomBaro = ' mb'; }

and add one line:

Code: [Select]
  if(useFeet)  { uomHeight = ' ft'; }
  if(useIn)  { uomRain = ' in'; }

The reason the "rain yesterday" remains as inches is because the javascript code doesn't modify that field.

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Re: Display changing after opening
« Reply #12 on: August 08, 2019, 11:46:02 AM »
Spot on Jasui, my site is now working properly (after clearing my browser cache), many thanks.

Beetlejuice... being of pensionable age I still work in half-crowns and inches. The most used app on my phone in the Converter.

One more question where do I change information for "Nearby Metar Reports"

Offline stevei

  • Member
  • *
  • Posts: 13
    • steveianson
Re: Display changing after opening
« Reply #13 on: August 08, 2019, 01:49:46 PM »
I thought that it was too good to be true, but I am getting close.

It is now raining (first time for about 2 weeks), although the station states inch the measurement is mm. Any thoughts?

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #14 on: August 08, 2019, 03:48:24 PM »
1) METAR instructions here: https://saratoga-weather.org/wxtemplates/find-metar.php

2) Which field was showing rain in mm (e.g., rain today, rain rate...)?  It doesn't look like it is raining right now (of course not... as soon as I look away, it will rain again).

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 632
    • LexMAWeather
Re: Display changing after opening
« Reply #15 on: August 08, 2019, 04:09:12 PM »
I think I see what you are hitting.  One more mod... find this function:

Code: [Select]
function convertRain ( inrawrain ) {
// function expects input in mm
var rawrain = cRainToMM(inrawrain);
if (useunits == 'E') { // convert mm to inches
   return (rawrain * .0393700787);
} else {
   return (rawrain * 1.0); // leave in mm
}
}

Change

Code: [Select]
if (useunits == 'E') { // convert mm to inches
to

Code: [Select]
if (useunits == 'E' || useIn) { // convert mm to inches
Although it seems like a waste of CPU to convert from inches to mm to inches again, this is the least intrusive way I can see to make it work.