Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.0.1 (build 4023) - 16 May 2024

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 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

<#currcond> graphics - DIY

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

Moderator: daj

Post Reply
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

<#currcond> graphics - DIY

Post by beteljuice »

Ok you've heard about the <#currcond> tag in the latest betas, you may even have found out how to display the input box by ticking a box in Configuration / Display :?

So how can you sex it up ?

.. here is a DIY Javascript lesson so that you could add (icon) graphics to your text :shock:

Working for the moment Example

First of all this is designed for working in Templates. ie. processed by Cumulus.

Somewhere to suit in your xxxxT.htm you need something like:

Code: Select all

<p>Observations <script>parse_cond();</script></p>
If we weren't going to do something with it you would simply have:

Code: Select all

<p>Observations <#currcond></p>
Lets get coding :(
In the <HEAD> section of xxxxT.htm lets set up some variable and start defining the function:

Code: Select all

<script type="text/javascript" language="JavaScript">

cond_pic_dir = "curr_weather/icons/"
// cond_time = (<#isdaylight> ? "day_" : "night_");
// if you only want day icons use cond_time = "day_";
cond_time = "day_";

curr_cond = "<#currcond>";


function parse_cond() {
  if(curr_cond) {
// replace any icon 'commands' eg. :FINE:

//  :FINE:
       curr_cond = curr_cond.replace( /:FINE:/g, "<img src = \"" + cond_pic_dir + cond_time + "clear.png\" />");

We have declared a location where our icons are located
We have given the capability of day / night icons (but this has been over ridden to only show day icons)(day icons are prefixed day_ and night icons night_, some icons [fog] have no prefix)

Code: Select all

//  :FINE:
       curr_cond = curr_cond.replace( /:FINE:/g, "<img src = \"" + cond_pic_dir + cond_time + "clear.png\" />");
Declare an 'instruction' to look for, replace the 'instruction' with the html for the graphic.

In this case to use the graphic you would type in your Cumulus conditions box eg. Today has been mostly fine :FINE:

The format of the 'instruction' is :instruction:, you call them anything you want and associate any icon you want.
The code has been written to ensure multiple duplicate icons can be handled.
For a full explanation of replace [RegExp] see http://www.w3schools.com/jsref/jsref_replace.asp

Put in all the 'instructions' you want, then we need to tidy up and finish the function:

Code: Select all

//  :SNOW:
       curr_cond = curr_cond.replace(/:SNOW:/g, "<img src = \"" + cond_pic_dir + cond_time + "snow.png\" />");

  } else { // NO current conditions found

     curr_cond = "N/A";

  } // END if curr_cond
        document.write(curr_cond);
} // END function parse_cond()

</script>
Because in the html I put "Observations " before currcond is inserted I need to cover myself if currcond is 'empty' - so the else statement which will output "N/A", you could remove that or edit to suit.

... and that's it - you're a coder :o

OK, OK here's a zip file with some icons and a chunk of script for insertion in the <HEAD> of your xxxxT.htm, don't forget the html line <p>Observations <script>parse_cond();</script></p>

After that, you're on your own ;)
curr_weather.zip
Please note, because we are processing this with JavaScript do NOT use " (quotes) in your text :bash:
You do not have the required permissions to view the files attached to this post.
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
g6nhy
Posts: 23
Joined: Sun 13 Dec 2009 7:56 am
Weather Station: WH-1080PC
Operating System: Windows XP
Location: Hucknall Nottingham
Contact:

Re: <#currcond> graphics - DIY

Post by g6nhy »

Hi
Thank you for the information, very grateful, will give it try in the morning :D .
rp4111
Posts: 62
Joined: Wed 30 Dec 2009 11:31 pm
Weather Station: Davis VP2
Operating System: Windows XP, Mac OSX
Location: Western Massachusetts, USA
Contact:

Re: <#currcond> graphics - DIY

Post by rp4111 »

Excellent! Thanks for this, beet.
User avatar
g6nhy
Posts: 23
Joined: Sun 13 Dec 2009 7:56 am
Weather Station: WH-1080PC
Operating System: Windows XP
Location: Hucknall Nottingham
Contact:

Re: <#currcond> graphics - DIY

Post by g6nhy »

Thank you BJ all working, just takes my old brain cells a time to work :bash: .
But all working and thanks again, excellent :clap: :clap:
User avatar
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: <#currcond> graphics - DIY

Post by GraemeT »

Before Cumulus I used Virtual Weather Station, which will import data from Metar stations.
If you run VWS in 'stationless' mode you still have access to its Metar importing facility.

We can use the VWS webtag ^climate_cconds1^ to get the current observation from a local Metar station and display it by parsing a Cumulus xxxxT.htm file with VWS before the Cumulus file update. The down-side is more files for Cumulus to process.

There's a bit less work top do if we create a file called, for instance, currentcontitions.htx with just the VWS webtag ^climate_cconds1^ in it.

When VWS parses currentcontitions.htx it substitutes text for the ^climate_cconds1^ tag just as Cumulus does with it's webtags.

The procedure I use is:
1. Set VWS to process currentcontitions.htx into c:\program files\cumulus\currentcontitions.txt
2. Set Cumulus to process cumuluswebtags.txt into cumuluswebtags.php

Below is some php code to show the Metar 'now-cast' along with the Cumulus 'forecast' tags.

<?php
require_once("/cumuluswebtags.php");
Echo "Current Metar Observation: " . $currcond;
Echo "<br />";
Echo "Our Crystal-ball Prediction: " . $forecast;
?>

See the result here: http://weather.gktnet.com/indext.php

The accuracy of this data is, of course, dependent of the Metar site you use.

Thanks Steve for providing a means of supplying Cumulus with data from an external source.
Cheers,
Graeme.
User avatar
GTB
Posts: 75
Joined: Thu 06 Nov 2008 12:14 am
Weather Station: ws1081 with Cumulus
Operating System: win 2000
Location: Terrigal NSW
Contact:

Re: <#currcond> graphics - DIY

Post by GTB »

Thankyou beteljuice

took me awhile to get it right

but it now works a treat

now if i can only remember what all the conditions are when i am putting the observations in

geoff
Image
Post Reply