Trixology

WeatherCat => WeatherCat Web Templates => Topic started by: tigers on March 12, 2012, 12:51:29 AM

Title: AJAX webpages are underway
Post by: tigers on March 12, 2012, 12:51:29 AM
I've begun work on a new template that incorporates javascript to have certain data updated in real-time. I don't have much to show thus far, but you can see the basic framework for a real-time dashboard (updates at every 5 seconds) that includes temp, pressure, and rain here: http://wx.atkinsfamily.org/indexjq.php

This seems to work on Safari, Firefox, Chrome, and iOS.

Like I said above, this is just the very basics right now, but I'm hoping to evolve this into something pretty cool. Gauges are on the list, but to be honest I'm not really a "gauge" guy. Just give me the number and I'm all set. Now graphs, that's another matter altogether. I've found a couple cool looking possibilities for graphs but that's a bit further down the road..
Title: Re: AJAX webpages are underway
Post by: Steve on March 12, 2012, 01:09:49 AM
Very cool, Todd! Thanks for taking on this project.

Steve
Title: Re: AJAX webpages are underway
Post by: Administrator on March 12, 2012, 08:44:58 AM
Nice work Todd!

Cheers,
Stu.
Title: Tiger in your tank . . . . (Re: AJAX webpages)
Post by: elagache on March 12, 2012, 09:11:50 PM
Howdy WeatherCat fans,  .. . .

I've begun work on a new template that incorporates javascript to have certain data updated in real-time.

Hurrah!!  [bounce]  Thanks Tiger!!  [cheer]

See what happens when you put a  ;) tiger in your tank!  [lol2]

Cheers, Edouard  [cheers1]
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 12, 2012, 10:32:50 PM
Looks very professional, far better than he primitive live display I have on my website.

I'm hoping there is going to be a metric version  ;)

Tony
Title: Re: AJAX webpages are underway
Post by: tigers on March 12, 2012, 11:13:58 PM
Looks very professional, far better than he primitive live display I have on my website.

I'm hoping there is going to be a metric version  ;)

Tony

Funny you should say that! I'm working on a way to set SI units now. I just gotta figure out if the cgi output from LWC is always in imperial units or not. It looks like this is the case but I just need to ask Stu to verify.
Title: Re: AJAX webpages are underway
Post by: mattm on March 12, 2012, 11:50:33 PM
Very slick! I wish I knew more Javascript. Looking forward to the final result.

For SI units, I'm thinking you could get the php file to output two .txt docs, one for imperial, one for SI (just converting the variables).
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 12, 2012, 11:57:53 PM


Funny you should say that! I'm working on a way to set SI units now. I just gotta figure out if the cgi output from LWC is always in imperial units or not. It looks like this is the case but I just need to ask Stu to verify.

Always Imperial I'm afraid, hence the rather messy conversions on my site.

I'm looking forward to seeing it done properly  [wink]
Title: Re: AJAX webpages are underway
Post by: tigers on March 13, 2012, 12:10:43 AM
Very slick! I wish I knew more Javascript. Looking forward to the final result.

For SI units, I'm thinking you could get the php file to output two .txt docs, one for imperial, one for SI (just converting the variables).

I'm converting the units in js since I'd rather just output one file. I'm thinking this might be slightly easier on the server since the xml file is getting updated every 5 seconds. Besides, we all have multi-core computers now so I figure might as well use some of those cycles for client-side arithmetic!
Title: Re: AJAX webpages are underway
Post by: mattm on March 13, 2012, 12:19:29 AM
True (also I meant to write xml, not txt).  It's probably more user friendly to allow the user to select the units on their end (and have the conversion happen on their side).
Title: Re: AJAX webpages are underway
Post by: tigers on March 13, 2012, 02:31:20 AM
Ok, I've got all the real-time variables available from WC (via the CGI panel) being read into a webpage via Ajax. I've also implemented a switch whereby one can switch between SI and Imperial units on the fly. The default is hardcoded into the page so if you use this template, you can just update that variable to either "c" or "f" depending on what you want the default to be.

http://wx.atkinsfamily.org/indexjq.php
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 13, 2012, 11:22:57 AM
Looks great, very professional.
Title: Nifty!! (Re: AJAX webpages)
Post by: elagache on March 13, 2012, 04:23:06 PM
Howdy Todd (aka Tigers), Tony,  and WeatherCat fans,

Ok, I've got all the real-time variables available from WC (via the CGI panel) being read into a webpage via Ajax.

ditto on Tony's observation!  [tup]

Certainly amazing how something as seemingly simple as this brings an immediacy to weather at a remote location!

Thanks again for taking this on Todd!  [spin]

Cheers, Edouard  [cheers1]
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 16, 2012, 07:41:12 AM
Coming along nicely  [tup]

Is there a reason you have decided to go with metres a second instead of km/hr in the metric version?

Tony
Title: Re: AJAX webpages are underway
Post by: tigers on March 16, 2012, 04:33:47 PM
Coming along nicely  [tup]

Is there a reason you have decided to go with metres a second instead of km/hr in the metric version?

Tony

No reason in particular. I'll switch it over to kph tonight.
Title: Re: AJAX webpages are underway
Post by: tigers on March 20, 2012, 02:16:15 AM
Page is finally getting somewhere. I've used the jquery and jquery ui scripts to help out with the AJAX and tab functions. One advanatage is that changing the theme is pretty simple and you can even roll your own by going to http://jqueryui.com/themeroller/

Also, the page is valid HTML5 and makes use of CSS3, so older browsers are out (IE mainly). Works just phone on iOS and Safari, FF, and Chrome.

I've still got to integrate the graphs and I have a couple more ideas I want to try and implement but I hope to have this ready to go in a week or so (or at least after the next release of WC which will provide a couple things that I and SaratogaWX need ;) ).

Anyway, check it out:
http://wx.atkinsfamily.org
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 20, 2012, 02:23:28 AM
Looking great  [tup]
Title: Re: AJAX webpages are underway
Post by: tigers on March 20, 2012, 02:47:03 AM
Looking great  [tup]

Thanks! And I haven't forgotten about the metric units--I just removed the user selectable option since that was more of a test thing anyway. All one needs to do is change a variable in the template and it'll switch to metric or imperial depending how one wants it.
Title: Re: AJAX webpages are underway
Post by: mattm on March 20, 2012, 11:16:58 AM
Very impressive. I'm liking your development page a lot. Thanks for putting the time into it.
Title: Re: AJAX webpages are underway
Post by: WCDev on March 20, 2012, 04:50:20 PM
Indeed, very nice  [tup]
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 20, 2012, 10:37:10 PM
Looking great  [tup]

Thanks! And I haven't forgotten about the metric units--I just removed the user selectable option since that was more of a test thing anyway. All one needs to do is change a variable in the template and it'll switch to metric or imperial depending how one wants it.

I was going to ask about it  ;) but realised it was still in development.

Is there any chance of doing some Javanese on the wind direction to get it to display compass bearings rather than degrees? My pet hate.. but not enough to put me off  [tup]

Tony
Title: Re: AJAX webpages are underway
Post by: saratogaWX on March 21, 2012, 12:08:39 AM
Here's a handy JavaScript code to convert degrees to cardinal directions:

Code: [Select]
function windDir ($winddir)
// Take wind direction value, return the
// text label based upon 16 point compass -- function by beeker425
//  see http://www.weather-watch.com/smf/index.php/topic,20097.0.html
{
   var $windlabel = new Array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
   return $windlabel[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];
}

use it by
Code: [Select]
var windDirection = windDir(windDegrees); and the windDirection variable will contain the text of the cardinal wind direction based on the number in windDegrees.

Best regards,
Ken
Title: Re: AJAX webpages are underway
Post by: tigers on March 21, 2012, 12:53:07 AM
Here's a handy JavaScript code to convert degrees to cardinal directions:

Code: [Select]
function windDir ($winddir)
// Take wind direction value, return the
// text label based upon 16 point compass -- function by beeker425
//  see http://www.weather-watch.com/smf/index.php/topic,20097.0.html
{
   var $windlabel = new Array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
   return $windlabel[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];
}

use it by
Code: [Select]
var windDirection = windDir(windDegrees); and the windDirection variable will contain the text of the cardinal wind direction based on the number in windDegrees.

Best regards,
Ken

Thanks! That's much more compact than the code I came up with!
Title: Re: AJAX webpages are underway
Post by: tigers on March 21, 2012, 01:17:12 AM
Looking great  [tup]

Thanks! And I haven't forgotten about the metric units--I just removed the user selectable option since that was more of a test thing anyway. All one needs to do is change a variable in the template and it'll switch to metric or imperial depending how one wants it.

I was going to ask about it  ;) but realised it was still in development.

Is there any chance of doing some Javanese on the wind direction to get it to display compass bearings rather than degrees? My pet hate.. but not enough to put me off  [tup]

Tony

Cardinal directions have been added thanks to the efficient function provided by saratogaWX (which is many many lines shorter than the code I'd originally come up with!).
Title: Re: AJAX webpages are underway
Post by: WCDev on March 21, 2012, 05:15:37 PM
Looking good Todd  [tup]
Title: Thanks for the converter! (Re: AJAX webpages)
Post by: elagache on March 21, 2012, 06:21:29 PM
Hi Ken, Todd, Stu, and WeatherCat fans,

Here's a handy JavaScript code to convert degrees to cardinal directions:

Thanks! That's much more compact than the code I came up with!

Ditto!! Shucks I should have thought of that!! (http://www.canebas.org/Weather/LWC_forum/Custom_emoticons/D%27oh.gif)

Not certain AppleScript can do the math properly . . . *sigh* everything is weird in AppleScript  :o, but that doesn't look like a real stretch.  [tup]

The one good thing is I have that code in a separate library so I could swap it out and all my AppleScripts would be updated.

Thanks Ken for the elegant solution!!  [bounce]

Cheers, Edouard  [cheers1]
Title: Re: AJAX webpages are underway
Post by: tigers on March 22, 2012, 01:29:23 AM
Looking good Todd  [tup]

Thanks, Stu. Got the realtime min/max for today included now and no problems to report with the interim build. Thanks.
Title: Re: AJAX webpages are underway
Post by: WCDev on March 25, 2012, 10:41:11 AM
Just had a quick look Todd, looking good! (So glad you made the high/low text a little bit bigger - I had to get a twenty year old colleague to read it earlier in the week  [biggrin])

Stu.
Title: Re: AJAX webpages are underway
Post by: tigers on March 27, 2012, 02:24:20 AM
Thanks Stu, yeah I was playing around with Google fonts. I ended up making the widget boxes a little wider to there's more room to work.

Anyway, things are coming along nicely. I've got weather underground forecasts and alerts working now and the only thing left for an initial release is to bring in the graphs.

Not sure of a good solution for the STMONTHLY and STDAILY tags yet...the output from those is W   I   D   E! :D
Title: Re: AJAX webpages are underway
Post by: HairyMcLeary on March 27, 2012, 03:03:53 AM

Looking good!

I like the forecast icons, give the page a bit of a lift
Title: Re: AJAX webpages are underway
Post by: mattm on March 27, 2012, 03:06:53 AM
Lookin' great!

I'm assuming we'd have the flexibility to swap tags. When Stu gets tags for all the extra sensors, I'd like to present a few of those.
Title: Re: AJAX webpages are underway
Post by: Steve on March 27, 2012, 04:45:11 AM
That's really nice looking, Todd! Thanks for working on this.
Steve
Title: Re: AJAX webpages are underway
Post by: WCDev on March 27, 2012, 06:40:24 PM
Lookin' great!

I'm assuming we'd have the flexibility to swap tags. When Stu gets tags for all the extra sensors, I'd like to present a few of those.

Hi Matt,
As of version 0.9.5, the current values of additional sensors are available (see http://www.trixology.com/live_weather/custom/ - scroll down to 'Additional Current Readings') - queries are planned for a later release.

Cheers,
Stu.
Title: Re: AJAX webpages are underway
Post by: WCDev on March 27, 2012, 09:11:29 PM
Not sure of a good solution for the STMONTHLY and STDAILY tags yet...the output from those is W   I   D   E! :D

Sorry about that  :)

I've been doing tentative work on a macro language for templates to do data tables and such like (it'll probably make an experimental appearance in early V2 releases if there's interest to take it forward). This will make it possible to come up with custom layouts and data in the future (simple conditionals, loops and variables which will allow one to loop a bunch of tags from some date to some other date - say the first day of the month to today). But for now we're stuck with the hard-wired, pre-formatted output for which I apologise - I'd love to sit here and develop all day, but the most important thing on my plate at the moment is to get V1 out.

Cheers,
Stu.