Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See the Wiki for download

BT's Global Sager Weathercaster PHP Scripts For Cumulus

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 1:50 am

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".

User avatar
Werk_AG
Posts: 182
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Werk_AG » Thu May 09, 2013 2:07 am

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();
Image

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 2:31 am

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.

User avatar
Werk_AG
Posts: 182
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Werk_AG » Thu May 09, 2013 2:53 am

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
Last edited by Werk_AG on Thu May 09, 2013 3:04 am, edited 2 times in total.
Image

User avatar
Werk_AG
Posts: 182
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Werk_AG » Thu May 09, 2013 3:01 am

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.
Image

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 3:13 am

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?

User avatar
Werk_AG
Posts: 182
Joined: Sun Jan 13, 2013 8:04 pm
Weather Station: WeatherDuino Pro2
Operating System: Windows 7
Location: Cercal CDV - Portugal

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Werk_AG » Thu May 09, 2013 3:30 am

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 :)
Image

User avatar
robynfali
Posts: 1075
Joined: Sat Jul 31, 2010 10:34 pm
Weather Station: Fine Offset
Operating System: Windows XP
Location: Anglesey, North Wales, UK
Contact:

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by robynfali » Thu May 09, 2013 6:24 am

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

User avatar
steve
Cumulus Author
Posts: 26713
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by steve » Thu May 09, 2013 7:10 am

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).
Steve

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 10:02 am

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.

User avatar
steve
Cumulus Author
Posts: 26713
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by steve » Thu May 09, 2013 10:23 am

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.
Steve

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 10:37 am

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>?

User avatar
steve
Cumulus Author
Posts: 26713
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by steve » Thu May 09, 2013 10:43 am

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.
Steve

User avatar
Buford T. Justice
Posts: 385
Joined: Fri Aug 17, 2012 9:21 pm
Weather Station: Ambient Weather WS-2902A
Operating System: Windows 10 Pro 64-bit
Location: USA

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by Buford T. Justice » Thu May 09, 2013 10:46 am

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.

User avatar
mcrossley
Posts: 5209
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: BT's Global Sager Weathercaster JavaScripts For Cumulus

Post by mcrossley » Thu May 09, 2013 11:21 am

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(',','.'));

Post Reply