cloudy

Author Topic: Javascript advisory scroll  (Read 31812 times)

0 Members and 4 Guests are viewing this topic.

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Javascript advisory scroll
« on: January 31, 2005, 11:44:21 PM »
NorCal Dan was asking about this code and I thought I'd make it it's own thread.

The code is actually very very simple. This simply inserts HTML code anywhere on a custom page if the NOAAEvent custom tag is anything but "NO CURRENT ADVISORIES". The idea behind this is that there is no need to post an advisory that says "no advisory".

The code I use is below. It uses the MARQUEE tag to scroll the warning so the webpage does not pause to load Java.

Insert it wherever you want the code to appear on your page or pages. It really gives a professional feel to the advisories. I credit www.weather.com with the idea. They do the exact same thing.

Also, for those wanting to use this in WD, here is the setup guide for the NOAA Warnings...

NOAA Warning Setup
« Last Edit: November 05, 2005, 02:41:53 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #1 on: January 31, 2005, 11:48:23 PM »
No advisory...

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #2 on: January 31, 2005, 11:48:48 PM »
Advisory...

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline lknweather

  • Posts: 183
  • Lake Norman, NC, US
    • lknweather
Re: Javascript advisory scroll
« Reply #3 on: February 01, 2005, 04:07:35 AM »
Carterlake...Thanks for the code, I have managed to add it to my website. I do have a question though...

I was looking at your Hazard page (wx4) and saw that you have the Hazard Outlook text at the bottom. I was able to figure out how to get that onto a page that I have made and had WD process into html.  I assume that you are using the HTTP Download to download the text file from NWS. I found the correct file and set the HTTP Download screen up to get it, but it downloaded the first file and now each additional file is being saved with a .TXT2 then .TXT3, then .TXT4, etc.

I can not find an option to just overwrite the file with the latest downloaded. What am I missing?

Thanks again,

Chad

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #4 on: February 01, 2005, 12:06:26 PM »
Carterlake...Thanks for the code, I have managed to add it to my website. I do have a question though...

I was looking at your Hazard page (wx4) and saw that you have the Hazard Outlook text at the bottom. I was able to figure out how to get that onto a page that I have made and had WD process into html.  I assume that you are using the HTTP Download to download the text file from NWS. I found the correct file and set the HTTP Download screen up to get it, but it downloaded the first file and now each additional file is being saved with a .TXT2 then .TXT3, then .TXT4, etc.

I can not find an option to just overwrite the file with the latest downloaded. What am I missing?

Thanks again,

Chad

Mine makes a couple of those as well...  8O I just ignore them.  :D

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #5 on: February 10, 2005, 01:26:34 AM »
Here's a somewhat more advanced version of the same scroll script. It has more customizable options in the variables and changes the background and font colors based on the type of advisory being displayed.

<script type="text/javascript">
<!--
var warning = "%NOAAEvent%".toUpperCase();
var width = "550";
var mylocation = "CARTER LAKE, IOWA";
var link = "wx4.html";
var watchcolor = "#FFCC66"; <!-- Background color for watches //-->
var watchfont = "#0000FF"; <!-- Font color for watches //-->
var warningcolor = "#FF3333"; <!-- Background color for warnings //-->
var warningfont = "#FFFFFF"; <!-- Font color for warnings //-->
var defaultcolor = "#F0E68C"; <!-- Default background color //-->
var defaultfont = "#0000FF"; <!-- Default font color //-->
if (warning != "NO CURRENT ADVISORIES") {
       if (warning.indexOf("WATCH") > 0) {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + watchcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='1' color='" + watchfont + "'>" + mylocation + " - <b><span style='text-transform: uppercase'>%NOAAEvent%</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
   else if (warning.indexOf("WARNING") > 0) {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + warningcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='1' color='" + warningfont + "'>" + mylocation + " - <b><span style='text-transform: uppercase'>%NOAAEvent%</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
   else {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + defaultcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='1' color='" + defaultfont + "'>" + mylocation + " - <b><span style='text-transform: uppercase'>%NOAAEvent%</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
}
//-->
</script>


(Minor bug fixes listed in red since code was originally posted.)
« Last Edit: March 06, 2005, 02:38:03 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,233
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Javascript advisory scroll
« Reply #6 on: March 01, 2005, 12:25:18 PM »
carterlake,

I just wanted to point out that the "Enhanced - Bigger and Better" scroll script breaks in Firefox, works Ok in IE, It was choking on:

" + location + " -

Kept trying to add the entry for Location, JACKSONVILLE,%20FL, to the end of the URL...

Here is a test page with the broken script running.

http://www.JaxWeather.net/WeatherImages/WD/wx9.html

I simply removed the three instances of " + location + " and hard coded Jacksonville, Fl to fix...

The running instance can be seen here:
http://www.jaxquest.com/WeatherImages/WD/wx7.html

By the way thanks for these scripts :)

-Bob

Offline TomTc

  • Posts: 400
  • Granada Hills, CA, USA
    • The Tcimpidis Weather Station
Re: Javascript advisory scroll
« Reply #7 on: March 01, 2005, 02:03:35 PM »
Perhaps Brian can add this to WD in place of the Weather Alert default web page code he is presently using...  He needs to make the No Advisory variable customizable though since NOAA here uses a different string for no advisories in my location than "No Advisory" and thus it does not work properly for me...

Tom
« Last Edit: March 09, 2005, 01:37:32 PM by Tom T »

Offline Weather Display

  • Posts: 64,529
Re: Javascript advisory scroll
« Reply #8 on: March 01, 2005, 04:59:43 PM »
i could have as option to have on web page.,.,
so what is the coding needed?
what is here on this thread, less the +location+
?

Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,233
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Javascript advisory scroll
« Reply #9 on: March 01, 2005, 05:54:48 PM »
The code that carterlake posted here:
http://www.weather-watch.com/smf/index.php/topic,7508.msg52321.html#msg52321

Unless he (or someone who knows more than I do) can post a correction for the "location" entry then removing...

var location = "CARTER LAKE, IOWA";
and
three instances of: " + location + " -

would allow the script to work in IE and FF...

However the addition of a WD tag that pulled the Station Name (if there isn't already one) into the areas where the " + location + " - was removed would be a nice touch...

Code: [Select]
<font face='verdana,arial' size='1' color='" + warningfont + "'>%stationnametag% - <b>
And then if nothing is edited by hand it would at least have some identification.  And for those that want they could probably hard code something else if they wanted?

-Bob

Offline Weather Display

  • Posts: 64,529
Re: Javascript advisory scroll
« Reply #10 on: March 01, 2005, 07:36:52 PM »
uploading a new 10.23 zip now with this in it

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #11 on: March 01, 2005, 10:22:48 PM »
carterlake,

I just wanted to point out that the "Enhanced - Bigger and Better" scroll script breaks in Firefox, works Ok in IE, It was choking on:

" + location + " -

Kept trying to add the entry for Location, JACKSONVILLE,%20FL, to the end of the URL...

Here is a test page with the broken script running.

http://www.JaxWeather.net/WeatherImages/WD/wx9.html

I simply removed the three instances of " + location + " and hard coded Jacksonville, Fl to fix...

The running instance can be seen here:
http://www.jaxquest.com/WeatherImages/WD/wx7.html

By the way thanks for these scripts :)

-Bob

Hum.... I think there is something wrong with your HTML. I get this kind of broken page when I do things like <br. instead of <br>
« Last Edit: March 01, 2005, 10:26:20 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,233
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Javascript advisory scroll
« Reply #12 on: March 01, 2005, 10:39:26 PM »
The only change in the two files is one has the 'var location =' and ' " + location + " ' removed...

This is the code actually contained in wx9.html...
Code: [Select]
<script type="text/javascript">
<!--
var warning = "FLOOD WARNING";
var width = "550";
var location = "JACKSONVILLE, FL";
var link = "http://JaxWeather.net/JaxWeatherWarning.php";
var watchcolor = "#008080"; <!-- Background color for watches //-->
var watchfont = "#1CE6E6"; <!-- Font color for watches //-->
var warningcolor = "#FF3333"; <!-- Background color for warnings //-->
var warningfont = "#FFFFFF"; <!-- Font color for warnings //-->
var defaultcolor = "#FFFFFF"; <!-- Default background color //-->
var defaultfont = "#0000FF"; <!-- Default font color //-->
if (warning != "NO CURRENT ADVISORIES") {
       if (warning.indexOf("WATCH") > 0) {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + watchcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='2' color='" + watchfont + "'>Jacksonville, FL - <b><span style='text-transform: uppercase'>FLOOD WARNING</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
   else if (warning.indexOf("WARNING") > 0) {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + warningcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='22' color='" + warningfont + "'>Jacksonville, FL - <b><span style='text-transform: uppercase'>FLOOD WARNING</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
   else {
       document.write("<table border='1' cellpadding='2' cellspacing='0' width=" + width + " bgcolor='" + defaultcolor + "'><tr><td><marquee scrolldelay='125' width='" + width + "'><a href='" + link + "'><font face='verdana,arial' size='2' color='" + defaultfont + "'>Jacksonville, FL - <b><span style='text-transform: uppercase'>FLOOD WARNING</span></b> ... [Click here for more]</marquee></font></a></td></tr></table><br>");
   }
}
//-->
</script>

Removing just that block allows the page to work...  Placing it back breaks it again in FF? 
If I mucked something above up please let me know  LOL

-Bob

Offline carterlake

  • Tom Chaplin
  • Posts: 2,273
  • Carter Lake, Iowa USA
    • Carter Lake, Iowa Weather
Re: Javascript advisory scroll
« Reply #13 on: March 01, 2005, 10:44:26 PM »
Well, what do you know.... Firefox doesn't like the variable "location"

Fixed. See above for latest code.
« Last Edit: March 06, 2005, 02:34:33 PM by carterlake »

WD; Davis VP2 6153; Quickcam for Notebooks Pro; Boltek w/ Nexstorm; GRLevel3; Live NOAA radio

Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,233
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Javascript advisory scroll
« Reply #14 on: March 01, 2005, 10:56:28 PM »
Updated and confirmed...
http://JaxWeather.net/WeatherImages/WD/wx9.html

I changed the color in the warning fields just as a sanity test for myself :)

Thanks carterlake and now if we can figure out how to get the "Right" warnings and alerts called by %NOAAEvent% the world will be good for a few moments :)

Thanks again,
Bob

 

cumulus