Author Topic: New Saratoga AJAX/PHP template plugin for WeatherCat now available  (Read 38930 times)

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #15 on: August 21, 2012, 04:41:58 AM »
Sorry for the difficulties.. would you mind copying the contents of your wxnewpage in a post (the area bounded by <div id="main-copy'> ... </div><!-- end main-copy -->) and I'll take a look.

Additional include()s are not needed .. all the data comes from the WCTtags.php into the global $WX[] array.
The WCT-defs.php is automatically included to map SOME of the $WX[] values to $wdvariablenames used in the template, but you can always refer to the $WX[] entries directly in any wx....php page that is based on a copy of wxnewpage.php.

Use http://www.nowaitweather.com/WCTtags.php?sce=dump to see all the $WX[] values available for use.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

nowait

  • Strong Breeze
  • ***
  • Posts: 110
  • Station Details: Davis Vantage Pro 2 Wireless (Heated) on a Snow Leopard Mac Mini
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #16 on: August 21, 2012, 12:36:53 PM »
My rough test page is http://nowaiitweather.com/wxnewpage_test.php

<div id="main-copy">


  <?php
   
   include_once($SITE['WXtags']);
      
    echo($WX['STAT:TEMPERATURE:CURRENT']);
    echo($WX['STAT:WINDCHILL:CURRENT']);
    echo($WX['STAT:HEATINDEX:24HRSAGO']);
    echo($WX['STAT:EXTHUMIDITY:DELTA24']);
    echo($WX['STAT:WINDCHILL:MIN:ALLTIME']);
    echo($WX['STAT:WINDCHILL:MIN:ALLTIME:TIME']);

  ?>
 
 
   <h1><?php langtrans('Sample Blank Page'); ?></h1>
   
    <p>This is a sample page</p>

    <p>Copy it to a new name and use as the base for a new page on your site.</p>
 
   <?php
    echo($WX['STAT:TEMPERATURE:CURRENT']);
    echo($WX['STAT:WINDCHILL:CURRENT']);
    echo($WX['STAT:HEATINDEX:24HRSAGO']);
    echo($WX['STAT:EXTHUMIDITY:CURRENT']);
    echo($WX['STAT:WINDCHILL:MIN:ALLTIME']);
    echo($WX['STAT:WINDCHILL:MIN:ALLTIME:TIME']);

  ?>     
   
</div><!-- end main-copy -->

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #17 on: August 21, 2012, 05:44:03 PM »
That's the right idea and it is working.. just not printing out in a way to allow you to diagnose what might be having a problem.

I used a modification of your code
Code: [Select]
  <?php
   
   
include_once($SITE['WXtags']);
      
    echo 
"Current Temperature: ".$WX['STAT:TEMPERATURE:CURRENT']."<br/>\n";
    echo 
"Current WindChill: ".$WX['STAT:WINDCHILL:CURRENT']."<br/>\n";
    echo 
"Current HeatIndex: ".$WX['STAT:HEATINDEX:24HRSAGO']."<br/>\n";
    echo 
"EXTHUMIDITY:DELTA24: ".$WX['STAT:EXTHUMIDITY:DELTA24']."<br/>\n";
    echo 
"WINDCHILL:MIN:ALLTIME: ".$WX['STAT:WINDCHILL:MIN:ALLTIME']."<br/>\n";
    echo 
"WINDCHILL:MIN:ALLTIME:TIME: ".$WX['STAT:WINDCHILL:MIN:ALLTIME:TIME']."<br/>\n";

  
?>
 
which shows each variable (labeled on a separate line) and got this output
Quote
Current Temperature: 62.9
Current WindChill: 62.9
Current HeatIndex: 64.5
EXTHUMIDITY:DELTA24: 10

Notice: Undefined index: STAT:WINDCHILL:MIN:ALLTIME in /homepages/9/d141952417/htdocs/wx/wxtemplates/Test/wxnowaitwx.php on line 63
WINDCHILL:MIN:ALLTIME:

Notice: Undefined index: STAT:WINDCHILL:MIN:ALLTIME:TIME in /homepages/9/d141952417/htdocs/wx/wxtemplates/Test/wxnowaitwx.php on line 64
WINDCHILL:MIN:ALLTIME:TIME:

I got the two Notice error messages because in my test setup, I have the error_reporting() set for everything.

So the issue is that two values are not present in my WCTtags.php so they cause the Notice: Undefined index messages (and therefore print nothing because there is no value for them).

When you do a http://www.nowaitweather.com/WCTtags.php?sce=dump , you can use any of the $WX['...'] names in your own page .. picking one that is not listed will not work :)

Best regards,
Ken

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

nowait

  • Strong Breeze
  • ***
  • Posts: 110
  • Station Details: Davis Vantage Pro 2 Wireless (Heated) on a Snow Leopard Mac Mini
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #18 on: August 21, 2012, 05:53:58 PM »
That makes sense to not print anything is it doesn't exist.
In Reply #13 of this thread, I must have missed something when you were helping me add variables (link windchill and heatindex of all time) to the list of variables...

I'll have to go back through the steps and check again.



nowait

  • Strong Breeze
  • ***
  • Posts: 110
  • Station Details: Davis Vantage Pro 2 Wireless (Heated) on a Snow Leopard Mac Mini
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #19 on: August 22, 2012, 12:38:37 AM »
Yep.  Wrong WCTtags.php file on my weather cat server.  It works much better when the server updates the correct file and uploads it to the website.  Now the "new" values I added to the WCTtags.php are available!

Is there a function that will parse the date and time out of this?
WINDCHILL:MIN:ALLTIME:TIME: "2010-12-11T22:09:00" to "2010 DEC 11 at 22:09:00"?

See http://nowaitweather.com/wxnewpage_test.php

Thanks for all your help.  I'm learning a lot!

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #20 on: August 22, 2012, 06:23:04 AM »

For a time format like that ( "2010-12-11T22:09:00" ), you can use strtotime() to get it into a time format useable by date()
to create 2010 DEC 11 at 22:09:00
For your specific one, something like
Code: [Select]
<?php
$utime 
strtotime($WX['WINDCHILL:MIN:ALLTIME:TIME']);
$pdate date("Y M d",$utime) . ' at ' date("H:i:s",$utime);
echo 
$pdate;
?>

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

nowait

  • Strong Breeze
  • ***
  • Posts: 110
  • Station Details: Davis Vantage Pro 2 Wireless (Heated) on a Snow Leopard Mac Mini
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #21 on: August 22, 2012, 12:25:08 PM »
That helps but the time converted looks like the beginning of computer time (epoc)...

1969 Dec 31 at 18:00:00

http://nowaitweather.com/wxstationrecords.php

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #22 on: August 25, 2012, 11:08:54 PM »
Looks like you fixed it
http://nowaitweather.com/wxstationrecords.php
is now showing valid date/times
Quote
Lowest Recorded Wind Chill: -27.4 on 2010 Dec 11 at 21:09:00

Highest Recorded Heat Index: 118.9 on 2011 Aug 01 at 15:09:00

The 'yyyy-mm-ddThh:mm:ss' format (ISO) is one that should be processed correctly by PHP strtotime() function.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

nowait

  • Strong Breeze
  • ***
  • Posts: 110
  • Station Details: Davis Vantage Pro 2 Wireless (Heated) on a Snow Leopard Mac Mini
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #23 on: August 27, 2012, 01:21:40 AM »
Yes its correct now.  I needed to add "STAT" to the variable name in your example.

Thanks for all your help.  Slowly but surely, I'm getting things figured out!

jf-i2r

  • Strong Breeze
  • ***
  • Posts: 136
    • IPOITOUC29
    • La Noue Beach
  • Station Details: vantage pro2 wireless with solar sensor ; weather envoy + weatherlink-ip ;mac mini 1,6ghz 2go ram snow leopard
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #24 on: March 29, 2013, 10:04:07 AM »
hi

for information :
all datas uploaded from weathercat are in : /meteo-jf2/
all files for Saratoga Templates are on http://www.jf-i2r.com/meteo-jf2/saratoga/

i need your help :

 why " NaN " for some datas :





http://www.jf-i2r.com/meteo-jf2/saratoga/wxindex.php

i send you my WCTags.php and WCT_realtime.txt from my server

thanks
jean frederic

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #25 on: March 29, 2013, 04:29:23 PM »
Hi Jean,

The problem is with the data in /meteo-jf2/WCT_realtime.txt

29/03/13|17:19:20|11,7|92|10,4|6|5|237|0,0|4,8|1000,4|OSO|-|Knots|&#176;C|mb|mm|111,47|

The numbers inside must use a period as the decimal point and not the European convention of using a comma as a decimal point.  The JavaScript
is unable to process the numbers with commas as decimal points and so show NaN (meaning Not a Number) instead.  Have WeatherCat emit the WCT_realtime.txt file using periods as decimal point and the AJAX script should work properly.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

jf-i2r

  • Strong Breeze
  • ***
  • Posts: 136
    • IPOITOUC29
    • La Noue Beach
  • Station Details: vantage pro2 wireless with solar sensor ; weather envoy + weatherlink-ip ;mac mini 1,6ghz 2go ram snow leopard
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #26 on: March 29, 2013, 05:01:08 PM »
thanks Ken

is it possible to me to setup weathercat to use periods as d├ęcimal ?

or Stu can do it ?

cheers

jean frederic

WCDev

  • WeatherCat Developer
  • Global Moderator
  • Storm
  • *****
  • Posts: 2735
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #27 on: March 29, 2013, 08:02:04 PM »
Unfortunately there's no quick fix for this one as the decimal separator is provided by the OS (from settings made in the Language & Text System Preferences). It'll probably need a tag to override the OS settings to turn it off for that particular file whilst it's being processed.

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 114
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #28 on: March 29, 2013, 10:04:08 PM »
I think I found a quick fix for you to try...

Change ajaxWCTwx.js code
Code: [Select]
    var realtime = x.responseText.split('|');
to
Code: [Select]
var rttext = x.responseText;
if(decimalComma) {
rttext = rttext.replace(/(\d)\,(\d)/g,"$1.$2");
}
    var realtime = rttext.split('|');

That should find all the numbers with comma decimal points and replace the comma with a period so normal math can be done by JavaScript.

The script already had a mechanism to convert from decimal points to comma decimals built-in, just not a mechanism to do the reverse.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

jf-i2r

  • Strong Breeze
  • ***
  • Posts: 136
    • IPOITOUC29
    • La Noue Beach
  • Station Details: vantage pro2 wireless with solar sensor ; weather envoy + weatherlink-ip ;mac mini 1,6ghz 2go ram snow leopard
Re: New Saratoga AJAX/PHP template plugin for WeatherCat now available
« Reply #29 on: March 30, 2013, 09:30:15 AM »
Hi

i setup that in ajaxWCTwx.js

Quote
var decimalComma = true;    // =false for '.' as decimal point, =true for ',' (comma) as decimal point

and it's seem ok http://www.jf-i2r.com/meteo-jf2/saratoga/index.php

****  but i've another problem with date and update , Saratoga template don't find the WCT_realtime.txt i think ; have you an idea?  i'm lost

in http://www.jf-i2r.com/meteo-jf2/saratoga/wxstatus.php 

Quote
WeatherCat weather data   NOT Current   379070:25:12    > 0:05:15
01/01/1970 01:00




can you verify my ajaxWCTwx.js  and settings files ?   


all datas uploaded from weathercat are in : /meteo-jf2/
all files for Saratoga Templates are on http://www.jf-i2r.com/meteo-jf2/saratoga/

http://www.jf-i2r.com/meteo-jf2/saratoga/index.php








thanks
jean frederic