Author Topic: Released: PHP/AJAX multilingual website templates for Cumulus, VWS, WD, WL  (Read 46868 times)

0 Members and 1 Guest are viewing this topic.

Offline ext3

  • Member
  • *
  • Posts: 12
Any advice of how to fix the javascript and gizmo would be valuable.I am reading the code,but missing some ajax basics,so i don't understand how the ajax updates the values,but i will find it.
One more addition/code change i have thought has to do with update times.When an ajax update occurred,the counter said updated 1,2 or 100 seconds before.The problem is that this counter doesn't count the update time with values based on realtime or weather data timestamp.So if my weather station,stops uploading data for an hour or a day,because of internet problem for example,the counter every time i visit the page said las updated timestamp,next update timestamp,updated x seconds before.
I think thats not correct,and the counter should first check if weather data or realtime is updated(done in status page),and then if it is updated should report updated x seconds ago,if not should report with red coloured flashing letters(LOL) Warning:Weather data not updated,last update occurred timestamp.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Debugging JavaScript can be a real pain because ALL the JavaScript stops executing when an error is encountered, so you have to be very careful with syntax, and use a good debugger plugin (like FireBug for Firefox browser).

So, you'd said previously you wanted to change the dashboard to use the UV icon .. now it's the gizmo instead?  The same caution applies, and even more so in the ajax-gizmo as little vertical space is available in the gizmo area for an icon .. only images of about 12px high could be used there.

Display and update of a page in the viewer's browser is a two-step process (with the second step depending on the viewer's browser allowing JavaScript to run from your website):

Step 1:  the webserver loads and executes all the PHP code in the page, and the resulting PHP print/echo statements (if any) replace all the <?php ... ?> areas you can see on the page.  The fully executed page is returned to the viewer's browser as pure HTML and text.
Step 2: (if viewer's browser has JavaScript enabled) the AJAX scripts are loaded by the viewer's browser, and executed in the viewer's browser.  The script will replace the contents of the displayed HTML page for sections with markup like
<span class="ajax" id="ajax...."> ... </span> with computed contents from your realtime file.  The JavaScript only replaces the marked-up sections in the display on the browser.. not the 'real' page from the server.   Updates this way will continue until either a specified number of updates occur, or a fatal JavaScript error is encountered.

Since a lot of folks have JavaScript turned off when they first visit a site, it's important to present the current page fully rendered by the PHP code.  Then you can add 'spice' by having JavaScript update the contents of the displayed page based on more current data from a realtime file.

The JavaScript counter is enabled for display on the page if JavaScript is allowed by the browser.  The counter will automatically reset when a newer realtime file is successfully loaded and displayed.  If the AJAX script has an update limit, then the counter will not be reset after the last update was displayed.

If you visit the page (by doing a reload, not just looking at the old page in your browser), it will use a 'current' PHP image, load the AJAX script and start the update process.

Keep in mind that what you see on the status page is produced only by the webserver using PHP at the time the page is first loaded into the browser .. it is NOT updated by any of the AJAX JavaScripts.  The AJAX JavaScripts only run in the browser so can only process the data they can see (the realtime file).

Hope this helps ... many folks find that learning PHP and JavaScript is at least half the fun of the weather enthusiast hobby, so I tend to encourage folks to use my scripts as a starting point for their own learning and enhancement of their personal weather website.  PHP tends to be easier to debug and add enhancements since PHP errors are clearly shown (so you can correct the code and move on).  JavaScript changes, especially to the AJAX routines are more challenging and harder to debug (given JavaScripts 'silent stop' method).  My recommendation is to try doing all of what you want by changing the PHP and HTML markup code first, get a good result, then moving on to the AJAX mods.  For UV display, I'm not sure that having a every-few-seconds update of UV index is meaningful, so having just the PHP version makes more sense to me -- AJAX updates are intended to make the page 'current' without refreshing the whole page. Not all the weather condition values are available in the realtime files, so it's a good idea to have folks reload the page at the same interval that the PHP conditions are updated (every 5 minutes).

Best regards,
Ken
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 ext3

  • Member
  • *
  • Posts: 12
Thanx a lot for your help.Reading a bit all scripts help me to understand the way that ajax sends data to gizmo and dashboard,so i think i have added all proper tags in all scripts,and adding also Solar radiation to gizmo.
So far all works ok,and modified a bit both css and dashboard i have no extra spaces.Thanx a lot again

Offline LeomaTNWX

  • Senior Contributor
  • ****
  • Posts: 271
    • Leoma, Tn Weather
I am just now getting around to getting my NOAA climate report page going. The page is up but when I click on a month or year it just redirects to the NOAA climate report page. also the status page is not showing the status current. How would I go about fixing this?

http://www.leomaweather.com/wxnoaaclimatereports.php

Thanks
Mark

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Hi Mark,
You seem to have three files with bogus dates in your NOAA reports directory:

1934.txt
1934-01.txt
1934-04.txt

All three files show correct format, but no data .. I'd suggest deleting them from the site then your index of the NOAA files will start at Feb 2009 (which does have data).  There is also a 2036.txt and 2036-02.txt file .. I think your VWS had a bit of confusion as 2036 is a long time ahead to have a NOAA report :)

The behavior you cited (click on a month or year it just redirects to the NOAA climate report page) is the correct one.  Clicking on one of the highlighted year or month links will reload the page with that data displayed.

Regarding the status report showing
Quote
Virtual Weather Station NOAA report    NOT Current    2808:44:45    > 0:05:15
Mon, 14-Feb-2011 11:00am CST
, make sure the file you check for currency is ./noaa/noaamo.txt

Best regards,
Ken
« Last Edit: June 11, 2011, 01:47:07 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 LeomaTNWX

  • Senior Contributor
  • ****
  • Posts: 271
    • Leoma, Tn Weather
Thanks Ken! Removing the files fixed it.  Is there some way to adjust the time so it will show current longer. I am updating it every 3 min but sometimes the file has not changed so it shows not current even if it is.
« Last Edit: June 11, 2011, 06:24:44 PM by LeomaTNWX »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Ahh... the status report problem is due to an omission on my part.

In wxstatus.php change
Code: [Select]
if($SITE['WXsoftware'] == 'VWS' and file_exists('noaamo.txt')) {
     do_check($SITE['WXsoftwareLongName']." ".langtransstr("NOAA report"),'noaamo.txt',60*5+15,'file');
}
to
Code: [Select]
if($SITE['WXsoftware'] == 'VWS' and file_exists($SITE['NOAAdir'] . 'noaamo.txt')) {
     do_check($SITE['WXsoftwareLongName']." ".langtransstr("NOAA report"),$SITE['NOAAdir'] . 'noaamo.txt',60*65+15,'file');
}
then it should find the noaamo.txt file you are updating.

Best regards,
Ken
« Last Edit: June 11, 2011, 07:19:42 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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
I've just done an update to fix a different issue for the WeatherLink folks in wxstatus.php and some Notice: errata in the NOAA reports.

I suggest you use http://saratoga-weather.org/wxtemplates/updates.php to get the changes.

Best regards,
Ken
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 LeomaTNWX

  • Senior Contributor
  • ****
  • Posts: 271
    • Leoma, Tn Weather
Thanks Ken! :grin:

Offline ext3

  • Member
  • *
  • Posts: 12
I have added all missing code to enable storm rain and uv index icon ajax updates,without modified the programming logic of Ken.Also i have added Solar Radiation to gizmo and also planning to add daily ET in both ajax and gizmo.All works ok so far,but might Ken want to look to it,i might loose something.
Any idea of how to pass webcam image update to ajax.Javascript does the work,but i think ajax is better.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
I did a separate script to fetch/display the webcam thumbnail, and another one on the webcam page to get the image processed by ImageSalsa.

Feel free to use those scripts if you like.. the JavaScript is available via a view-source on my pages.  I think that's much better than modifying the AJAX script (who's sole purpose is to fetch/parse realtime info and dynamically update the text conditions on the webpage).
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 warrenb

  • Member
  • *
  • Posts: 4
Hi there
New to all this but I have a problem with my NOAA reports. I have uploaded the WL NOAA reports to a directory called noaarep on my website so have the following
$SITE['graphImageDir']     = './';  // directory location for graph images with trailing /
$SITE['NOAAdir']           = './';   // relative location of the stored NOAA report files directory
$SITE['NOAACurDir']        = './noaarep/'; // relative location of the NOAAMO.TXT, NOAAYR.TXT, NOAAPRMO.TXT, NOAAPRYR.TXT files


The status page says my NOAA reports are current but when I click on NOAA reports it says there are no current NOAA reports.

Website is www.tonweather.org.uk

Thanks
Warren

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Hi there
New to all this but I have a problem with my NOAA reports. I have uploaded the WL NOAA reports to a directory called noaarep on my website so have the following
$SITE['graphImageDir']     = './';  // directory location for graph images with trailing /
$SITE['NOAAdir']           = './';   // relative location of the stored NOAA report files directory
$SITE['NOAACurDir']        = './noaarep/'; // relative location of the NOAAMO.TXT, NOAAYR.TXT, NOAAPRMO.TXT, NOAAPRYR.TXT files


The status page says my NOAA reports are current but when I click on NOAA reports it says there are no current NOAA reports.

Website is www.tonweather.org.uk

Thanks
Warren
Hi Warren,

I think you need to have the settings in Settings-weather.php be
Code: [Select]
$SITE['graphImageDir']     = './';  // directory location for graph images with trailing /
$SITE['NOAAdir']           = './noaarep/';   // relative location of the stored NOAA report files directory
$SITE['NOAACurDir']        = './noaarep/'; // relative location of the NOAAMO.TXT, NOAAYR.TXT, NOAAPRMO.TXT, NOAAPRYR.TXT files
so it can find the prior NOAA report files.

Best regards,
Ken
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 n3ouc

  • Contributor
  • ***
  • Posts: 123
    • Air Products Campus Weather
Hi All,
I need some help with adding metric conversions to my website. I have taken parts of Ken's Saratoga templates and the Webster Weather templates and incorporated a little of both into my VWS website. On the upper right of the ajax dashboard, I need to include metric conversions for our overseas personnel coming over to visit our Allentown headquarters. I have attempted to use some of the conversions elsewhere in this forum and failed miserably so I have defaulted to a weather underground sticky. I would really like to do the conversions using ajax on the dashboard so does anyone have any ideas on if this would be possible and what conversion formulas I could use?

Here is my website: http://macungieweather.net/a/index.php

Thank You
Mike
Air Products Campus Weather
Mike Stanton
Air Products Campus Weather

Offline n3ouc

  • Contributor
  • ***
  • Posts: 123
    • Air Products Campus Weather
Hi All,

(Update) 7/7/2011
After a looking at all the different options out there on this subject, i was able to work most of the conversions out. I changed and added to the VWS-def.php file to come with the following on my dashboard:
Wind In KPH:  SSW @ 0 KPH 
Max Gust Today:  25.7 KPH @  3:53pm 
Max Gust Month:  32.2 KPH on  Jul 4 
Temperature In C:  28.9 C 
Dewpoint In C:  21.2 C 
Humidity: 63 % 
Pressure In Millibars:  1011.8 MB 
Current Rain Rate:  0.34 MM/hr 
Daily Rainfall:  2.03 MM 
Month Rainfall:  4.32 MM 
Season Rainfall:  557.28 MM 


I have not been able to figure out how to make these update with ajax. I only receive updates via the VWStags.php file. Would someone be able to give me a pointer or two in getting these variables to update with ajax?

Thank You,
Mike
Air Products Campus Weather
Mike Stanton
Air Products Campus Weather

Offline blainec

  • Senior Member
  • **
  • Posts: 70
    • Weather YYC
I am seeing frequent errors on the page.
for example, I see this and similar errors

Notice: Undefined variable: forcasttemp in /home/wester54/public_html/nelsonbc/ajax-dashboard.php on line 960

Got any ideas?


Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
What page?  Where?  Can't help if we can't see.

Jay
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline blainec

  • Senior Member
  • **
  • Posts: 70
    • Weather YYC
oops, sorry, I forgot that little piece of info.

http://nelsonbc.westerncawx.com

Do a few page refreshs, you should see it pop up eventually

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
I'm not sure why it would happen sometimes and not others.  It took several refreshes to see the error.  Maybe Ken can take a look.

Sorry,

Jay
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
The issue is that ec-forecast only produces $forecasticons (etc) from the EC for 7 entries [0] to [6] and the code
Code: [Select]
       <table width="100%" border="1" cellpadding="2" cellspacing="3" style="border:solid; border-color: #CCCCCC;">
              <tr align="center">
        <td>
                      <?php echo $forecasticons[1]; ?><br/>
                      <?php echo $forcasttemp[1]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[2]; ?><br/>
                      <?php echo $forecasttemp[2]; ?>
                 </td>
<td>
                      <?php echo $forecasticons[3]; ?><br/>
                      <?php echo $forecasttemp[3]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[4]; ?><br/>
                      <?php echo $forecasttemp[4]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[5]; ?><br/>
                      <?php echo $forecasttemp[5]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[6]; ?><br/>
                      <?php echo $forecasttemp[6]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[7]; ?><br/>
                      <?php echo $forecasttemp[7]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[8]; ?><br/>
                      <?php echo $forecasttemp[8]; ?>
                 </td>
              </tr>  
           </table>
at the end of your ajax-dashboard is starting at [1] and going to [8]  .. entries [7] and [8] in the arrays are undefined, so cause the Notice: errors.

I suggest you change the code to read
Code: [Select]
       <table width="100%" border="1" cellpadding="2" cellspacing="3" style="border:solid; border-color: #CCCCCC;">
              <tr align="center">
        <td>
                      <?php echo $forecasticons[0]; ?><br/>
                      <?php echo $forecasttemp[0]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[1]; ?><br/>
                      <?php echo $forcasttemp[1]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[2]; ?><br/>
                      <?php echo $forecasttemp[2]; ?>
                 </td>
<td>
                      <?php echo $forecasticons[3]; ?><br/>
                      <?php echo $forecasttemp[3]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[4]; ?><br/>
                      <?php echo $forecasttemp[4]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[5]; ?><br/>
                      <?php echo $forecasttemp[5]; ?>
                 </td>
        <td>
                      <?php echo $forecasticons[6]; ?><br/>
                      <?php echo $forecasttemp[6]; ?>
                 </td>
              </tr>  
           </table>
and that should remove the Notice: errata.

Best regards,
Ken
« Last Edit: July 20, 2011, 01:14:46 AM 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 blainec

  • Senior Member
  • **
  • Posts: 70
    • Weather YYC
still having the issue

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Ahh... but they're slightly different issues:

Notice: Undefined variable: WXSIMtemp in /home/wester54/public_html/nelsonbc/ajax-dashboard.php on line 924

Since you don't have a plaintext.txt from WXSIM, the $WXSIMtemp[] array is not available.  I'd change that line to use $forecasttemp as the variable name.
Code: [Select]
<?php echo $forecasticons[0] . "<br />" $forecasttemp[0]; ?></strong>
Notice: Undefined variable: useVPfc in /home/wester54/public_html/nelsonbc/ajax-dashboard.php on line 931

that appears in
Code: [Select]
   if (($useVPfc) && ($vpforecasttext <> '')) {
      print '        <b>Local station forecast:</b> <span style="color: green; font-size: 9px">' . ucfirst($vpforecasttext) . "</span>";
}
.  I suggest you include a $useVPfc = true; (or =false;) in the settings area to show or not-show the VP forecast.

   
Notice: Undefined variable: WXSIMtemp in /home/wester54/public_html/nelsonbc/ajax-dashboard.php on line 936

Same as WXSIM suggestion above.. change line to
Code: [Select]
<?php echo $forecasticons[1] . "<br />" $forecasttemp[1]; ?></strong></td>
Notice: Undefined variable: forcasttemp in /home/wester54/public_html/nelsonbc/ajax-dashboard.php on line 964

This is just a missing 'e' in $forecasttemp .. change the code to
Code: [Select]
                      <?php echo $forecasttemp[1]; ?>

Hope this helps...
Best regards,
Ken

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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Released: PHP/AJAX multilingual website templates for Cumulus, VWS, WD, WL
« Reply #47 on: November 18, 2011, 12:34:52 PM »
Just a note to let you know that several updates to the templates are now available.

First, a new wxmetar.php page was added to the Base-* distributions .. this new page allows you to display the reports from your nearby METAR stations.  For Canada/World, the display is also multilingual.

Second, for Base-World distribution, an improved WU-forecast.php is available with multi-city forecast capability (like the same capability for Base-USA in the NOAA forecasts).

Third, the capability for right-to-left reading languages has been added to the Base-World template, and the Hebrew translations were provided by Eli of Sde Hemed Weather.  For this capability, a new Settings-language.php file was implemented to make it easier to update languages as they become available.

Updates for V3 templates are available from the updates page

Convert V2 WD/AJAX/PHP to V3 easily using the upgrade tool page.

You can keep informed of updates as they become available using the RSS feed and/or the SaratogaWXPHP Twitter feed.

Best regards,
Ken
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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Released: PHP/AJAX multilingual website templates for Cumulus, VWS, WD, WL
« Reply #48 on: November 21, 2011, 05:47:07 PM »
Another update 21-Nov-2011 to Base-* V3 websites.  The wxstatus.php page has been redesigned to accommodate any custom checks you'd like to do, and the stock weather software checks have been moved to a new include-wxstatus.php page .. this enables an easy update of include-wxstatus.php when new weather software is added to the templates, and not to disturb your custom checks in wxstatus.php

The update has the following changes:
1) fixed Weather-Display clientraw.txt test
2) fixed several Multi-lingual omissions
3) added stock checks for Cumulus, VWS and WeatherLink NOAA-style reports (Thanks to Beau for the suggestion)
4) added Weather-Display <Month><year>.htm monthly report check

Best regards,
Ken
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 jgillett

  • Forecaster
  • *****
  • Posts: 1187
  • Boltek, Win7 Pro, ToA
    • TiggrWeather Phoenix
Re: Released: PHP/AJAX multilingual website templates for Cumulus, VWS, WD, WL
« Reply #49 on: November 22, 2011, 11:47:57 AM »
Hi Ken,

Really like the new wxmetar page - http://tiggrweather.net/wxmetar.php - and the updated status page - http://tiggrweather.net/wxstatus.php.

However, I was having a problem with the status where all the Nexstorm items were not showing as current, even though the files were current on the server. Bottom line is I could find no reference anywhere in my site to a setting for nexstormDir. So, I added the following to Settings.php...

Code: [Select]
// Nexstorm directory setting
$SITE['nexstormDir'] = 'lightning/';

Works fine now. Just FYI.

As always - thank you for all your efforts. Most appreciated.
John
W7JKG

 

anything