Wednesday, February 15, 2006

Timer HTA



<html>
<head>
<title>Elapsed Time Timer Countdown Countup Count</title>

<HTA:APPLICATION
ID="objTimer"
APPLICATIONNAME="Timer"
SCROLL="yes"
SINGLEINSTANCE="no"
WINDOWSTATE="normal">
</head>

<script language="vbs">
Dim x : x = 1
Dim iTimerId

Sub Window_Onload
Const iWIDTH = 525
Const iHEIGHT = 250
Window.ResizeTo iWIDTH, iHEIGHT
Window.MoveTo (Screen.availWidth-iWIDTH)/2,_
(Screen.availHeight-iHEIGHT)/2
last.InnerHTML = "Current Time: " & now() & " -- Last Modified: " & document.lastModified
End Sub

Function myTime
timerArea01.innerHTML = x
If x=60 Then
stopTimer
timerArea01.innerHTML = "<a style='color:red;'>DONE!</a>"
End If
x=x+1
End Function

Sub stopTimer
window.clearInterval(iTimerId)
End Sub

Sub RunScriptHTARefresh
StopTimer
Location.Reload(True)
End Sub

Function startTimer
iTimerId=window.setInterval("myTime", 1000)
End Function

' (window.innerWidth/2)px
</script>
<BODY>

<center>
<span id="timerArea01" style="font: bold 3 em/2 arial, helvetica, sans-serif;"
name="timerarea">
</span>
</center>

<input id=start01 class="button" type="button"
value="Start" name="start" style="position:absolute; left:10px; top:10px"
onClick="startTimer">

<input id=stop01 class="button" type="button"
value="Stop" name="stop" style="position:absolute; right:10px; top:10px"
onClick="stopTimer">

<input id=refresh01 class="button" type="button"
value="Refresh" name="refresh" style="position:absolute; left:10px; bottom:20px;"
onClick="RunScriptHTARefresh">

<a id="last" style="position:absolute; bottom:5px; font:bold 0.5em/1 'courier new', helvetic, serif;"></a>
</body>
</html>

No comments:

Post a Comment