Guys:
I found a great new Weather Script on the net. It’s actually a Universal PHP RSS Reader that I configured to read the NOAA Alerts RSS Feed, but it can be configured for any weather related RSS feed (or non-weather related, of course).
There are two versions of the Script and you can try both at the same time. As I configured it (see below), the first Script, (“pscroller1”), will vertically scroll the RSS “Items” for a given NWS Zone, in my case, MDZ006. You can easily change the zone by simply copying the URL for the RSS for your zone by finding the URL at NWS Public Alerts in XML/CAP v1.1 and ATOM Formats - NOAA's National Weather Service and then configuring the PHP setup pages that come with the Script. So for this script, I get the headlines “Severe Thunder Storm Warning”, 'Special Weather Statement", etc. for my zone, and that’s it (no Description), but they scroll very cleanly and “snappy” one at a time in the display box. It’s very neat.
The second Script, (“pscroller2”), will vertically scroll the RSS “Item” and “Description” for a given NWS Zone. So for this script, I get the headlines and the descriptions / text for the “Severe Thunder Storm Warning”, 'Special Weather Statement", etc. The ‘rub’ is that they scroll one at a time - and PAUSE for each one for a configurable time - in the display box. It’s VERY neat.
Here is the script:
http://www.dynamicdrive.com/dynamicindex17/rsspausescroller/index.htm
Here are the instructions:
-
Download the zip file on that web page.
-
Follow the instructions step by step - carefully - on that web page. Be sure to put ALL the zipped files and sub-directories in the same directory in your webserver. In other words, There is one HTM page (“demo.htm”) and one file (“rsspausescroller.js”) that you place in your webserver directory, but you also place the subdirectory (“lastrss”), just like it is, in the same webserver directory. That subfolder has two PHP pages and an additional cache subfolder which will copy over when you place the files in your webserver.
-
Load up the demo.htm and be sure it works properly. If it does not, check the directions on the web page above again. It worked for me the first time.
-
OK, so now you see how it works and you need to configure it for NOAA RSS. Go here: NWS Public Alerts in XML/CAP v1.1 and ATOM Formats - NOAA's National Weather Service and then in the THIRD column where it says “RSS ‘By County/Zone’” you click the orange XML button for your state. Next, click on your county. When the RSS feed displays in your browser, highlight and copy the URL link.
-
Back at your webserver, edit the PHP file “scrollerbridge.php” in the “lastrss” subdirectory.
-
You will see some code that looks like this:
// Define your list of RSS URLs- "RSS_id"=> "URL to RSS feed"
$rsslist=array(
"cnn" => "http://rss.cnn.com/rss/cnn_topstories.rss",
"bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
"news.com" => "http://news.com.com/2547-1_3-0-5.xml",
"slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
"dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new",
"WJZ" => "http://wjz.com/localbriefs/resources_genericrss.xml",
"NOAA" => "http://www.weather.gov/alerts/wwarssget.php?zone=WIZ046",
);
Notice the last line I added that starts “NOAA”. You need to add this line, and insert the URL you copied as a replacement to what I inserted. Remember to add the comma after the last quote. Now close that page. You’re done. You do not need to edit the other PHP file called “lastRSS.php”.
- Now go to the “demo.htm” page that come with the script and edit that page. You will find this code at the end of that page:
new rsspausescroller("NOAA", "pscroller1", "rssclass", 3000, "_new")
document.write("
") //add a divider for demo
new rsspausescroller("NOAA", "pscroller2", "rssclass", 3000, "", "date+description")
See how I adjusted the RSS feed to “NOAA” instead of whatever they had there (I think it was cnn)? Well, change this to NOAA. This now pulls the feed from what you just set up in “scrollerbridge.php”.
-
Open up “demo.htm” in your browser. If there are no alerts for your area, I would suggest going back to Current Watches, Warnings and Advisories for the United States Issued by the National Weather Service and looking at our fine country, and work backwards to find some juicy warnings and watches and select that zone temporarily. I have gotten fairly good at this because warnings and watches change and can suddenly drop when the warning is over. Go back to “scrollerbridge.php” and just substitute the zone number (the rest of the URL stays the same) so you can see the script in action.
-
COOL, eh? But wait… there’s a problem. That is why I took the time to post this.
If you look at the Script (that shows the RSS “Description”), i.e., the second script, you will notice that it displays like this:
`
PROVIDENCE COUNTY IN RHODE ISLAND
SOUTHERN NORFOLK COUNTY IN EASTERN MASSACHUSETTS
THIS INCLUDES THE CITY OF FRANKLIN
-
UNTIL 145 PM EDT
-
AT 755 AM EDT RADAR INDICATES HEAVY RAIN WILL CONTINUE THROUGH AT
LEAST NOON BEFORE DIMINISHING BETWEEN 1 AND 4 PM. RAINFALL
OVERNIGHT ENDING AT 730 AM HAS AVERAGED 1 TO 2 INCHES ACROSS MUCH
OF PROVIDENCE COUNTY RHODE ISLAND AND SOUTHERN NORFOLK COUNTY. -
HEAVIEST RAIN SO FAR HAS OCCURRED FROM FOXBOROUGH TO PLAINVILLE
MASSACHUSETTS TO CUMBERLAND…LINCOLN…SMITHFIELD…WOONSOCKET
AND NORTH PROVIDENCE. -
THE HEAVY RAIN WILL CAUSE WIDESPREAD POOR DRAINAGE AND BASEMENT
FLOODING BY LATE THIS MORNING WITH SEVERAL STREAMS EXPECTED TO
RIDE OUT OF THEIR BANKS DURING MIDDAY. -
THE BLACKSTONE AND NORTH BRANCH OF THE PAWTUXET RIVERS WILL BE
RISING RAPIDLY DURING MIDDAY AND THIS AFTERNOON…THREATENING TO
FLOOD. -
ROAD CLOSURES MAY OCCUR BY LATE MORNING. IF ROADS BECOME
IMPASSABLE…DONT DRIVE AROUND BARRICADES. IT COULD BECOME
LIFE THREATENING. -
STORM TOTAL RAINFALL BY NOON IN PORTIONS OF NORFOLK AND
PROVIDENCE COUNTIES WILL PROBABLY EXCEED 4 INCHES…WITH 6 INCH
TOTALS POSSIBLE.
A FLOOD WARNING MEANS THAT FLOODING IS IMMINENT OR HAS BEEN REPORTED.
STREAM RISES WILL BE SLOW AND FLASH FLOODING IS NOT EXPECTED.
HOWEVER…ALL INTERESTED PARTIES SHOULD TAKE NECESSARY PRECAUTIONS
IMMEDIATELY.
LAT…LON 4177 7178 4176 7145 4197 7141 4210 7107
4218 7132 4199 7149 4198 7178
$$
DRAG
Issuing Weather Forecast Office HomepageFlood Watch - Southeast Providence (Rhode Island)
Dec 31, 1969 7:00:00 PM
`
Notice how this script is not ‘reading’ the line breaks in the RSS feed but just displaying the html instead? I want to make the script display the results better, i.e., literally enforce the line breaks or instead remove that html and have it flow better. Ideally, I want it to display just like it does with the “
” html command…or the way it does when you read the page over IWIN, etc. so it looks ‘normal’ as I am used too the way I normally read it on the net.So I AM NOT a PHP guy. I only tinker. After hours of bs-ing around to tinker with the script, I managed to get some progress - but then hit a dead end. At the end of the “scrollerbridge.php” page, I found this code:
function slas**t($what){ //Encode text for storing in JavaScript array $newstring=str_replace(''', '\'', $what); //replace those half valid apostrophe entities with actual apostrophes return rawurlencode($newstring);
I replaced that middle line (sloppy…but as a test and then ill add it ‘in addition to’ the middle line) with the following code:
$newstring=preg_replace(" ", " ", $what); //replace those half valid apostrophe entities with actual apostrophes
Now, it displays like this:
`
PROVIDENCE COUNTY IN RHODE ISLAND<> SOUTHERN NORFOLK COUNTY IN EASTERN MASSACHUSETTS<> THIS INCLUDES THE CITY OF FRANKLIN<><>* UNTIL 145 PM EDT<><>* AT 755 AM EDT RADAR INDICATES HEAVY RAIN WILL CONTINUE THROUGH AT<> LEAST NOON BEFORE DIMINISHING BETWEEN 1 AND 4 PM. RAINFALL<> OVERNIGHT ENDING AT 730 AM HAS AVERAGED 1 TO 2 INCHES ACROSS MUCH<> OF PROVIDENCE COUNTY RHODE ISLAND AND SOUTHERN NORFOLK COUNTY.<><>* HEAVIEST RAIN SO FAR HAS OCCURRED FROM FOXBOROUGH TO PLAINVILLE<> MASSACHUSETTS TO CUMBERLAND…LINCOLN…SMITHFIELD…WOONSOCKET<> AND NORTH PROVIDENCE.<><>* THE HEAVY RAIN WILL CAUSE WIDESPREAD POOR DRAINAGE AND BASEMENT<> FLOODING BY LATE THIS MORNING WITH SEVERAL STREAMS EXPECTED TO<> RIDE OUT OF THEIR BANKS DURING MIDDAY.<><>* THE BLACKSTONE AND NORTH BRANCH OF THE PAWTUXET RIVERS WILL BE<> RISING RAPIDLY DURING MIDDAY AND THIS AFTERNOON…THREATENING TO<> FLOOD.<><>* ROAD CLOSURES MAY OCCUR BY LATE MORNING. IF ROADS BECOME<> IMPASSABLE…DONT DRIVE AROUND BARRICADES. IT COULD BECOME<> LIFE THREATENING.<><>* STORM TOTAL RAINFALL BY NOON IN PORTIONS OF NORFOLK AND<> PROVIDENCE COUNTIES WILL PROBABLY EXCEED 4 INCHES
`
See? It removes the "
" but leaves the “<” and the “>”.If instead I use this code:
$newstring=preg_replace(" ", "<p>", $what); //replace those half valid apostrophe entities with actual apostrophes
It will display like this:
`
PROVIDENCE COUNTY IN RHODE ISLAND<
SOUTHERN NORFOLK COUNTY IN EASTERN MASSACHUSETTS<
THIS INCLUDES THE CITY OF FRANKLIN<
<
- UNTIL 145 PM EDT<
<
- AT 755 AM EDT RADAR INDICATES HEAVY RAIN WILL CONTINUE THROUGH AT<
LEAST NOON BEFORE DIMINISHING BETWEEN 1 AND 4 PM. RAINFALL<
OVERNIGHT ENDING AT 730 AM HAS AVERAGED 1 TO 2 INCHES ACROSS MUCH<
OF PROVIDENCE COUNTY RHODE ISLAND AND SOUTHERN NORFOLK COUNTY.<
<
- HEAVIEST RAIN SO FAR HAS OCCURRED FROM FOXBOROUGH TO PLAINVILLE<
MASSACHUSETTS TO CUMBERLAND…LINCOLN…SMITHFIELD…WOONSOCKET<
AND NORTH PROVIDENCE.<
<
- THE HEAVY RAIN WILL CAUSE WIDESPREAD POOR DRAINAGE AND BASEMENT
`
See?
I must be getting close here but, because I dont know the finer points of PHP, I cant get any further. I cant get the “<” and “>” to go away.
If anyone wants to tinker with this and suggest a code change, it sure would be appreciated. I did see on the other PHP page needed for the Script (“lastRSS.php”) there is more code and at one point it talks about stripping html and other “bull[edit]” (it actually says it in there) and maybe thats where the tinkering should be…but that part is really confusing to me.
Good luck should you find yourself as close as me to perfection but not able to make the final step!!!
Adam