Alternative ATOM Feed Alert Program

Thats not good. i sent him an email.

I found him on wxforums but he’s not answering my message…

I don’t know if this has been covered before, but for those that don’t use Linux or, want or have access to Task Scheduler (e.g., my host does not allow me access), or you don’t want to change your index file to a php file, then this is a good alternative. Since it is an asynchronous request, it allows the page to load as it is getting the data.

First you need jQuery: http://docs.jquery.com/Downloading_jQuery#Download_jQuery
For the script below, it is installed in a “js” subdirectory under the folder where the page is executed.

Create a webpage (straight .html is fine) and add the code below. For existing pages, add the javascript code and a div with the id of “v_Alerts” where you want the alert box to show up.

Also, on the line “url: ‘AtomAlerts/AtomFeed.php?rand=’ + (new Date()).valueOf()” change the location to that of your “AtomFeed.php” file (leave the ?rand… part).

Create a php file named “AtomAlertAjax.php” with the contents shown below (or whatever you want in your alert box).

Then run the html page… the page should load and when the javascript calls are complete, the alert box should show up.

The line “setTimeout(“SetAlerts()”, 60 * 1000);” controls how often the script checks for new info. In this case it is every 60 seconds.

If you do not want to use the body onload event, then you can use the jquery function:
$(document).ready(function () {
SetAlerts();
});

Example: http://www.bocafallsweather.com/testalerts.html

Webpage (e.g., index.html):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<script type="text/javascript" src="js/jquery-1.5.1.js"></script> <!-- change folder to where this is located -->
<script type="text/javascript">
function SetAlerts() {
   $.ajax({
      url: 'AtomAlerts/AtomFeed.php?rand=' + (new Date()).valueOf(), //change to the location of your AtomFeed.php
      dataType: 'text',
      success: function (data, textStatus) {
      	try {
         //alert('Status is '+textStatus);
         //alert('JSON data string is: '+data);
         GetAlerts();
         } catch (err) {
            //Handle errors here
         }
         setTimeout("SetAlerts()", 60 * 1000);
      },
      error: function (xhr, ajaxOptions, thrownError) {
         alert('ErrorStatus: ' + xhr.status);
         alert('ErrorThrown: ' + thrownError);
      }
   });
}
function GetAlerts() {
   $.ajax({
      url: 'AtomAlertAjax.php?rand=' + (new Date()).valueOf(),
      dataType: 'text',
      success: function (data, textStatus) {
      	try{
         //alert('Status is '+textStatus);
         //alert('JSON data string is: '+data);
         
          $('#v_Alerts').html(data)
		  
         } catch (err) {
            //Handle errors here
         }
      },
      error: function (xhr, ajaxOptions, thrownError) {
         alert('ErrorStatus: ' + xhr.status);
         alert('ErrorThrown: ' + thrownError);
      }
   });
}
// Uncomment the following three lines if you don't want to use the body unload function
//$(document).ready(function () { 
//	SetAlerts();
//}); 

</script>
</head>
<body onload="SetAlerts()"> <!-- you can use the jQuery ready function instead of the onload function -->
<h2>ALERTS</h2>

<div id="v_Alerts"></div>



<div>Some more page data</div>

</body>
</html>

AtomAlertAjax.php:


<?php
echo "\n<!-- AtomFeed Alert Box-->";
include("AtomArray.php");
print $alert_box;
echo "\n<!-- end AtomFeed Alert Box-->\n";
?>


TestAjaxAlerts.zip (1.12 KB)

hello…

can someone help me out with 2 things concerning this script.?

  1. in the Atom-feed-Config.php file…what do I place in this section for my area?

COUNTY/ZONE SET UP

$Code_Location = array(
“INZ005” => “Elkhart Co”, // ELKHART IN - priority zone listed first
“INC039” => array(1 => “INC039”,‘a’ => “INZ005”), // COUNTY CODE => COUNTY CODE => ZONE CODE
“MDC005” => array(1 => “MDC005”,‘a’ => “MDZ011”,‘b’ => “MDZ006”), // COUNTY CODE => COUNTY CODE => ZONE CODE => ZONE CODE
“MDZ006” => “No.Balt.Co.”, // N Baltimore
“MDZ011” => “So.Balt.Co.” // S Baltimore
);

My Noaa Zone is MAZ021 and the County Zone is MAC023 for Plymouth County, but what else should I also add in? Should I add in the Noaa Zones for Western and eastern plymouth County? Stumped as to what I should be adding for this section and could use some insight from someone that knows what to do with this?

  1. on the top of my homepage in the warning box it currently reads “No Warnings, Watches or Advisories”…in what file can I edit this, so that when there are no watches.,warnings or advisories…it reads “There are currently no Watches,Warnings or Advisories in the Area”?

Thanks for any help, and by the way this script seems a bit better than the basic Atom script.

I have also yet to configure a Cron job or windows task scheduler part of the instructions, since I am on E-rice, I will most likely have to use the windows task scheduler option, but will do that afterwards.

…Chris

Chris,it may be a while til I get home from work, but I’ll send you the vbscript for task manager,in fact, if i remember correctly, Curly, when he was with us on the forum, had a copy of the VB script included in the instructions…

chris

Hi Chris,

I have been trying to work with this program also and ran into several issues.

I don’t understand all the necessary configurations that need to be done. I have in the location area for the Atom-feed-Config.php file as follows, don’t know if this is correct or not:

$Code_Location = array(
“HIZ020” => “Windward Haleakala”, // Maui HI - priority zone listed first
“HIC009” => array(1 => “HIC009”,‘a’ => “HIZ019”), // COUNTY CODE => COUNTY CODE => ZONE CODE
“HIC009” => array(1 => “HIC000”,‘a’ => “HIZ020”,‘b’ => “HIZ019”), // COUNTY CODE => COUNTY CODE => ZONE CODE => ZONE CODE
“HIZ020” => “Windward Haleakala”, // Windward Haleakala
“HIZ019” => “Central Maui Valley” // Central Maui Valley
);

As far as the cron job, I have no idea what this is, but attached is the one that I found some place for XP OS’s.

Guess that we are in the same boat at this time. Otherwise, hope all is well with you.

–Stan Y.
Maui, Hawaii


TaskSchedulerSetupXP.zip (2.21 KB)

This is what mine has. Its been working great for a long time now. You dont have to use all of the areas, just delete the lines if you dont want to use them all. I added some surrounding areas to show more results.


// county/zone codes => location
$Code_Location = array(
    "WAZ505" => "Snoqualmie,Wa", // Snoqualmie Wa - priority zone listed first
    "WAC033" => "King County",  // King County
    "WAZ508" => "Seattle Metropolitan Area, WA", // Seattle
    "WAZ509" => "Tacoma Area, WA", // Tacoma
    "WAZ519" => "West Slopes Central Cascades and Passes, WA", //
    "WAC061" => "Snohomish County, WA", // Snohomish County, WA
    "WAC037" => "Kittitas County, WA", // Kittitas County, WA
    "WAC053" => "Pierce County, WA" // Pierce County, WA

);


Hi Mark,

I will try to get mine to read like yours and see what happens for my area. Looks like I will need just 3 or 4 zones for the Island of Maui.

Thanks for the insight. Next to tackle that cron job issue if I need to… Will try with out it first and maybe Chris will be able to help me out a bit when his time permits.

–Stan Y.
Maui, Hawaii

I think I found a fix for this script. I am hoping some others will try it.

Change these two lines:

$AlertURL = 'http://www.weather.gov/alerts-beta/wwaatmget.php?x=';  // NWS URL for primary data

$AlertURL2 = 'http://www.weather.gov/alerts-beta/wwacapget.php?x='; // NWS URL for alert data

to:

$AlertURL = 'http://alerts.weather.gov/cap/wwaatmget.php?x=';  // NWS URL for primary data

$AlertURL2 = 'http://alerts.weather.gov/cap/wwacapget.php?x='; // NWS URL for alert data

Mike announced that here http://discourse.weather-watch.com/t/50400

So yeah, if some people didnt see that, then theres would stop working.

Rats. I missed that completely. Me, bringing up the rear again. :slight_smile:

Hi,

I think I found all of those fixes also. A lot of places needed to be changed…

–Stan Y.
Maui, Hawaii

Yeah Stan. There’s more places that need changed other than what was just posted.

Hi Mark,

I hope that I found most of the places that needed this change.

Also got the zone changes as follows:

$Code_Location = array(
“HIZ020” => “Windward Haleakala”, // Maui HI - priority zone listed first
“HIZ017” => “Maui Windward West”, // Maui HI
“HIZ018” => “Maui Leeward West”, // Maui HI
“HIZ019” => “Central Maui Valley” // Maui HI
“HIZ021” => “Leeward Haleakala”, // Maui HI
“HIZ022” => “Haleakala Summit”, // Maui HI
);

Hope that this will work. I have not posted this on my host as of yet. Gotta figure out that sub folder routine and cron issue and hope all will fall in place or all will fall apart… Hope not the latter…

–Stan Y.
Maui, Hawaii

You need to remove the “comma” after this line…

“HIZ022” => “Haleakala Summit”, // Maui HI

Should be…

“HIZ022” => “Haleakala Summit” // Maui HI

I use this for my cron jobs, System Scheduler. I use the free version. Works good. Was recomended by Niko awhile ago.

http://www.splinterware.com/products/wincron.htm

hello alll…

Thanks kindly for the help…I went with this for my area:

// county/zone codes => location
$Code_Location = array(
“MAZ021” => “S. Plymouth ,MA”, // S. Plymouth Ma - priority zone listed first
“MAC023” => “Plymouth County”, // Plymouth County
“MAZ019” => “E. Plymouth, MA”, //E. Plymouth
“MAZ018” => “W. Plymouth, MA”, // W. Plymouth
“MAC001” => “Barnstable County, WA”, // Barnstable County, MA
“MAC005” => “Bristol County, MA” // Bristol County, MA

);

Stanley/Silversword…if you dont or cant, since some servers like E-rice cant have Cron Jobs for whatever reason, then you can use the Windows task scheduler method, that I intend to use. I havent attempted it yet, but others here will provide us help if we need it.

Ill keep you posted via Direct email on that.

…Chris

The windows Task sceduler method that I spoke about can be found with good direction here:

http://www.642weather.com/weather/wxblog/php-scripts/scheduled-http-request-windows-task-scheduler/

from Mike Challis website.

I am awaiting the vbscript also Mentioned from a few post’s back from chrisinPa.

…chris

Attached is a copy of my VBS script as a .txt file.


Atom_Feed.txt (552 Bytes)

Thanks Mark…

I edited it to the URL path to my own AtomFeed.php file on my server and am heading down stairs to the Weather PC and see if I can get some more gray hairs in setting up the windows task scheduler thing. wish me luck…lol

…Chris

P.S. I you have some Popcorn and wanna watch a good movie, go to my live cam/ time lapse links.

The comma should make no difference to the array as you are not defining another array section.

An alternative would be to use Pseudo Cron or something like it which is done in PHP and basically runs off the hits to your own website to trigger it.

This is especially good for something like this where pinpoint timing really isn’t needed.

Pseudo Cron