Sandaysoft

Support forum for Cumulus weather station software
It is currently Tue May 21, 2013 7:49 pm
Please click here before posting. Help me to help you!
Useful Links: Cumulus FAQ • Enhancement requests • Wiki (documentation)
Please put your approximate location into your profile
Add your web site to the Cumulus user map
Vantage Pro2 users with firmware 3.00 should upgrade to fw 3.12 and Cumulus 1.9.4

All times are UTC




Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Fri Feb 25, 2011 9:19 am 
Offline
User avatar

Joined: Tue Jul 29, 2008 8:00 pm
Posts: 2001
Location: Thornhill, Dumfries, UK
Weather Station: WH1081
Operating System: Mac OSx & Win 7
Do people seriously not use Javascript?! The Internet must be quite dull then ;)

In all fairness we should always consider these things -- especially for people who rely on technology such as screen readers. Who said web page design was simple? It's bad enough coding a page for a bucket full of browsers all with their own set of issues.

_________________
David
Contact Me


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Fri Feb 25, 2011 1:07 pm 
Offline

Joined: Thu Feb 03, 2011 1:15 am
Posts: 136
Location: Canberra
Weather Station: WH1091
Operating System: OSX running WinXP via Parallels
Interesting change in the browser stats since I last looked a year or two ago: IE ~45%, FFox ~30%, Chrome ~13%, Safari ~6% So non-w3c-compliant browsers (IE) now down to below 50%... hallelujah!

DN

(though Safari's javascript leaves something to be desired)

_________________
Image


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 8:51 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Paul & Daj,

I really like this javascript. Great job. I have tried it on a test page and am able to update the data as per the instructions. I also use a fair bit of javascript to update other stuff using the standard web tags (wind dir images, trend arrows, text, speed conversions, etc). Will using the <span id="temp"><#temp></span> still allow the <#temp> tag to update trend arrows for instance?. I couldn't get it to work. Is there a work around?

Thanks

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 10:29 am 
Offline

Joined: Mon Jan 25, 2010 1:55 pm
Posts: 623
Location: Brighton, UK
Weather Station: Watson W-8681
Operating System: Vista
Hi Dan,

Glad you like it. Seems you are using some Javascript in your HTML anyway for the trend arrows. To make them work 'realtime' that code would need to be added in the realtimereader.js file.

Something like:
Code:
var temptrendicon = rawdata[25];
if (temptrendicon==0){var imagen = "steady1.gif";}
if (temptrendicon>0){var imagen = "up1.gif";}
if (temptrendicon<0){var imagen = "down1.gif";}
$("#temptrendicon").html('<img src="http://www.brisbaneliveweather.com/'+imagen+'"align =absmiddle>');


Then in your HTML, code <span id="temptrendicon"></span>

_________________
Paul

http://www.greatcollegestreet.co.uk -Online
http://www.lehamel.eu - Online

Image Image


Last edited by Synewave on Sun Feb 27, 2011 10:44 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 10:35 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Thanks Paul, I'll give it a try.

Cheers

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 10:45 am 
Offline

Joined: Mon Jan 25, 2010 1:55 pm
Posts: 623
Location: Brighton, UK
Weather Station: Watson W-8681
Operating System: Vista
Ooops, Sorry Dan, there was an error in that code I quoted. I've upated my post.

_________________
Paul

http://www.greatcollegestreet.co.uk -Online
http://www.lehamel.eu - Online

Image Image


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 3:06 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1846
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
In a similar fashion, all your other JS created Hi / Lo, weather / wind icon decision coding needs to moved / modded into the ajax 'loop' :shock:

Welcome to the world of bespoke coding - to paraphrase Oscar Wilde "The pure and simple page is rarely pure and never simple" !

But you do feel so good when a little graphic changes or some text suddenly appears :clap:

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Feb 27, 2011 7:55 pm 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Thanks Paul / Daj,
I can see some more lost hours in front of the screen coming up for me. :lol:

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Thu Mar 03, 2011 12:41 pm 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Thanks again Paul & Daj.

:clap: The script works well and easy enough to get up and running. Paul, thanks for the tip about the trend arrows. I was able to use that info to get all my other bits to update as well. Its a bit clunky in Chrome (okay in IE and FF) when fetching the wind direction graphic etc, but I can live with that. :clap:

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 9:16 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Hi Guys,

I need some help with some conversions & calculations and the <span> tags.
Previously, I was running some js to convert and display wind speed km/h to knots (for fishing buddies) easily enough. The old script was:

<script type="text/javascript">
var speed = "<#wlatest>";
var speedknots = Math.abs(speed*0.54*10)/10;
document.write(speedknots.toFixed(1));
</script>&nbsp;kts

I have been able to get the do a similar thing using the realtimereader.js by using:

var spknots = rawdata[6];
$("#speedknots").html(Math.abs(spknots*0.54*10)/10);

and the span tag is <span id="speedknots"></span>

However, this will give 1.6 km/h as 0.8640000000000001 knots.

How am I able to display with 1 decimal point, ie, as 0.8 knots. Am I close or way off the mark here?

I have tried several variants but it usually breaks the javascript.

Thanks in advance.

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 10:49 am 
Offline

Joined: Mon Jan 25, 2010 1:55 pm
Posts: 623
Location: Brighton, UK
Weather Station: Watson W-8681
Operating System: Vista
captzero wrote:
Hi Guys,

I need some help with some conversions & calculations and the <span> tags.
Previously, I was running some js to convert and display wind speed km/h to knots (for fishing buddies) easily enough. The old script was:

<script type="text/javascript">
var speed = "<#wlatest>";
var speedknots = Math.abs(speed*0.54*10)/10;
document.write(speedknots.toFixed(1));
</script>&nbsp;kts

I have been able to get the do a similar thing using the realtimereader.js by using:

var spknots = rawdata[6];
$("#speedknots").html(Math.abs(spknots*0.54*10)/10);

and the span tag is <span id="speedknots"></span>

However, this will give 1.6 km/h as 0.8640000000000001 knots.

How am I able to display with 1 decimal point, ie, as 0.8 knots. Am I close or way off the mark here?

I have tried several variants but it usually breaks the javascript.

Thanks in advance.


Dan,

Based on the script you quoted above that worked, try this in the realtimereader.js

Code:
var spknots = rawdata[6];
var speedknots = Math.abs(spknots*0.54*10)/10;
var speedknots = speedknots.toFixed(1);
$("#speedknots").html(speedknots);


Untested, but logically should work based on your original.
The <span id="speedknots"></span> stays the same in your HTML.

_________________
Paul

http://www.greatcollegestreet.co.uk -Online
http://www.lehamel.eu - Online

Image Image


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 11:00 am 
Offline
User avatar

Joined: Wed Mar 03, 2010 10:20 am
Posts: 299
Location: Brisbane, Australia
Weather Station: Vantage Pro2 w/ daytime FARS
Operating System: Windows Vista SP2
Synewave wrote:
Untested, but logically should work


Works like a dream. Thanks Paul.

I knew I had to add .toFixed(1) somewhere.

And, thanks for the quick reply too.

_________________
Dan

http://www.brisbaneliveweather.com




A man with a thermometer always knows the temperature. A man with two thermometers, not so sure.


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 1:03 pm 
Online
User avatar

Joined: Thu Jan 07, 2010 9:44 pm
Posts: 2512
Location: Wilmslow, Cheshire, UK
Weather Station: Davis VP2
Operating System: XP SP3, Win 7
Why Math.abs() are you expecting it to go negative?

Math.round(spknots*0.54*10)/10

_________________
Mark
Wilmslow Astro Weather


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 1:37 pm 
Online
User avatar

Joined: Thu Jan 07, 2010 9:44 pm
Posts: 2512
Location: Wilmslow, Cheshire, UK
Weather Station: Davis VP2
Operating System: XP SP3, Win 7
Second thoughts, as you are using .toFixed() - required for those pesky n.0 values - then all you need is:


var speedknots = rawdata[6]*0.54;
speedknots = speedknots.toFixed(1);
$("#speedknots").html(speedknots);

_________________
Mark
Wilmslow Astro Weather


Top
 Profile  
 
 Post subject: Re: Auto-refresh Website Index Page Without Using Meta Refre
PostPosted: Sun Mar 06, 2011 2:05 pm 
Offline
User avatar

Joined: Tue Dec 09, 2008 1:37 pm
Posts: 1846
Location: Dudley, West Midlands, UK
Weather Station: None !
Operating System: XP SP3
Or as a one-liner

$("#speedknots").html((rawdata[6]*054).toFixed(1));

:lol: but not so easy on the mind or the eye :shock:

_________________
Image
......................Imagine, what you will KNOW tomorrow !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group