Page 2 of 23

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 1:50 am
by Buford T. Justice
Buford T. Justice wrote:
robynfali wrote:That looks awesome, do you know how you might install it into the templates that Jacques makes, such as mine?
Attach your indexT.htm or whatever template page you use and I will look at it.
Actually, I "THINK" you can do it this way. Be sure to backup "index.php" then open it with a program like Notepad++ and do the following:

CHANGE LINES 30-51:

Code: Select all

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $location; ?> Weather Sunset template</title>
	<meta name="keywords" content="Current, actually, last minute" />
	<meta name="description" content="Current weather observations" />
	<link type="text/css" rel="stylesheet" href="style.css" />
  <link rel="stylesheet" type="text/css" href="lib/ajaxtabs/ajaxtabs.css" />
  <script type="text/javascript" src="lib/ajaxtabs/ajaxtabs.js"></script>
	<script type="text/javascript">
		var dayname = new Array ('<?php echo $Tr_sun."','".$Tr_mon."','".$Tr_tue."','".$Tr_wed."','".$Tr_thu."','".$Tr_fri."','".$Tr_sat; ?>');
		var monthname = new Array ('<?php echo $Tr_jan."','".$Tr_feb."','".$Tr_mar."','".$Tr_apr."','".$Tr_may."','".$Tr_jun."','".$Tr_jul."','".$Tr_aug."','".$Tr_sep."','".$Tr_oct."','".$Tr_nov."','".$Tr_dec; ?>');	
	</script>
	<script type="text/javascript">
		function changeImage(im) {
			document.images["graphs"].src = im + "?" + new Date().getTime();
		}
	</script>
</head>
<body>
TO:

Code: Select all

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $location; ?> Weather Sunset template</title>
	<meta name="keywords" content="Current, actually, last minute" />
	<meta name="description" content="Current weather observations" />
	<link type="text/css" rel="stylesheet" href="style.css" />
  <link rel="stylesheet" type="text/css" href="lib/ajaxtabs/ajaxtabs.css" />
  <script type="text/javascript" src="lib/ajaxtabs/ajaxtabs.js"></script>
	<script type="text/javascript">
		var dayname = new Array ('<?php echo $Tr_sun."','".$Tr_mon."','".$Tr_tue."','".$Tr_wed."','".$Tr_thu."','".$Tr_fri."','".$Tr_sat; ?>');
		var monthname = new Array ('<?php echo $Tr_jan."','".$Tr_feb."','".$Tr_mar."','".$Tr_apr."','".$Tr_may."','".$Tr_jun."','".$Tr_jul."','".$Tr_aug."','".$Tr_sep."','".$Tr_oct."','".$Tr_nov."','".$Tr_dec; ?>');	
	</script>
	<script type="text/javascript">
		function changeImage(im) {
			document.images["graphs"].src = im + "?" + new Date().getTime();
		}
	</script>
	<script type="text/javascript" src="bt-sager-cu.js"></script>
	<script type="text/javascript" src="bt-sager.js"></script>
</head>
<body onload="forecast();">
CHANGE LINE 131:

Code: Select all

				<p><img src="style/forecast/forecast_<?php echo $isdaylight.'_'.$forecastnumber; ?>.png" alt="<?php echo $Tr_forecast.': '.$forecast; ?>" title="<?php echo $Tr_forecast.': '.$forecast; ?>" /></p>
TO:

Code: Select all

				<p><b>12-24 Hour Forecast:</b><a href="http://www.freewebs.com/btjustice/bt-forecasters.html" style="text-decoration:none;" target="_blank"><span id="Forecast" style="font-family:Tahoma;color:red;font-size:16px;">...Forecast Offline...</span></a></p>
Hopefully that will work. If not, restore your backup of "index.php".

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 2:07 am
by Werk_AG
Still get ...Forecast Offline...

I'm testing with included indexT.htm
http://www.meteocercal.info/indexT.htm

This is what I have in bt-sager-cu.js

Last Cumulus Update: 5-9-2013 2:00:11 AM UTC
*/
var l = 39,22611;
var w3 = 1;
var wd = "N";
var r = 1015,9;
var b = "hPa";
var t = "Falling slowly".toLowerCase();
var c = "Cloudy".toLowerCase();

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 2:31 am
by Buford T. Justice
Werk_AG wrote:Still get ...Forecast Offline...

I'm testing with included indexT.htm
http://www.meteocercal.info/indexT.htm

This is what I have in bt-sager-cu.js

Last Cumulus Update: 5-9-2013 2:00:11 AM UTC
*/
var l = 39,22611;
var w3 = 1;
var wd = "N";
var r = 1015,9;
var b = "hPa";
var t = "Falling slowly".toLowerCase();
var c = "Cloudy".toLowerCase();
Your decimal coordinate is using a comma instead of a period. I have no idea why, but you can close Cumulus, open cumulus.ini, and change the comma to a period for both Latitude and Longitude.

I also see your barometric hPa is also using a comma.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 2:53 am
by Werk_AG
Buford T. Justice wrote:... open cumulus.ini, and change the comma to a period for both Latitude and Longitude.

I also see your barometric hPa is also using a comma.
If I change the comma to a point in cumulus.ini, when I restart Cumulus, the values are reset to zero.
Possibly this is a question related to regional settings in Windows. I'm using settings for Portugal, where decimal point is a comma. This is why barometric hPa is also using a comma.

Thanks for the help

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 3:01 am
by Werk_AG
Just to test, manually edited the file bt-Sager-cu.js, and changing the comma by a point, and it works.
It's really a problem with regional settings that use a comma as decimal separator.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 3:13 am
by Buford T. Justice
That damn comma is going to mess up JavaScript as well as a comma is an operator that returns the number on the right side of the comma. Why Portugal? WHY?

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 3:30 am
by Werk_AG
When something is working well, often something comes along to complicate... :)

I think it is not only Portugal that uses the comma as the decimal separator.
From International Language Environments Guide
"Great Britain and the United States are two of the few places in the world that use a period to indicate the decimal place. Many other countries use a comma instead."

Seems that I'm only the first to borrow you with this damm comma :)

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 6:24 am
by robynfali
It's this one mate, it doesn't have that file, and it's processed differently to the standard template


http://weatherbyyou.com/wsu_sheet.php

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 7:10 am
by steve
A number of the Cumulus web tags have 'replace commas' versions, to get around this problem where the user has commas for decimals but the web server uses decimal points. I can do such a version for the latitude and longitude web tags. In this case it would probably be easier to add a parameter "rc=y", eg: <#latitude dp=5 rc=y>. Or, in a similar way to what you've done to convert to lower case, you could you the JavaScript 'replace' function: .replace(",",".") but then it would have to be string.

One thing I don't understand though; as JavaScript runs in the browser, on the client, why doesn't it use the user's settings anyway? Is this just the way JS works? It certainly makes sense to work that way (the way it does).

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 10:02 am
by Buford T. Justice
Werk_AG wrote:When something is working well, often something comes along to complicate... :)

I think it is not only Portugal that uses the comma as the decimal separator.
From International Language Environments Guide
"Great Britain and the United States are two of the few places in the world that use a period to indicate the decimal place. Many other countries use a comma instead."

Seems that I'm only the first to borrow you with this damm comma :)
http://en.wikipedia.org/wiki/Decimal_se ... les_of_use

That just seems crazy to me. I guess it is how we are brought up and taught. To me, to type the numerical value of one million two hundred and thirty-four thousand five hundred and sixty-seven and eighty-nine hundredths would be:

1,234,567.89

But doing it that odd other way:

1 234 567,89 or even 1.234.567,89

Those just don't look right.

I have been trying to come up with a JavaScript replace function or charAt function to change commas to periods, but I have not had any luck. I am still tinkering with a solution to this.
robynfali wrote:It's this one mate, it doesn't have that file, and it's processed differently to the standard template


http://weatherbyyou.com/wsu_sheet.php
The directions I typed earlier should work for your "indexT.php" file. Do you have one saved as "indexT.php" and have Cumulus set to process it as save it remotely as "index.php"?
steve wrote:A number of the Cumulus web tags have 'replace commas' versions, to get around this problem where the user has commas for decimals but the web server uses decimal points. I can do such a version for the latitude and longitude web tags. In this case it would probably be easier to add a parameter "rc=y", eg: <#latitude dp=5 rc=y>. Or, in a similar way to what you've done to convert to lower case, you could you the JavaScript 'replace' function: .replace(",",".") but then it would have to be string.

One thing I don't understand though; as JavaScript runs in the browser, on the client, why doesn't it use the user's settings anyway? Is this just the way JS works? It certainly makes sense to work that way (the way it does).
You're a lifesaver steve! The webtags with that option would work. Can that also be done with in, hPa, and mb barometer readings?

As I said, I am still learning JavaScript, but I think the answer to your question is that it doesn't use non-English settings. With numbers in JavaScript, 1025.5 is not the same as 1025,5. It's like the period is a decimal and the comma is a separator. I guess this is because JavaScript uses 64-bit (8-bytes) base 10 floating point numbers. So any user settings outside of that are not understood I reckon.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 10:23 am
by steve
Buford T. Justice wrote:You're a lifesaver steve! The webtags with that option would work.
OK, I'll add that parameter, it's very easy.
Can that also be done with in, hPa, and mb barometer readings?
Do you mean the <#press> web tag? There's already <#RCpress> for that.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 10:37 am
by Buford T. Justice
steve wrote:
Buford T. Justice wrote:You're a lifesaver steve! The webtags with that option would work.
OK, I'll add that parameter, it's very easy.
Can that also be done with in, hPa, and mb barometer readings?
Do you mean the <#press> web tag? There's already <#RCpress> for that.
So these new ones would be <#RClatitude> and <#RClongitude>?

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 10:43 am
by steve
Buford T. Justice wrote:So these new ones would be <#RClatitude> and <#RClongitude>?
No, as I said, the existing ones would have a new parameter "rc=y". I could do it by adding new "RC" web tags like the others, but that's confusing as the existing web tags are now dual-purpose. The new parameter would only apply if the "dp" parameter had also been specified.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 10:46 am
by Buford T. Justice
steve wrote:
Buford T. Justice wrote:So these new ones would be <#RClatitude> and <#RClongitude>?
No, as I said, the existing ones would have a new parameter "rc=y". I could do it by adding new "RC" web tags like the others, but that's confusing as the existing web tags are now dual-purpose. The new parameter would only apply if the "dp" parameter had also been specified.
Yeah I keep forgetting that. My bad. Thanks for doing this.

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Posted: Thu 09 May 2013 11:21 am
by mcrossley
Buford T. Justice wrote:I have been trying to come up with a JavaScript replace function or charAt function to change commas to periods, but I have not had any luck. I am still tinkering with a solution to this.
You would need something like Steve suggested...

var x = "<#tag>".replace(',','.');

And rely on type conversion to use it as a floating point number, or force it to be numeric with...

var x = parseFloat("<#tag>".replace(',','.'));