Weather Warnings is the only script I have that isn't .NET and while I'd prefer to not be running anything VB6, I'm kind of a "If it ain't broke, don't fix it!" kind of guy. Well Weather Warnings is now broke...sort of.
So obviously if you are using this as well you see that they are going to change the URL and provide a much nicer XML interface. Since the link is changing, the URL in the script will need to change. However, the way the script parses the XML will need to change as well.
This is my test modification so I offer it up with no warranties or guarantees so use at your own risk. I'm just looking for someone else to help work the bugs out.
Chances are it will have to change again anyway since the new URL contains "-beta" so I'm assuming they will change that at some point, but it's trivial as long as they don't mess with the XML format too much.
I tried to keep the changes close to the style of how the original was coded. I've modified the original so much that I can't provide a straight up replacement of the entire file. So I provide modifications in two parts below.
First, add these declarations at the end of his declaration block and right before the line:
RepeatWarnings = hs.GetINISetting("Settings", "RepeatWarnings", "", "weatherwarnings.ini")
Then look for this code block which you will replace:
Replace that code block with:
Again my code is slightly different, but I think this should work. I'd just like someone else to help clean it up. While I'd really prefer a nice .NET script that does the same, I'm sure some people would prefer to just keep using this so hopefully we can get it working.
So obviously if you are using this as well you see that they are going to change the URL and provide a much nicer XML interface. Since the link is changing, the URL in the script will need to change. However, the way the script parses the XML will need to change as well.
This is my test modification so I offer it up with no warranties or guarantees so use at your own risk. I'm just looking for someone else to help work the bugs out.
Chances are it will have to change again anyway since the new URL contains "-beta" so I'm assuming they will change that at some point, but it's trivial as long as they don't mess with the XML format too much.
I tried to keep the changes close to the style of how the original was coded. I've modified the original so much that I can't provide a straight up replacement of the entire file. So I provide modifications in two parts below.
First, add these declarations at the end of his declaration block and right before the line:
RepeatWarnings = hs.GetINISetting("Settings", "RepeatWarnings", "", "weatherwarnings.ini")
PHP Code:
Dim ChildNode
Dim EventNode
Dim IdNode
Dim warningDoc
Dim warningURL
Dim FoundWarning
PHP Code:
Page = "http://www.weather.gov/alerts/wwarssget.php?zone=" & zone & ""
Set myDoc = CreateObject("Microsoft.XMLDOM")
myDoc.async=false
myDoc.Load(Page)
Set myList = myDoc.getElementsByTagName("item")
For Each Node In myList
'add by Jay Fro 10/22/05 to ignore alert types set by user in the .ini file
DontProcess = hs.GetINISetting("Settings", "DontProcess", "", "weatherwarnings.ini")
Set objRegExp = New RegExp
strSearch = Node.ChildNodes(0).Text
objRegExp.Pattern = DontProcess
objRegExp.Global= True
objRegExp.IgnoreCase = True
blnFind = objRegExp.Test(strSearch)
title = Node.ChildNodes(0).Text
description = Node.ChildNodes(2).Text
If blnFind Then
PHP Code:
' BEGIN REPLACE CODE BLOCK
' At some point this URL will change again, probably removing -beta
Page = "http://www.weather.gov/alerts-beta/wwaatmget.php?x=" & zone & ""
Set myDoc = CreateObject("Microsoft.XMLDOM")
myDoc.async = False
myDoc.Load (Page)
'Get all of the entries (the various warnings)
Set myList = myDoc.getElementsByTagName("entry")
Set warningDoc = CreateObject("Microsoft.XMLDOM")
warningDoc.async = False
'This will handle multiple warnings on the page
For Each Node In myList
FoundWarning = False
warningURL = ""
warningtype = ""
warning = ""
Title = ""
Description = ""
'Get the id which is the URL to the actual warning page
For i = 0 To Node.childNodes.length - 1
If Node.childNodes(i).nodeName = "id" Then
warningURL = Node.childNodes(i).nodeTypedValue
Exit For
End If
Next
If warningURL <> "" Then
'Load the actual warning URL
warningDoc.Load (warningURL)
'Get the actual alert
Set EventNode = warningDoc.getElementsByTagName("alert")
'Get the information node of the alert which has the alert details. There should be only one event (alert) node per page.
For Each ChildNode In EventNode
For i = 0 To ChildNode.childNodes.length - 1
If ChildNode.childNodes(i).nodeName = "info" Then
Set IdNode = ChildNode.childNodes(i)
FoundWarning = True
Exit For
End If
Next
Next
If (FoundWarning) Then
'Get the event (warning type) and the description
For i = 0 To IdNode.childNodes.length - 1
If IdNode.childNodes(i).nodeName = "event" Then
Title = IdNode.childNodes(i).nodeTypedValue
End If
If IdNode.childNodes(i).nodeName = "description" Then
Description = IdNode.childNodes(i).nodeTypedValue
End If
Next
End If
End If
If Title="" And Description="" Then
'There are no warnings so force this flag to be set so nothing is processed
blnFind = True
Else
'add by Jay Fro 10/22/05 to ignore alert types set by user in the .ini file
DontProcess = hs.GetINISetting("Settings", "DontProcess", "", "weatherwarnings.ini")
Set objRegExp = New RegExp
strSearch = Title
objRegExp.Pattern = DontProcess
objRegExp.Global = True
objRegExp.IgnoreCase = True
blnFind = objRegExp.Test(strSearch)
End If
If blnFind Then
' END REPLACE CODE BLOCK
Comment