http://www.elated.com/res/File/articles ... clock.html
The panel comes up but I don't see the clock. Can anybody make it work, please? (I made a clock using only vbscript and label caption method. That works but when the second changes, the clock text flickers quite often; whereas the java clock inside a webpage is smooth.)
I tried changing various things unsuccessfully. The clock.html file displays the clock in IE8 by itself.
Two files, both go into scripts/auto folder.
1. clock.vbs
Code: Select all
'A simple real time Clock inside Monkey
Sub OnStartup
'create panel
Dim ui: Set ui = SDB.UI
Dim pan : Set pan = ui.NewDockablePersistentPanel("Clock")
If pan.IsNew Then
pan.DockedTo = 4
pan.Common.Width = 250
pan.Common.Height = 50
End If
pan.showCaption = True
pan.Common.Visible = True
'create a web browser component
Dim web : Set web = ui.NewActiveX(pan,"Shell.Explorer")
web.Common.ClientWidth = pan.Common.ClientWidth
web.Common.ClientHeight = pan.Common.ClientHeight
web.Common.Anchors = 15
web.Common.ControlName = "ClockWeb"
'apply skin
Dim path : path = Left(Script.ScriptPath,InStrRev(Script.ScriptPath,"\"))
path = path&"clock.html"
Call web.Interf.Navigate(path)
End Sub
Code: Select all
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Clock</title>
<style type="text/css">
#clock { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: blue; background-color: white; text-align: left;}
</style>
<script type="text/javascript">
function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("clock").appendChild ( timeDisplay );
}
function updateClock ( )
{
var currentTime = new Date ( );
var myDays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var thisDaynum=currentTime.getDay();
var thisDay=myDays[thisDaynum];
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
currentTimeString = month + "/" + day + "/" + year + " " + thisDay + " " + currentTimeString;
// Update the time display
document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
</script>
</head>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
<div style="clear: both;"> </div>
<div style="width: 250px; text-align: left;">
<span id="clock"> </span>
</div>
</body>
</html>