I need help converting this to JScript:
<%
Const ksKbaURL = "http://www.kbalertz.com/websvc/latestkbs.aspx?t=%t%&c=%c%"
Const ksKbaCount = 10
Const ksKbaX = "kbAlertz"
Const ksKbaXslPath = "/kbAlertz.xsl"
Const ksKbaError="kbAlertz is unavailable at this time."
Function kbAlertz(iTech)
On Error Resume Next
Dim sRet, lTech, sURL
lTech = 0
If IsNumeric(iTech) Then
lTech = CLng(iTech)
End If
If CLng(lTech) < 1 Then lTech = 1
lTech = Trim(lTech)
sURL = Replace(ksKbaURL, "%t%", lTech)
sURL = Replace(sURL, "%c%", ksKbaCount)
lTech = ksKbaX & "." & lTech
If Application(lTech) & "" <> "" Then
If (Application(lTech & ".Refresh") > Now()) And _
(Application(lTech & ".xsl") = _
Application(ksKbaX & ".xsl.Refresh")) Then
kbAlertz = Application(lTech)
Exit Function
End If
End If
Dim oXml
Set oXml = Server.CreateObject("Msxml2.ServerXMLHTTP")
oXml.Open "GET", sURL , False
oXml.send
Dim oXsl
Set oXsl = Server.CreateObject("Msxml2.DOMDocument")
oXsl.async = False
If Application(ksKbaX & ".xsl") & "" = "" Then
kbAlertzXSL
End If
oXsl.loadXML Application(ksKbaX & ".xsl")
Dim oXmlD
Set oXmlD = Server.CreateObject("Msxml2.DOMDocument")
oXmlD.loadXML oXml.responseText
sRet = oXmlD.transformNode(oXsl)
If Err = 0 Then
kbAlertz = sRet
Application.Lock
Application(lTech) = sRet
Application(lTech & ".Refresh") = NoonTomorrow
Application(lTech & ".xsl") = _
Application(ksKbaX & ".xsl.Refresh")
Application.UnLock
Else
If Application(lTech) & "" <> "" Then
kbAlertz = Application(lTech)
Else
kbAlertz = ksKbaError
End If
Err.Clear
End If
sRet = ""
sURL = ""
Set oXmlD= Nothing
Set oXsl = Nothing
Set oXml = Nothing
End Function
Sub kbAlertzXSL()
Dim oXsl
Set oXsl = Server.CreateObject("Msxml2.DOMDocument")
oXsl.async = False
oXsl.Load Server.MapPath(ksKbaXslPath)
Application.Lock
Application(ksKbaX & ".xsl") = oXsl.xml
Application(ksKbaX & ".xsl.Refresh") = Now()
Application.UnLock
Set oXsl = Nothing
End Sub
Function NoonTomorrow()
Dim dTomorrow
dTomorrow = FormatDateTime(CDate(Now()+1), vbShortDate)
dTomorrow = CDate(dTomorrow) + 0.5
NoonTomorrow = CDate(dTomorrow)
End Function
%> |