Welcome to the Cumulus Support forum.
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024
Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024
Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)
Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki
Trend arrow Javascript
Moderator: daj
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Trend arrow Javascript
Hi !! I need help with this JavaScript indicating the temperature trend arrow (Up or down)
<td><#temp> <#tempunit><script type="text/javascript">
var temp = "<#temptrend>";
if (temp=="0"){var imagen = "steady.bmp";}
if (temp>"0"){var imagen = "up.bmp";}
if (temp<"0"){var imagen = "down.bmp";}
document.write('<img src="http://arecoclima.com.ar/xxxxx/'+imagen+'"/>');
</script></td>
When trend is 0: is correct arrow steady and similar when trend is negative.(arrow down)
But when the trend is positive (example +1.2) continuous with the down arrow. Where I have the error?
Many thanks,
Mauricio
<td><#temp> <#tempunit><script type="text/javascript">
var temp = "<#temptrend>";
if (temp=="0"){var imagen = "steady.bmp";}
if (temp>"0"){var imagen = "up.bmp";}
if (temp<"0"){var imagen = "down.bmp";}
document.write('<img src="http://arecoclima.com.ar/xxxxx/'+imagen+'"/>');
</script></td>
When trend is 0: is correct arrow steady and similar when trend is negative.(arrow down)
But when the trend is positive (example +1.2) continuous with the down arrow. Where I have the error?
Many thanks,
Mauricio
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
- steve
- Cumulus Author
- Posts: 26701
- Joined: Mon 02 Jun 2008 6:49 pm
- Weather Station: None
- Operating System: None
- Location: Vienne, France
- Contact:
Re: Trend arrow Javascript
I think the problem is that you are comparing strings, not numbers. I think you need:
Code: Select all
var temp = <#temptrend>;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
Steve
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Re: Trend arrow Javascript
Steve if I remove the quotes 0 instead of "0" continues the problem.
You do not have the required permissions to view the files attached to this post.
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
- steve
- Cumulus Author
- Posts: 26701
- Joined: Mon 02 Jun 2008 6:49 pm
- Weather Station: None
- Operating System: None
- Location: Vienne, France
- Contact:
Re: Trend arrow Javascript
Can you show me the page where you have this code?
I took a copy of your current page at http://arecoclima.com.ar/, which had this code in it:
I edited the code to this:
And I got this:
I edited it to this:
And I got this:
I edited it to this:
And I got this:
I took a copy of your current page at http://arecoclima.com.ar/, which had this code in it:
Code: Select all
var temp = "+1.3";
if (temp=="0"){var imagen = "steady.bmp";}
if (temp<"0"){var imagen = "up.bmp";}
if (temp>"0"){var imagen = "down.bmp";}
Code: Select all
var temp = 0;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
Code: Select all
var temp = +1.3;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
Code: Select all
var temp = -1.3;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
You do not have the required permissions to view the files attached to this post.
Steve
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Re: Trend arrow Javascript
Steve: The page is http://www.arecoclima.com.ar/index.htm and the current code is:
var temp = "<#temptrend>";
if (temp=="0"){var imagen = "steady.bmp";}
if (temp<"0"){var imagen = "up.bmp";}
if (temp>"0"){var imagen = "down.bmp";}
But in this case by lowering the trend continues up arrow.
Now I change if (temp > "0") for if (temp<" 0 ") so that the arrow goes up, but this sunset when the negative trend is continue the arrow up and I have to modify the code again.
Thanks.
var temp = "<#temptrend>";
if (temp=="0"){var imagen = "steady.bmp";}
if (temp<"0"){var imagen = "up.bmp";}
if (temp>"0"){var imagen = "down.bmp";}
But in this case by lowering the trend continues up arrow.
Now I change if (temp > "0") for if (temp<" 0 ") so that the arrow goes up, but this sunset when the negative trend is continue the arrow up and I have to modify the code again.
Thanks.
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
- steve
- Cumulus Author
- Posts: 26701
- Joined: Mon 02 Jun 2008 6:49 pm
- Weather Station: None
- Operating System: None
- Location: Vienne, France
- Contact:
Re: Trend arrow Javascript
I don't understand; you said you had removed the quotes as I suggested, but they are still there. The code you need, which I have tested in all three situations, is in my first reply.
Steve
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Re: Trend arrow Javascript
Steve: Now add your code without quotes and without quotes in <#temptrend>.
var temp = <#temptrend>;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
And update to the site Ok.
I'll try it this afternoon with the temperature down if it responds.
Thank for you help !!!
var temp = <#temptrend>;
if (temp==0){var imagen = "steady.bmp";}
if (temp>0){var imagen = "up.bmp";}
if (temp<0){var imagen = "down.bmp";}
And update to the site Ok.
I'll try it this afternoon with the temperature down if it responds.
Thank for you help !!!
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Re: Trend arrow Javascript
Steve, now with trend steady and down, update Ok.
Many Thanks!!
Many Thanks!!
You do not have the required permissions to view the files attached to this post.
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
-
- Posts: 52
- Joined: Sat 28 Nov 2009 9:57 am
- Weather Station: W1081
- Operating System: Windows 7
- Location: New Zealand
- Contact:
Re: Trend arrow Javascript
I did my trends something like this:
E.G. Wind:
And for those that are calculated by Cumulus software, something very simple like this:
So of course I named my arrows "Rising" "Falling" and "Steady". Works well for me. Will soon be introducing wind direction arrows based upon the latter principal.
Someone will probably find holes in what I have done but seems okay to me.
E.G. Wind:
Code: Select all
<script type="text/javascript">
var windaverage = *VALUE*;
var windlatest = *VALUE*;
if (windlatest>windaverage)
document.write('<img src="dbimages/risingarrow.gif" width="7px" height="7px" align="absmiddle" border="0" alt="Current trend is " title="Current trend is rising" />');
else if (windlatest<windaverage)
document.write('<img src="dbimages/fallingarrow.gif" width="7px" height="7px" align="absmiddle" border="0" alt="Current trend is " title="Current trend is falling" />');
else
document.write('<img src="dbimages/steadyarrow.gif" width="7px" height="7px" align="absmiddle" border="0" alt="Current trend is " title="Current trend is steady" />');
</script>
Code: Select all
<img src="dbimages/<#temptrendenglish>arrow.gif" width="7px" height="7px" align="baseline" border="0" alt="Current trend is <#temptrendtext>" title="Current trend is <#temptrendtext>" />
Someone will probably find holes in what I have done but seems okay to me.
- GraemeT
- Posts: 312
- Joined: Wed 21 Oct 2009 11:19 am
- Weather Station: La Crosse WS-2355 & WS-2306
- Operating System: Windoze 7, 10, 11
- Location: Bayswater, Australia
- Contact:
Re: Trend arrow Javascript
I just thought I'd muscle in with my bit, too.
Not much good with javascript, so here's the php code I use:
The same structure is used to show pressure trend.
...I wonder how many different ways there are of achieving a result...
Not much good with javascript, so here's the php code I use:
Code: Select all
....html
<?php if ($temptrendenglish == 'Rising') echo '<img src="images/trendup.png" alt="" />';
else if ($temptrendenglish == 'Falling') echo '<img src="images/trenddn.png" alt="" />';
else echo '<img src="images/steady.png" alt="" />'; ?>
more html...
...I wonder how many different ways there are of achieving a result...
Cheers,
Graeme.
Graeme.
-
- Posts: 102
- Joined: Sun 05 Oct 2008 2:13 pm
- Weather Station: WH-1081
- Operating System: Windows XP
- Location: San Antonio de Areco-Buenos Aires - Argentina
- Contact:
Re: Trend arrow Javascript
This is my final work, thank you all!! www.arecoclima.com.ar
Mauricio
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
----------------------------------------------------------------------------------------
http://www.arecoclima.com.ar
-
- Posts: 5
- Joined: Tue 09 Nov 2010 10:38 am
- Weather Station: Davis Vantage Pro 2
- Operating System: Win Seven
Re: Trend arrow Javascript
Impossible to manage it... I try everything (I think...) Can you ,please, tell me what am I doing wrong???
Here is my page... http://www.corsair.gr/wxpage/lc3600.html
Here is my page... http://www.corsair.gr/wxpage/lc3600.html
- steve
- Cumulus Author
- Posts: 26701
- Joined: Mon 02 Jun 2008 6:49 pm
- Weather Station: None
- Operating System: None
- Location: Vienne, France
- Contact:
Re: Trend arrow Javascript
It's the 'comma' decimal separator which Javascript doesn't understand. You can use the web tags which replace the comma with a decimal point, which are there for this purpose. There may be ways of getting Javascript to understand the commas; I don't know.corsair wrote:Impossible to manage it... I try everything (I think...) Can you ,please, tell me what am I doing wrong???
Steve