WXforum.net

Web Weather => Weather Web Site Help => Topic started by: saratogaWX on November 23, 2006, 01:27:32 AM

Title: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 23, 2006, 01:27:32 AM
Recently, I added a 'green flash' feature to my AJAX/PHP pages that looks a bit like what WeatherUnderground shows for Rapid-Fire updates (text turns green when updated, then returns to base color after 2 seconds).  It's not quite smart enough to flash only the changed values yet, but I'm working on that too.  I've also reformatted the display to not require <noscript> around the PHP for the conditions (the AJAX replaces the values when it updates), so the page shows the same (except for time) with Javascript enabled or disabled in the browser.

I've updated the AJAX/WD scripts page at http://saratoga-weather.org/scripts-WD-AJAX.php and included a brief explanation of how it works and a sample set of files in the V1.01 .zip to play with.

It's based on my current-ajax.php that's used throughout my site to provide a current conditions sidebar.  My homepage was also updated with this AJAX code too.

It has rising/falling arrow graphics (both PHP and JavaScript) and wind direction arrows (both PHP and JavaScript), along with a decoder ring for UV conditions with the color code for the conditions displayed.

My special thanks again goes to pinto and carterlake for their pioneering work on AJAX and WD for current conditions displays -- without them, this sample set wouldn't have been possible.  Thanks also to beeker425 on the WD forum for a very succinct wind degrees converter JavaScript.

Please note that the samples are PHP-dependent .. to use AJAX with html-only sites, you'll need to use the templates provided by carterlake.

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: anchorageweather on November 23, 2006, 06:56:12 AM
That is very cool!  This AJAX script might finally force me to breakdown and get Weather-Display. :wink:

This is NOT a criticism mind you, but, Do you worry that until you finalize the script to turn only the changed value green, that some  new visitors might just think the info is "flashing"?

P.S. Got my quake page changed.  THANKS! for the update.  Your site is awesome!
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 23, 2006, 01:11:08 PM
It just occurred to me that maybe it would be easier for folks to incorporate 'green-flash' into their existing AJAX pages if I just said what needed to be changed on your existing page, so here's what you can do to add the 'green-flash' effect:

First, change all of the <span id="..."> tags used for AJAX substitution in your page (that you want to 'green-flash') to also have a name="ajax" tag so something like
Code: [Select]
<span id="ajaxtemp"> becomes
Code: [Select]
<span name="ajax" id="ajaxtemp">

Second, copy this
Code: [Select]
// --- added flash-green on data update functions from saratoga-weather.org

var ie4=document.all;

function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function set_ajax_color( usecolor ) {
    if (ie4) {
//     eval("document.all.content"+y).style.display="none";
      var elements = getElementsByName_iefix("span","ajax");
    } else {
      var elements = document.getElementsByName("ajax");
    }
 var numelements = elements.length;
//  alert("contract_all: content"+y+" numelements="+numelements);
 for (var index=0;index!=numelements;index++) {
         var element = elements[index];
element.style.color=usecolor;
      }
}


// --- end of flash-green functions
before the
Code: [Select]
// main AJAX routine .. load and format clientraw.txt
function ajaxLoader(url) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
  }
lines.


Then add these two lines
Code: [Select]

    set_ajax_color('#00CC00'); // change all the ajax text to green
    setTimeout("set_ajax_color('')",2000); // change text back to default color after 2 secs
 
just above the
Code: [Select]

    setTimeout("ajaxLoader('clientraw.txt?'+new Date())", 5000); // get new data after 5 secs
  }
} // end ajaxLoader function


Then your existing template should work with 'green flash'.

And yes, it is a bit cheesey to have it ALL flash green.. not quite as bad and annoying as the dreaded <blink> tag  :lol:  -- it will be a major refit to remember prior values and flash only when a change is spotted.. I'll work on that over the next week.   Meanwhile, you can green-flash only the tags you desire by adding the name="ajax" tag inside the <span> for the AJAX substitution.

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: CNYWeather on November 23, 2006, 03:20:35 PM
Thanks to Ken's help, here an example for you to see:


http://www.cnyweather.com


This AJAX stuff is really neat. Been a long time fanboy of
FrontPage, but with this setup, all you need to upload if you're
using WD is wx30.html and clientraw. No more need to upload
every page.

 :D
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: weatheroz on November 23, 2006, 09:28:22 PM
Quote from: "kenmtrue"
It just occurred to me that maybe it would be easier for folks to incorporate 'green-flash' into their existing AJAX pages if I just said what needed to be changed on your existing page, so here's what you can do to add the 'green-flash' effect:


Just tried to upgrade it and noticed that in Internet Exploder that it comes up with an error when I fiddle with the temp section of it.

Here's what I've changed :-
Code: [Select]

temp = x.responseText.split(' ')[4];
document.getElementById("ajaxtemp").innerHTML =  temp;
templast = x.responseText.split(' ')[90];
document.getElementById("ajaxtemparrow").innerHTML =
  genarrow(temp, templast, '',
'Warmer %s&deg;C than last hour.',
'Colder %s&deg;C than last hour.');


However if I keep your conversion stuff in there, but change slight to this then it does not come up with the error :-
Code: [Select]

temp = (1 * x.responseText.split(' ')[4]) + 0;
document.getElementById("ajaxtemp").innerHTML =  temp;
templast = (1 * x.responseText.split(' ')[90]) + 0;
document.getElementById("ajaxtemparrow").innerHTML =
  genarrow(temp, templast, '',
'Warmer %s&deg;C than last hour.',
'Colder %s&deg;C than last hour.');


But this 'claytons' conversion seems pretty stupid. :)
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 24, 2006, 12:24:00 AM
That is strange, OZ.  I've tried the ajax-testpage.php (and my site homepage/ pages with sidebar) using IE6-SP2, IE7, Firefox 2.0, Opera 8, and Netscape 7.1 with no errors indicated.

Which version of IE are you running?  What is the specific error message you get with the original code?

I don't know why adding a (1 * x.responseText.split(' ')[4]) + 0; would make a difference (maybe in treating it as math instead of characters?)

Puzzled,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: weatheroz on November 24, 2006, 01:30:26 AM
Quote from: "kenmtrue"
That is strange, OZ.  I've tried the ajax-testpage.php (and my site homepage/ pages with sidebar) using IE6-SP2, IE7, Firefox 2.0, Opera 8, and Netscape 7.1 with no errors indicated.

Which version of IE are you running?  What is the specific error message you get with the original code?

I don't know why adding a (1 * x.responseText.split(' ')[4]) + 0; would make a difference (maybe in treating it as math instead of characters?)

Puzzled,


And you know what is more puzzling is now it is not coming up with any errors !!! .... got me stuffed what's going on there.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 25, 2006, 03:15:48 PM
I've updated the sample instructions and sample file set for AJAX 'green-flash' for changed conditions only at http://saratoga-weather.org/scripts-WD-AJAX.php and added a section there on how to update your current AJAX template set to use the new green-flash code.

The bulk of the mod is to use a small function to update the page (instead of changing innerHTML directly).  The function (set_ajax_obs) will retrieve the prior value, set the new value and change the color if prior != current.  The prior value is stored as an attribute in the span tag as 'lastobs="value"' by the JavaScript setAttribute function.

Here's the revised instructions for how to fit 'green-flash-on-change' into your WD AJAX page:


First, change all of the <span id="..."> tags used for AJAX substitution in your page (that you want to 'green-flash') to also have a name="ajax" tag so something like
Code: [Select]
<span id="ajaxtemp"> becomes
Code: [Select]
<span name="ajax" id="ajaxtemp">

Second, copy this
Code: [Select]
// --- added flash-green on data update functions - saratoga-weather.org  24-Nov-2006
// -- begin settings
var flashcolor = '#00CC00'; // color to flash for changed observations
var flashtime  = '2000';    // miliseconds to keep flash color on (2000 = 2 seconds);
// -- end of settings

var ie4=document.all;

function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function reset_ajax_color( ) {
// reset all the <span name="ajax"...> styles to have no color override
    if (ie4) {
      var elements = getElementsByName_iefix("span","ajax");
    } else {
      var elements = document.getElementsByName("ajax");
    }
 var numelements = elements.length;
 for (var index=0;index!=numelements;index++) {
         var element = elements[index];
    element.style.color='';
 
      }
}

function set_ajax_obs( name, value ) {
// store away the current value in both the doc and the span as lastobs="value"
// change color if value != lastobs

var element = document.getElementById(name);
var lastobs = element.getAttribute("lastobs");
element.setAttribute("lastobs",value);
if (value != lastobs) {
          element.style.color=flashcolor;
}
element.innerHTML =  value;
}
// --- end of flash-green functions

before the
Code: [Select]
// main AJAX routine .. load and format clientraw.txt
function ajaxLoader(url) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
  }
lines.


Then add this line
Code: [Select]

    setTimeout("reset_ajax_color()",flashtime); // change text back to default color after 2 secs
 
just above the
Code: [Select]

    setTimeout("ajaxLoader('clientraw.txt?'+new Date())", 5000); // get new data after 5 secs
  }
} // end ajaxLoader function


Now the hard part.. you have to replace all of your lines in the JavaScript with assignment of .innerHTML with a call to the set_ajax_obs function to enable the green-flash to work.  So a line like this in the JavaScript
Code: [Select]
document.getElementById("ajaxgust").innerHTML = gust.toFixed(1); would be changed to
Code: [Select]
set_ajax_obs("ajaxgust",gust.toFixed(1));


Then your existing template should work with 'green flash' for changed conditions.

I did add a little feature - an '@' in front of the date/time stamp that ALWAYS turns green when the AJAX script has retrieved data.  It's nice to see the script is working even when WD clientraw update is pausing for main ftp update :-)

You can add this feature to your template too by adding
Code: [Select]
<span name="ajax" id="ajaxindicator"><strong>@</strong></span>&nbsp;&nbsp; in the HTML of the page where you'd like the indicator to appear, then add
Code: [Select]
       document.getElementById("ajaxindicator").style.color = flashcolor; just before the
Code: [Select]

   }
    }
    x.open("GET", url, true);
    x.send(null);

//get all of them every minute = 5000 milliseconds
//edit the location of your clienraw.txt twice!! (here and in the body onload)
setTimeout("reset_ajax_color()",flashtime); // change text back to default color
    setTimeout("ajaxLoader('clientraw.txt?'+new Date())", 5000); // get new data after 5 secs
  }
} // end ajaxLoader function


My homepage and conditions sidebar have been updated with green-flash-on-change.

The functions have been tested with IE6-SP2, IE7, Firefox 2.0, Opera 8, Netscape 7 and seem to work ok.

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 25, 2006, 03:40:24 PM
:roll:   I should have checked the XHTML 1.0-Strict docs more closely.

http://www.w3.org/TR/xhtml1/#h-4.8 does say "Note that in XHTML 1.0, the name attribute of these elements is formally deprecated, and will be removed in a subsequent version of XHTML."

So.. I'll be issuing a subsequent version that doesn't use the name="ajax" attribute in it.  For folks using plain HTML 4, it should be fine and will render correctly in browsers, but get spotted by the validator.w3.org compliance checker for XHTML 1.0-Strict.

Thanks for pointing that out krelvinaz!

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: carterlake on November 25, 2006, 06:33:07 PM
Yeehaw!

Check out the main page... http://www.carterlake.org/
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 25, 2006, 06:54:26 PM
Thanks to krelvinaz's gentle nudge, I've reworked the code so it's XHTML 1.0-Strict compliant.  I'm just finishing up the packaging and docs on my scripts page, so stand by for the (hopefully final) version in an hour or so.

The major change with the new version is to use 'class="ajax"' attributes instead of 'name="ajax"' attributes as the markers on the <span id="ajax..."> tags.  That puts the XHTML 1.0-Strict validator at ease.  To find those tags with the class="ajax" attribute involved rewriting two functions and finding (and handling) all the silly differences in JavaScript between IE6-SP2, IE7, Firefox 2.0, Navigator 7 and Opera 8.  Sigh..  I think I've found the quirks and now to documentation and packaging.

Hang in there for V1.03 shortly :-)

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 25, 2006, 07:50:37 PM
EDITED:  added one line to set_ajax_obs to avoid JavaScript errors trying to update when a <span id="ajax..." class="ajax"> is missing in the HTML.
EDITED:  reflects V1.04 code with error checking
---------------------------------------------------------------------------
Whew!  Verstion 1.03 with XHTML 1.0-Strict compliant code is now available and tested with IE6-SP2, IE7, Firefox 2.0, Navigator 7, and Opera 8.  It also passes the validator at
http://validator.w3.org/check?uri=http%3A%2F%2Fsaratoga-weather.org%2Fajax-testpage.php

Download from http://saratoga-weather.org/scripts-WD-AJAX.php (look near the middle of the long page for the download link.

I've updated the sample instructions and sample file set for AJAX 'green-flash' for changed conditions only and added a section there on how to update your current AJAX template set to use the new green-flash code.

The bulk of the mod is to use a small function to update the page (instead of changing innerHTML directly).  The function (set_ajax_obs) will retrieve the prior value, set the new value and change the color if prior != current.  The prior value is stored as an attribute in the span tag as 'lastobs="value"' by the JavaScript setAttribute function.  Then a timer-driven reset_ajax_color('') routine locates all the <span class="ajax"> tags and removes the green color after 2 seconds (adjustable).

Note:  if you'd been an early adopter, and already changed your <span id="ajax..."> tags to have 'name="ajax", you'll have to change them again (sorry) to "class="ajax" and remove the 'name='.  And.. copy in the new main flash-green code below. This makes it XHTML 1.0-Strict compliant.


Here's the revised instructions V1.03 for how to fit 'green-flash-on-change' into your WD AJAX page:


First, change all of the <span id="..."> tags used for AJAX substitution in your page (that you want to 'green-flash') to also have a class="ajax" tag so something like
Code: [Select]
<span id="ajaxtemp"> becomes
Code: [Select]
<span class="ajax" id="ajaxtemp">

Second, copy this
Code: [Select]
// --- added flash-green on data update functions - saratoga-weather.org  24-Nov-2006
// -- begin settings
var flashcolor = '#00CC00'; // color to flash for changed observations
var flashtime  = '2000';    // miliseconds to keep flash color on (2000 = 2 seconds);
// -- end of settings

var ie4=document.all;
var browser = navigator.appName;

function get_ajax_tags ( ) {
// search all the span tags and return the list with class="ajax" in it
//
  if (ie4 && browser != "Opera") {
    var elem = document.body.getElementsByTagName('span');
var lookfor = 'className';
  } else {
    var elem = document.getElementsByTagName('span');
var lookfor = 'class';
  }
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute(lookfor);
          if(att == 'ajax') {
               arr[iarr] = elem[i];
               iarr++;
          }
     }

     return arr;
}

function reset_ajax_color( usecolor ) {
// reset all the <span class="ajax"...> styles to have no color override
      var elements = get_ajax_tags();
 var numelements = elements.length;
 for (var index=0;index!=numelements;index++) {
         var element = elements[index];
    element.style.color=usecolor;
 
      }
}

function set_ajax_obs( name, value ) {
// store away the current value in both the doc and the span as lastobs="value"
// change color if value != lastobs

var element = document.getElementById(name);
if (! element ) { return; } // V1.04 -- don't set if missing the <span id=name> tag
var lastobs = element.getAttribute("lastobs");
element.setAttribute("lastobs",value);
if (value != lastobs) {
          element.style.color=flashcolor;
}
element.innerHTML =  value;
}
// --- end of flash-green functions
before the
Code: [Select]
// main AJAX routine .. load and format clientraw.txt
function ajaxLoader(url) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
  }
lines.


Then add this line
Code: [Select]

    setTimeout("reset_ajax_color('')",flashtime); // change text back to default color after 2 secs
 
just above the
Code: [Select]

    setTimeout("ajaxLoader('clientraw.txt?'+new Date())", 5000); // get new data after 5 secs
  }
} // end ajaxLoader function


Now the hard part.. you have to replace all of your lines in the JavaScript with assignment of .innerHTML with a call to the set_ajax_obs function to enable the green-flash to work.  So a line like this in the JavaScript
Code: [Select]
document.getElementById("ajaxgust").innerHTML = gust.toFixed(1); would be changed to
Code: [Select]
set_ajax_obs("ajaxgust",gust.toFixed(1));


Then your existing template should work with 'green flash' for changed conditions.

I did add a little feature - an '@' in front of the date/time stamp that ALWAYS turns green when the AJAX script has retrieved data.  It's nice to see the script is working even when WD clientraw update is pausing for main ftp update :-)

You can add this feature to your template too by adding
Code: [Select]
<span class="ajax" id="ajaxindicator"><strong>@</strong></span>&nbsp;&nbsp; in the HTML of the page where you'd like the indicator to appear, then add
Code: [Select]
element = document.getElementById("ajaxindicator");
if (element) { // V1.04 set indicator if <span id="ajaxindicator" class="ajax"> exists
          element.style.color = flashcolor;
}
just before the
Code: [Select]

   }
    }
    x.open("GET", url, true);
    x.send(null);

//get all of them every minute = 5000 milliseconds
//edit the location of your clienraw.txt twice!! (here and in the body onload)
setTimeout("reset_ajax_color()",flashtime); // change text back to default color
    setTimeout("ajaxLoader('clientraw.txt?'+new Date())", 5000); // get new data after 5 secs
  }
} // end ajaxLoader function


My homepage and conditions sidebar have been updated with green-flash-on-change.

Thanks again to krevinaz for the nudge to get it XHTML 1.0-Strict compliant.  

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: carterlake on November 26, 2006, 03:51:28 PM
Just a note to say that I figured out a way to add images to the AJAX mix... now the radar, webcam, and citycam images (on my main page) auto update if there is a change... using AJAX!
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: carterlake on November 28, 2006, 08:07:11 PM
Yet another update on this just awesome tool... the original person who wrote up the code mentioned that you can this with other files... now I'm working on having the majority of values on my home page be entirely live... many of them update every 6 seconds... others every 5 minutes (more than enough for most values)... couple that with auto updating images and you've got a page which is very close to never needing reloaded.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on November 29, 2006, 01:51:46 PM
That's very cool Tom!!  8)

I've added error checking to V1.03 post (above) so it is easier for folks to adapt without causing JavaScript errors due to missing <span id="ajax...."> tags.

The two changed parts are the set_ajax_obs function which now reads
Code: [Select]
function set_ajax_obs( name, value ) {
// store away the current value in both the doc and the span as lastobs="value"
// change color if value != lastobs

var element = document.getElementById(name);
if (! element ) { return; } // V1.04 -- don't set if missing the <span id=name> tag
var lastobs = element.getAttribute("lastobs");
element.setAttribute("lastobs",value);
if (value != lastobs) {
          element.style.color=flashcolor;
}
element.innerHTML =  value;
}


and the flashing indicator support which was
Code: [Select]
document.getElementById("ajaxindicator").style.color = flashcolor;
and is now
Code: [Select]
element = document.getElementById("ajaxindicator");
if (element) { // V1.04 set indicator if <span id="ajaxindicator" class="ajax"> exists
          element.style.color = flashcolor;
}

I've updated the instructions and sample files at http://saratoga-weather.org/scripts-WD-AJAX.php . Hopefully, this will make your addition of AJAX green-flash easier as you add/remove AJAX-driven variable updates.

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 02, 2006, 05:55:45 PM
Ken, is it possible to use this script with VWS?
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 02, 2006, 10:09:17 PM
If VWS can FTP up a delimited data file (text format) at 5 second intervals, then yes.. I don't know if VWS currently offers that.  I know there's a WeatherFlash add-on, but the format of the file(s) used is not documented as far as I can tell.

Let me know if you find a file-set uploaded by VWS to your website that has those conditions, then I could refit the AJAX code to use it :-)

Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 02, 2006, 10:14:40 PM
Ken, I noticed there is a CSV file export which updates at 3 seconds at default settings. If you go to settings then CSV Export you should see it but I'm not sure if you use VWS or not.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 02, 2006, 10:25:14 PM
Alas, I have no VWS.. just WeatherLink and Weather-Display.

If you could send me a sample of the .htx file template for the .csv and a sample of the uploaded .csv file (and the URL where you upload it on your site), I'll take a look.. should be easy to adapt :-)

Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: kray1000 on December 02, 2006, 10:31:19 PM
The trick would be to upload that .csv file at 5 second intervals... guess we're looking at a third-party app to do that... unless you're running your own server, I suppose...

Just a caveat to Ken... VWS changed the format of its .csv file a couple of years ago... worth mentioning if/when you get to the documentation phase...
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 02, 2006, 10:35:17 PM
I actually run webdrive for all of my FTP transfers and it seems to be pushing at 5 second intervals to my host or whenever the file updates. What I don't get is when I created the export file I'm actually getting data.csv and data2.csv. You can take a look at the files here if you wish ken.

http://www.capeweather.com/data.csv

http://www.capeweather.com/data2.csv
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 03, 2006, 01:02:56 AM
After much searching, I found the docs for the data.csv/data2.csv on pages 45-47 of the VWS manual ( http://www.wunderground.com/autoasp/downloads/vwsmanual.PDF )

It DOES look possible.. let me code a bit and post a sample for you to try.

Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 03, 2006, 01:08:25 AM
Very cool Ken. I just peeked at the manual and it does state the following...

Quote
Real-time data can be exported to a csv file for other programs to utilize


Lookin good so far. Can you tell if my files are updating quickly? Right now they are set for 5 seconds.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 03, 2006, 02:12:44 AM
Yes, your data.csv and data2.csv do update about every 5 seconds.

Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 05, 2006, 01:25:34 AM
AJAX is the absolute bomb!!! Thanks Ken for all your help!!!!  =D> I was really happy to get it working with VWS.

http://www.capeweather.com
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 05, 2006, 01:40:17 AM
It IS very cool.. I think your're the first VWS site to have AJAX 'green-flash' updates.

I will be packaging a VWS version of the script(s) around the VWS templates so html only sites should be able to use it (if they can upload the data.csv file often enough).

Thanks Chris for letting us play with the concept with your website.. the homepage looks great!

Best regards,
Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 05, 2006, 01:52:33 AM
Thanks Ken! I had a ton of fun playing around too and implementing it into my site. It took some trial and error but it's great to know that other VWS users can have it on there site as well. I really think it's going to be a home run! Looking forward to seeing your script package that you will be putting together for this project. I would also mention that folks will need a 3rd party FTP app. to update the data.csv files since the built in uploader in VWS is a bit slow and probably will not be fast enough. I'm currently using webdrive which is a thousand times more reliable and faster than the standard built in VWS uploader incase anybody wants to konw. Also, I hope Ed at Ambient can figure out why the seconds don't update in the .csv file. Maybe he will reply tomorrow. If he does I will update.  :D

http://www.webdrive.com
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: weatheroz on December 05, 2006, 04:16:37 AM
Quote from: "capeweather"

http://www.webdrive.com


Great application.... I had to get it to get around some of my vws issues I was having before I changed over to WD.

Still use it now, as it makes it a whole lot easier to get stuff on to my website, as now I simply run as part of the dos batch file the command to copy the file/s to my website, rather than ftp 'ing there. :)
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: FishDude on December 05, 2006, 05:53:42 AM
Quote from: "capeweather"
Thanks Ken! I had a ton of fun playing around too  Also, I hope Ed at Ambient can figure out why the seconds don't update in the .csv file. Maybe he will reply tomorrow. If he does I will update.  :D

http://www.webdrive.com


I wouldn't hold my breathe! Seems like development stopped at the current V20. I guess he figured that was "good enough".
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: weatheroz on December 05, 2006, 08:39:11 AM
Quote from: "FishDude"
Quote from: "capeweather"
Thanks Ken! I had a ton of fun playing around too  Also, I hope Ed at Ambient can figure out why the seconds don't update in the .csv file. Maybe he will reply tomorrow. If he does I will update.  :D

http://www.webdrive.com


I wouldn't hold my breathe! Seems like development stopped at the current V20. I guess he figured that was "good enough".


So he's gone on another one of his 'sabbaticals' or something again ? :roll:

Sounds like nothing has changed, which really vindicates the decision of many to upgrade to Weather Display. :)

I'm glad that Ken was able to get this great script to work with vws though, as it gives the vws people something to brighten their day.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: ncpilot on December 05, 2006, 09:30:19 AM
Since Webdrive came up... I visited their site and have some questions for those of you that use it...

The "synchronize" feature looks interesting, but even the pdf users guide has no info on it. The slide show had a bit...

I'm interested in the time granularity for synching. Can it monitor a folder, and when a new file shows up, FTP it somewhere? How frequently can it monitor for file change? Every x minutes?
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: anchorageweather on December 05, 2006, 11:37:44 AM
Quote from: "kenmtrue"
It IS very cool.. I think your're the first VWS site to have AJAX 'green-flash' updates.

I will be packaging a VWS version of the script(s) around the VWS templates so html only sites should be able to use it (if they can upload the data.csv file often enough).

Thanks Chris for letting us play with the concept with your website.. the homepage looks great!

Best regards,
Ken


  (kickin dirt) us WeatherLink guys never have any fun....:cry:
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: ncpilot on December 05, 2006, 12:45:55 PM
Weatherlink can generate a CSV file, if that's all that's needed...
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 05, 2006, 02:37:43 PM
A CSV file, and a way to get it to your website fairly quickly.

I use WeatherLink too but it's FTP is kinda slow and seems to hog up the console.  After I make some VWS template adjustments for green-flash, I'll see what can be done with regular WeatherLink too (and the Current_VantagePro.htx template.

I wouldn't want you to miss out on the fun :-)

Ken
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: anchorageweather on December 05, 2006, 02:45:59 PM
Quote from: "kenmtrue"
After I make some VWS template adjustments for green-flash, I'll see what can be done with regular WeatherLink too (and the Current_VantagePro.htx template.

I wouldn't want you to miss out on the fun :-)

Ken


Ken; always taking care of the little guy! :D
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 05, 2006, 02:51:17 PM
Quote from: "ncpilot"
Since Webdrive came up... I visited their site and have some questions for those of you that use it...

The "synchronize" feature looks interesting, but even the pdf users guide has no info on it. The slide show had a bit...

I'm interested in the time granularity for synching. Can it monitor a folder, and when a new file shows up, FTP it somewhere? How frequently can it monitor for file change? Every x minutes?


I haven't really played with it much as far as the settings are concerned. I installed it and configured to my server and it started working the way I wanted to right out of the box. I didn't really think I needed to do much because whenever a file was updated it would automatically write it to the mapped network drive almost instantly.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: weatheroz on December 05, 2006, 07:21:33 PM
Quote from: "ncpilot"
Since Webdrive came up... I visited their site and have some questions for those of you that use it...

The "synchronize" feature looks interesting, but even the pdf users guide has no info on it. The slide show had a bit...

I'm interested in the time granularity for synching. Can it monitor a folder, and when a new file shows up, FTP it somewhere? How frequently can it monitor for file change? Every x minutes?


I've just plugged in it, and changed the created file folder as being on w: drive, and it just uploads it automatically.

Never looked at it beyond that I'm afraid. :(

There is (or was) a demo version you could play with for a little while, perhaps you might like to give that a shot and see if does what you want ?
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: SLOweather on December 05, 2006, 08:41:25 PM
I don't have any experience with the synchronize feature either, but I've been wondering about it.

I just map the website ftp folder as a drive and have VWS save the jpgs there. It thinks it's a local drive.

This process does tend to freeze VWS during the upload process, and I've been wondering if folder sync would stop that.

As Oz noted, there is a 30 day (I think) trial of WebDrive. My experience is that the clock is only checked on WebDrive startup. I think I got got 6 or 7 weeks out of my trial.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: ncpilot on December 05, 2006, 09:49:18 PM
I called the folks that sell Webdrive, and they told me that the program doesn't have a way of checking a local folder for a changed file, or new file, on any kind of short time frame (like every few minutes). It sounds like you could manually trigger something like that...

I was thinking that if you have a program that generates some kind of file, whether csv, or jpeg, or whatever, but doesn't itself have a way to FTP, maybe Webdrive could sense the new file and do the transfer.

Sounds like the drive mapping may be a way to do it, but what if you want a program to write a file locally, but you also want to FTP it somewhere?

I don't actually have a reason for doing this, yet anyway... it's more an academic exercise...
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: capeweather on December 05, 2006, 09:57:54 PM
Webdrive will send the file based on whatever new file is being generated. Once a new file is created it will transfer the data to the mapped location you tell it to go. So if you're generating a file which in my case is the data.csv file every five seconds, webdrive will send it out every time it's created. This also holds true for all the graphics in VWS and the .htx conversions. It will spit out the data as fast as it created. Have you tried the trial yet? It's really cool once you start playing around wit it.
Title: Re: WD + PHP + AJAX with Wunderground-style 'green flash'
Post by: saratogaWX on December 06, 2006, 02:37:59 AM
So... Chris and I finished up this evening with the VWS-AJAX demo.. please continue discussion on this thread (http://www.wxforum.net/viewtopic.php?p=2439#2439) for the VWS-AJAX info.

Best regards,
Ken