WXforum.net
May 26, 2013, 03:22:53 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
Members: 6623  •  Posts: 178939  •  Topics: 18156
Please welcome Porchpup, our newest member.
Welcome to the the new hosting for WXforum.net.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: VWS + AJAX (+webdrive) = dynamic page updates  (Read 10805 times)
0 Members and 1 Guest are viewing this topic.
saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« on: December 06, 2006, 01:16:09 AM »

Chris and I have finished the development of an AJAX demo for dynamic updates of VWS sites using the data.csv function.  Please note that to implement, you'll need a separate FTP application to upload the data.csv file from VWS at 5 second (or so) intervals.

Many thanks to Chris for inspiring the project, and for doing a lot of collaborative testing/developing with it.

His home page at http://www.capeweather.com/ is using this capability.

The docs/scripts are available (free) at http://saratoga-weather.org/scripts-VWS-AJAX.php

Good luck with your VWS/AJAX implementations!

Best regards,
Ken
Logged

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

Posts: 1349



WWW
« Reply #1 on: December 06, 2006, 01:30:22 AM »

WOW, you guys are something else! Great job.

Someday I hope to incorporate some of the features you have developed but first I need to get my hands around Weather Display and the basics of the package.

So much to learn...
Logged

Don - W3DRM - Minden, Nevada --- Davis Wireless VP2, VWS 14.00 p101,
StartWatch, VirtualVP, VPLive, WL 5.9.3, Win7 Ultimate-SP1
--- Logitech QuickCam Fusion webcam
kray1000
Purveyor of wry
Forecaster
*****
Offline Offline

Posts: 1308



WWW
« Reply #2 on: December 06, 2006, 04:26:07 AM »

Quote from: "kenmtrue"
His home page at http://www.capeweather.com/ is using this capability.


Looks good Chris!
Logged

Kevin Ray
Roanoke, VA

Wireless VP2, Stardot NetCam, ImageSalsa 2.0.12, MovieSalsa, Nexstorm, WASP2, Skymet, VWS14.01p33, WD 10.37N build 03
CNYWeather
Forecaster
*****
Offline Offline

Posts: 1388



WWW
« Reply #3 on: December 06, 2006, 07:39:55 AM »

Quote from: "W3DRM"

Someday I hope to incorporate some of the features you have developed but first I need to get my hands around Weather Display and the basics of the package.


It's not as hard as you think.

I was quite frustrated in the beginning. BUT, I'm quite
pleased with the result. Plus any questions, the guys at
the WD Forums are a wealth of information.

Tony
Logged

W3DRM
Forecaster
*****
Offline Offline

Posts: 1349



WWW
« Reply #4 on: December 06, 2006, 12:00:34 PM »

Quote from: "CNYWeather"
Quote from: "W3DRM"

Someday I hope to incorporate some of the features you have developed but first I need to get my hands around Weather Display and the basics of the package.


It's not as hard as you think.

I was quite frustrated in the beginning. BUT, I'm quite
pleased with the result. Plus any questions, the guys at
the WD Forums are a wealth of information.

Tony


Thanks Tony - yes, I have been doing a lot of reading on the WD forum. I have never seen such an active bunch over there. Just testing the WD waters at the moment but hope to get something going soon. I've already purchased WD and will probably get WDL also after the first of the year.

My biggest problem, besides learning the basics of WD, is trying to keep up with all of the changes you guys throw into the mix on an almost daily basis. Talk about a moving  target... Laughing
Logged

Don - W3DRM - Minden, Nevada --- Davis Wireless VP2, VWS 14.00 p101,
StartWatch, VirtualVP, VPLive, WL 5.9.3, Win7 Ultimate-SP1
--- Logitech QuickCam Fusion webcam
saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« Reply #5 on: December 06, 2006, 12:26:24 PM »

I too fell under the spell of Brian's Weather-Display earlier this year.  It is a weather package chock full of features, which also has a lot of setup screens to pick/choose exactly how you want something done.

What sold me on it is the incredible support provided by Brian (and a hearty band of contributors) on the weather-watch.com forum.  I just looked this morning and here are Brian's stats:

Posts:     32,421 (19.878 per day)
Date Registered:    18 June 2002, 23:11:08

When have you EVER seen a developer that continuously involved with their creation?

Yes, it is a bit daunting to set up/configure and keep updated, but worth the effort!

I've also purchased the WD-Live and MesoMap-Live WD add-ons too.

What a great hobby with all the shiny toys!   Laughing
Logged

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

Posts: 445



WWW
« Reply #6 on: December 06, 2006, 02:26:59 PM »

Quote from: "kray1000"
Quote from: "kenmtrue"
His home page at http://www.capeweather.com/ is using this capability.


Looks good Chris!


Man, I gotta say I think Chris's site is one of the best.  Its like somebody from Yahoo or ESPN set it up....geez its great!

P.S.  Chris, I think your forecast icon set is missing nshra40.jpg:

http://www.capeweather.com/forecast/images/nshra40.jpg
Logged

South of the Tracks, Anchorage, KY
capeweather
Administrator
Forecaster
*****
Offline Offline

Posts: 921



WWW
« Reply #7 on: December 06, 2006, 03:08:11 PM »

Quote from: "anchorageweather"
Quote from: "kray1000"
Quote from: "kenmtrue"
His home page at http://www.capeweather.com/ is using this capability.


Looks good Chris!


Man, I gotta say I think Chris's site is one of the best.  Its like somebody from Yahoo or ESPN set it up....geez its great!

P.S.  Chris, I think your forecast icon set is missing nshra40.jpg:

http://www.capeweather.com/forecast/images/nshra40.jpg


Hey! Thanks a lot guys!  Embarassed  Embarassed I really appreciate those comments. A lot of the credit has to be given to the folks on this forum and some other outside sources. Thanks again.  Very Happy

PS. I appreciate you pointing out that icon and it has been fixed. Every once in a while one will sneak through and you caught it.  Many thanks for that too!  Very Happy
Logged


Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net
weatheroz
Contributor
***
Offline Offline

Posts: 133


WWW
« Reply #8 on: December 07, 2006, 02:19:30 AM »

Quote from: "CNYWeather"
Quote from: "W3DRM"

Someday I hope to incorporate some of the features you have developed but first I need to get my hands around Weather Display and the basics of the package.


It's not as hard as you think.

I was quite frustrated in the beginning. BUT, I'm quite
pleased with the result. Plus any questions, the guys at
the WD Forums are a wealth of information.


Well I was so frustrated with WD in the beginning, I just gave up and stuck with vws for another 12 months before I got so thoroughly fed up with vws, I took another look and stuck with it this time and haven't really looked back.

The support forum is full of people wanting to help you out regardless of what software you were running, and the software author that goes out of his way to help not only his paying customers, but those who are just looking, which is poles apart from what I was previously used to.

So stick with it, you will be glad that you did.  Smile
Logged

weathergirl
Forecaster
*****
Offline Offline

Posts: 498



WWW
« Reply #9 on: December 07, 2006, 07:03:42 PM »

A big thank-you to Ken and Chris for helping me to implement the
VWS-AJAX script on my site Smile You guys rock!
Logged

Ann-Marie
Beamsville, Ontario, Canada
saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« Reply #10 on: December 07, 2006, 07:36:21 PM »

You're very welcome!!  It was great learning how to get the metric units working with VWS (data2.csv).

Your site looks great (as always Smile )
http://www.beamsvillewx.ca/  (main page)
http://www.beamsvillewx.ca/today/current.php  (current conditions)

Both pages are AJAXed.

Best regards,
Ken
Logged

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

Posts: 921



WWW
« Reply #11 on: December 07, 2006, 07:38:09 PM »

Looks JAXed up to me!  Laughing Well done and it looks great!  Dancing
Logged


Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net
katlon
LONNIE'S WEATHER STATION
Contributor
***
Offline Offline

Posts: 129


GO HEELS!!!


WWW
« Reply #12 on: December 09, 2006, 08:43:54 AM »

Thanks Ken & Chris. I played around with the VWS + AJAX program and got it going. I have been using 3DFTP for quite sometime and am going to watch that program for awhile to see how it handles the 5 sec updates before I tinker with tweaking the page looks. I couldn't see spending the dollars for Webdrive when I already have one that has been good.

http://pulliamjr.com/PDA2.htm

Lonnie
Logged
CNYWeather
Forecaster
*****
Offline Offline

Posts: 1388



WWW
« Reply #13 on: December 09, 2006, 09:47:29 AM »

Good Job Lonnie!
Logged

FourOhFour
Member
*
Offline Offline

Posts: 15


WWW
« Reply #14 on: December 12, 2006, 08:26:22 PM »

Thank you!

I changed the green flash so instead of editing each <span>'s style, it adds/removes an 'ajaxhighlight' class. That way the highlight color is set in my stylesheet. (Also, the highlight can be anything you can do in CSS... background color, pattern, underline, italic, whatever. Even blink, but I'd have to remove your eyes with a rusty grapefruit spoon if you did that.)

To make the above work, I also fixed it so that it'll still work if any of your <span>s have multiple classes. (For example, <span class="ajax temperature"> is a member of the 'ajax' class and the 'temperature' class. The script wouldn't be able to find these spans before.)

This also allows you to not have the highlight appear on a printed copy if you so choose. (use @media screen { .ajaxhighlight { ... } } in your stylesheet)


I'm not really a JavaScript guy. It's quite possible the changes break IE, Netscape, or your cat. If it breaks, you get the pieces. Do not taunt happy fun ball.


If you want to see the modified script, it lives at http://skigod.us/ajaxvws.js and, of course, you can view the output at http://skigod.us

This copy also has the cache busting removed and the delay between fetches increased. You may want to put those back if you use it.
Logged
saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« Reply #15 on: December 12, 2006, 08:36:03 PM »

You're very welcome, and THANK YOU for adding function to the script.  That's what makes this whole thing so rewarding.. improvements from other weather enthusiasts like you.  I'll be incorporating your techniques too.

Thanks and best regards,
Ken
Logged

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

Posts: 15


WWW
« Reply #16 on: December 13, 2006, 10:18:23 AM »

Now that I have a little more time, thought I'd mention why I removed the cache busting code...

Short version: I prefer setting the server to properly send cache headers so caches will work properly instead of just bypassing them completely.

Long version:

My data.csv is only updated once a minute because I was too lazy/cheap to get a FTP client set up that could upload it more often. Now, I could set the javascript to load it once a minute, but then the data shown would be up to 2 minutes old... (last download was a minute ago, and the data was 59 seconds old at the time)

So I set it to download every 20 seconds. But then bandwidth is wasted downloading a file that hasn't changed.

Now, I suppose the best way to fix it would be to change the javascript to use the modification date of the downloaded data.csv file to figure out how long to wait. But I haven't done that yet.

Instead, I set the server to send an Expires header for data.csv saying that it expires 1 minute after it was modified. In my .htaccess:
Code:

ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/html "modification plus 10 minutes"
ExpiresByType text/plain "modification plus 1 minute"


With that set up on the server, and the javascript's cache busting removed, I can set the javascript to fetch every 10 seconds without wastefully re-downloading unchanged data. (Most browsers will pull the file out of the cache and give it to the script; and I believe Opera will give the script a 304 Not Modified code. Either works for this purpose.)


Now, if you remove the cache busting code without adding some form of cache control headers from the server, your page probably will not work as intended. In that case, browsers will try to figure out a good length of time to cache the file on their own. Some will probably check the file for changes often, others won't.
Logged
FourOhFour
Member
*
Offline Offline

Posts: 15


WWW
« Reply #17 on: December 13, 2006, 05:27:16 PM »

Yes, me again. In the pursuit of saving tiny bits of bandwidth, I've added a feature to poll less often when the window is in the background. After all, if nobody is looking at it, do you really need to update every few seconds? Also moved the poll times to settings at the top, so you can season to taste without digging through the increasingly long script.

Second, I added an option to stick the temperature in the window title. This should show up nicely in a Windows taskbar. (I say should since I don't use Windows...)

Third, replaced about eleventy billion instances of x.responseText.split(',') with a variable. No sense splitting the response over and over.
Logged
capeweather
Administrator
Forecaster
*****
Offline Offline

Posts: 921



WWW
« Reply #18 on: December 13, 2006, 05:46:16 PM »

Quote from: "FourOhFour"
After all, if nobody is looking at it, do you really need to update every few seconds?


Thats the thing. I know people are looking at it because I've already received great feedback on it because of the quicker updates compared to the static values before. I find it much more interesting seeing something change at a 5 second rate than 1 minute much less a static value. It's definitely already a hit on my site.  Very Happy
Logged


Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net
FourOhFour
Member
*
Offline Offline

Posts: 15


WWW
« Reply #19 on: December 13, 2006, 06:26:54 PM »

Quote from: "capeweather"
Quote from: "FourOhFour"
After all, if nobody is looking at it, do you really need to update every few seconds?


Thats the thing. I know people are looking at it because I've already received great feedback on it because of the quicker updates compared to the static values before. I find it much more interesting seeing something change at a 5 second rate than 1 minute much less a static value. It's definitely already a hit on my site.  Very Happy
Yes, but if the window has lost the focus, that means the user has some other window in front. Chances are good that the window isn't being watched. Not 100%, of course, since it could be a window on one side of the screen while the user is doing something else in a window on the other.

I'd love to be able to check to see if the window is minimized or if the window is a background tab. In both of those cases, there is no chance someone is watching it. That'd work much better than just window focus.

Anyway, the feature isn't for everyone, and setting both polltime_focus and polltime_blur to the same number will turn it off.
Logged
xmas1313
Member
*
Offline Offline

Posts: 39



WWW
« Reply #20 on: July 05, 2007, 01:54:30 PM »

First of all, thanks to everyone who has worked on the AJAX stuff...it is awesome.

I'm not sure if this will be of help to anyone, but I've written a small PERL script which will ftp the data.csv file (actually data_hold.csv) from VPLive roughly once every 5 seconds.  In it is a line of code which first copies the data.csv file into a "hold" file, and this seems to cut down on periodic access violations between the PERL script and VPLive (these violations don't cause anything to crash, just show up in the error log and as delayed data updates).

I call this script once a minute from the Windows task scheduler.  There are 2 ways to keep multiple instances from running- a 59 second time out in the script and a 2 minute limit on running the script from the scheduler.

I haven't figured out how to get this to running totally in the background (like in the tray), but I am referencing a link (shortcut) to the script so that it can be minimized upon running.

This script should help those who have don't have VWS (or comparable software), but do have VPLive which creates its own raw data file.

Here is the script...

Code:

use File::Copy;
use Net::FTP;

$hostname = "your_ftp_destination.com";
$username = "your_username";
$password = "your_password";
$home = "your_ftp_destination_directory";

$ftp = Net::FTP->new($hostname,Timeout=>59);
$ftp->login($username, $password);
$ftp->cwd($home);
$ftp->ascii;

for ($x = 1; $x <= 12; $x++) {
  copy("c:/Progra~1/VPLive/data.csv", "c:/Progra~1/VPLive/data_hold.csv");
  $ftp->put("C:/Progra~1/VPLive/data_hold.csv");
  sleep 4;
}

$ftp->quit;


Hope this helps,

Scott
www.arlingtonweather.net
Logged

saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« Reply #21 on: July 06, 2007, 07:05:09 PM »

Thanks Scott!  What a great idea to use Steve's (tinplate) VPLive freeware program as the source of the data.  Changes to the JavaScript to parse the values should be easy to do.

I know that Matt at WeatherBus.com has worked out an AJAX script that uses the VWS WeatherFlash upload file as it's data source.  I'm working with Matt to make that available as a VWS alternative to data.csv Smile

Best regards,
Ken
Logged

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

Posts: 576



WWW
« Reply #22 on: July 06, 2007, 10:22:28 PM »

You think you could put me in the loop on this? This would be a good way to give equivalent clientraw functions for vws in  the graphics script.
Logged

saratogaWX
Administrator
Forecaster
*****
Offline Offline

Posts: 3752


Saratoga, CA, USA Weather - free PHP scripts


WWW
« Reply #23 on: July 07, 2007, 12:13:48 AM »

Sure!  It's a great idea to have it drive the weather graphic too.

Ken
Logged

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.154 seconds with 19 queries.
anything