cloudy

Author Topic: Current UV index intensity indication wrong on ajax update (9.11a-9.13 Ajax)  (Read 226 times)

0 Members and 1 Guest are viewing this topic.

Offline PinkyCZ

  • Posts: 68
  • Jirkov, Czech Republic
    • Weather in Jirkov, CZ
Hi All,
this is the probelm I've discovered after a long time, but it must have been there for quite a while I'm afraid. When UV sensor reas value, it is displayed at my dashoard.
Now at the first page load, currentreading which today is 4-5 is shown with correct colour and tag next to it, description says "Medium".
Within a split of a second after page is loaded ajax upates the valuesm, the page flashes with green numbers and current display value stays shown with suddenly changed description to "Low".. See the screenshot please.
I was trying to find out where this evaluation is really done and I see Ajaxwdwx is having a function that deals with uv range "ajax_getUVrange". It seems as if the current UV value is lost at ajax update, despite in the testtags correct VPuv value exist...

Any ideas why ajax update is unable to determine current uv risk level??

« Last Edit: September 29, 2011, 12:44:49 PM by PinkyCZ »

Offline PinkyCZ

  • Posts: 68
  • Jirkov, Czech Republic
    • Weather in Jirkov, CZ
Re: Current UV index intensity indication wrong on ajax update
« Reply #1 on: September 29, 2011, 12:41:52 PM »
I'll take the opportunity to anwer this myself.
I was using Basheewa's 9.11a Ajax that supports metric and imperial UoM switching on the dashboard, and upgraded recently to 9.13 (latest). Both version had this problem and I narrowed it down to single line of code in ajaxwdwx.js

function ajax_getUVrange ( uv ) { // code simplified by FourOhFour on wxforum.net
   var uvword = "None";
   var uvclr1  = UVColor[Math.min(11,Math.round(uv))];
   switch (true) {
   case (uv < 0): uvword = langUVWords[6]; uvclr2 = 'none';    break; // UV sensor is not sending
   case (uv == 0): uvword = langUVWords[0]; uvclr2 = 'none';    break; // None
   case (uv < 3): uvword = langUVWords[1]; uvclr2 = '#4EB400'; break; // Low
   case (uv < 6): uvword = langUVWords[2]; uvclr2 = '#F7E400'; break; // Medium
   case (uv < 8): uvword = langUVWords[3]; uvclr2 = '#F85900'; break; // High
   case (uv <11): uvword = langUVWords[4]; uvclr2 = '#D8001D'; break; // Very High
   case (uv >18): uvword = langUVWords[6]; uvclr2 = 'none';    break; // UV sensor is not sending
   default      : uvword = langUVWords[5]; uvclr2 = '#998CFF';        // Extreme
   }
   return ('<span style="border: 1px solid gray; text-transform: uppercase; font-weight: bold; padding-bottom: 1px; background-color: '+ uvclr1 +';">&nbsp;'+ uvword +'&nbsp;</span>');
}; // end ajax_getUVrange function


Stepping through the script the uv value has been always losing it value at the second line of the switch/case where it should have been compared to zero... havin (uv==0) fixes the problem.

Uff....
« Last Edit: September 29, 2011, 12:46:58 PM by PinkyCZ »

 

cumulus