Author Topic: WU Sky Condition Icons (Day and Night)  (Read 4979 times)

0 Members and 1 Guest are viewing this topic.

Offline Impala88

  • Senior Contributor
  • ****
  • Posts: 195
    • IrvineWx
WU Sky Condition Icons (Day and Night)
« on: April 16, 2009, 02:46:24 AM »
The current USA.htx template provided by VWS has a sky condition icon that features a smiley sun, whether or not it was daytime.


In the old Ambient forum, there was a thread about having the WUnderground provided condition icons change from daytime to nighttime, depending on local sunrise/sunset times.  There was a java script forumula presented which worked perfectly.  Does anyone recall this and perhaps have a copy of the script? 

On another note, does anyone know if there is a way you can also use the new WU icon selections in place of the smileys?

http://www.wunderground.com/member/membersettings.html?page=icons

Offline mackbig

  • Forecaster
  • *****
  • Posts: 4128
    • Mackie's Main Street, Unionville, ON Canada Weather
Re: WU Sky Condition Icons (Day and Night)
« Reply #1 on: April 16, 2009, 07:13:02 AM »
hmmm?  I thought it showed the nightime image on mine without any modifications. However the sun was already up when I read this, so cant confirm???

by the way, this page has all the conditions icons...currently used by vws
http://icons.wunderground.com/graphics/conds/

The current USA.htx template provided by VWS has a sky condition icon that features a smiley sun, whether or not it was daytime.


In the old Ambient forum, there was a thread about having the WUnderground provided condition icons change from daytime to nighttime, depending on local sunrise/sunset times.  There was a java script forumula presented which worked perfectly.  Does anyone recall this and perhaps have a copy of the script? 


Using the new icons would be easy to do, assuming one factor, the new icons used the same GIF naming convention....clear.gif, sunny.gif rain.gif etc....

The current template has this line of code.
Code: [Select]
http://icons.wunderground.com/graphics/conds/^climate_icon1^.GIF
the ^climate_icon1^ tag is changed by vws depending on your conditions.

So to do what you want, simply change this
Code: [Select]
http://icons.wunderground.com/graphics/conds/^climate_icon1^.GIFto
Code: [Select]
http://icons-pe.wxug.com/i/c/e/^climate_icon1^.GIFor
Code: [Select]
http://icons-pe.wxug.com/i/c/h/^climate_icon1^.GIFor
Code: [Select]
http://icons-pe.wxug.com/i/c/a/^climate_icon1^.GIF
Andrew


On another note, does anyone know if there is a way you can also use the new WU icon selections in place of the smileys?

http://www.wunderground.com/member/membersettings.html?page=icons

Andrew - Davis VP2+ 6163, serial weatherlink, wireless anemometer, running Weather Display.  Boltek PCI Stormtracker, Astrogenic Nexstorm, Strikestar - UNI, CWOP CW8618, GrLevel3, (Station 2 OS WMR968, VWS 13.01p09), Windows 7-64

Offline LeomaTNWX

  • Senior Contributor
  • ****
  • Posts: 271
    • Leoma, Tn Weather
Re: WU Sky Condition Icons (Day and Night)
« Reply #2 on: April 16, 2009, 10:18:55 AM »
On the same note. I would like to use the NOAA pics for my 5 day forcast but I am getting confused on what to add to make it work.

Offline kray1000

  • Purveyor of wry
  • Forecaster
  • *****
  • Posts: 1336
    • http://www.roanokevalleyweather.com
Re: WU Sky Condition Icons (Day and Night)
« Reply #3 on: April 16, 2009, 10:29:31 AM »
The current USA.htx template provided by VWS has a sky condition icon that features a smiley sun, whether or not it was daytime.


In the old Ambient forum, there was a thread about having the WUnderground provided condition icons change from daytime to nighttime, depending on local sunrise/sunset times.  There was a java script forumula presented which worked perfectly.  Does anyone recall this and perhaps have a copy of the script?  

Here you go.  Obviously you'll need to change the locations of the icons (please) in two places near the bottom of the script.  The names of the files may need to be changed also, depending on what icon set you'll use.

Code: [Select]
<script type="text/javascript" language="javascript">
                    <!--
                      var time = "^vst143^";
                      var sunrise = "^vst144^";
                      var sunset = "^vst145^";
                      
                      var timetime = miltime(time);
                      var sunrisetime = miltime(sunrise);
                      var sunsettime = miltime(sunset);
                                                
                      if (timetime > sunrisetime && timetime < sunsettime) {  
                        document.write('<img src="http://www.roanokevalleyweather.com/weathericons/^climate_icon1^.gif"');
                      }
                      else {
                        document.write('<img src="http://www.roanokevalleyweather.com/weathericons/nt_^climate_icon1^.gif"');
                      }
                    -->
                    </script>

EDIT: This part goes in the <head> section:
Code: [Select]
<script type="text/javascript" language="javascript">
<!--
function miltime(timex)
{
  var timex = timex.split(":",2);
  var timexhr = timex[0];
  var timexhr = Number(timexhr); // convert timexhr from string to integer
  var timexmin = timex[1].substring(0,2);
 
  // convert time to military time if necessary
  if ((timex[1].indexOf('pm') > 0) && (timexhr != 12)) {
    timexhr = timexhr + 12;
  }
  else {
    if ((timex[1].indexOf('am') > 0) && (timexhr == 12)) {
      timexhr = 0;
    }
  }
  return Number(timexhr+timexmin);
} //end function miltime
//-->
</script>
« Last Edit: January 14, 2011, 08:37:49 PM by kray1000 »

Offline Impala88

  • Senior Contributor
  • ****
  • Posts: 195
    • IrvineWx
Re: WU Sky Condition Icons (Day and Night)
« Reply #4 on: April 16, 2009, 09:31:22 PM »
Thank you, kray1000, that is perfect!

Offline TemescalCoyote

  • Member
  • *
  • Posts: 1
Re: WU Sky Condition Icons (Day and Night)
« Reply #5 on: November 03, 2010, 02:19:07 PM »
Hi, this seems to work for the two hours before or after sunrise/sunset.  After sunset the icon goes back to the day icon.  Did I do it wrong?

Offline kray1000

  • Purveyor of wry
  • Forecaster
  • *****
  • Posts: 1336
    • http://www.roanokevalleyweather.com
Re: WU Sky Condition Icons (Day and Night)
« Reply #6 on: November 03, 2010, 04:54:32 PM »
Hi, this seems to work for the two hours before or after sunrise/sunset.  After sunset the icon goes back to the day icon.  Did I do it wrong?

First thing I'd check are your latitude and longitude settings.  If you're in the western hemisphere, the longitude should be negative.

Offline Impala88

  • Senior Contributor
  • ****
  • Posts: 195
    • IrvineWx
Re: WU Sky Condition Icons (Day and Night)
« Reply #7 on: January 14, 2011, 10:58:16 AM »
Hello, me again.   :?  

I had used your JavaScript and it worked perfectly; however, soon after I used it, I was able to access the NOAA metar observations and resumed using my old .htx file.  I had thought I had saved the .htx file which had the day/night formula, but I am unable to locate it.

As I have stated in another thread, I again started having a problem with retrieving NOAA metars.  I switched over to Hamweather, but the data is available about 35 minutes later, which is not acceptable.

I again copied and pasted the script, using "http://icons-ecast.wxug.com/i/c/a/^climate_icon1^.gif" and "http://icons-ecast.wxug.com/i/c/a/^nt_climate_icon1^.gif" in place of  the roanokevalleyweather.com icons, but got a blank space.  I tried placing quotes before and after miltime(sunrise) and miltime (sunset):

var timetime = "miltime(time)";
                      var sunrisetime = "miltime(sunrise)";
                      var sunsettime = "miltime(sunset)";

...which made the icon appear.  However, it was only the day icon that would appear.  I even tried using the "nt_" icon in both instances but the day icon would show all of the time, even at night. :-#


I tried using the roanokevalleyweather.com icons (with the quotes in the miltime areas still in place) and it worked like it was supposed to.  

I don't recall having this problem before.  Did something change at WUnderground or is this computer possessed?   :evil:

I am using www.irvineweather.net/beta.htm  on this project.
« Last Edit: January 14, 2011, 11:15:38 AM by Impala88 »

Offline kray1000

  • Purveyor of wry
  • Forecaster
  • *****
  • Posts: 1336
    • http://www.roanokevalleyweather.com
Re: WU Sky Condition Icons (Day and Night)
« Reply #8 on: January 14, 2011, 08:40:00 PM »
There is another part of the script I didn't post previously (except on the old Ambient forum).

This needs to be in the <head></head> section.

Code: [Select]
<script type="text/javascript" language="javascript">
<!--
function miltime(timex)
{
  var timex = timex.split(":",2);
  var timexhr = timex[0];
  var timexhr = Number(timexhr); // convert timexhr from string to integer
  var timexmin = timex[1].substring(0,2);
  
  // convert time to military time if necessary
  if ((timex[1].indexOf('pm') > 0) && (timexhr != 12)) {
    timexhr = timexhr + 12;
  }
  else {
    if ((timex[1].indexOf('am') > 0) && (timexhr == 12)) {
      timexhr = 0;
    }
  }
  return Number(timexhr+timexmin);
} //end function miltime
//-->
</script>

Try that and see if that works.
« Last Edit: January 14, 2011, 08:41:44 PM by kray1000 »

Offline Impala88

  • Senior Contributor
  • ****
  • Posts: 195
    • IrvineWx
Re: WU Sky Condition Icons (Day and Night)
« Reply #9 on: January 15, 2011, 10:02:06 AM »
Yes!  :grin: That's it!  It all works now!  Thank you once again!  =D&gt;

 

anything