../Msgboard/General customization/taskbar date and time tickerHome
p455w0rd - 25 Dec. 2006 - 11:24:

taskbar date and time ticker

This is just a little script I wrote for the HTML on my taskbar. I used the method of creating an about: URL and creating a toolbar from that. I'm using XPSP2. It uses full date and time (Monday, December 25, 2006 @ 5:18:14 AM) format. I scrolls like a news ticker and slows when you mouse over it. It stop completely when you click it. Then just click it again to start it back up....

--------------------------------------------------------------------------------------------

<html>
<head>
<title>Time and Date:</title>
<script>
var clickState = "on";
function newTimeDate() {
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var day = now.getDay();
var month = now.getMonth();
var year = now.getYear();
var date = now.getDate();
var ampm = "AM";
if (hour == 0) { hour = 12; }

if (hour > 12) {
ampm = "PM";
hour = hour - 12;
}

if (minute < 10) {
var minute = "0"+minute;
}

if (second < 10) {
var second = "0"+second;
}

var time = hour+":"+minute+":"+second+" "+ampm;

switch(day) {
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
break;
case 0:
day = "Sunday";
break;
}

switch(month) {
case 0:
month = "Januaury";
break;
case 1:
month = "February";
break;
case 2:
month = "March";
break;
case 3:
month = "April";
break;
case 4:
month = "May";
break;
case 5:
month = "June";
break;
case 6:
month = "July";
break;
case 7:
month = "August";
break;
case 8:
month = "September";
break;
case 9:
month = "October";
break;
case 10:
month = "November";
break;
case 11:
month = "December";
break;
}

document.datef.ield.value = day+", "+month+" "+date+", "+year+" @ "+time;
setTimeout("newTimeDate()", 500);

}

function handleClick(marquee) {

if (clickState == "on") {
clickState = "off";
marquee.stop();
}

else {
clickState = "on";
marquee.start();
}

}
</script>
</head>
<body onload="newTimeDate()" text=000000 style="background-color:buttonface;border:0px" scroll=no>
<div style="position: absolute; top: 1px; font-size: 12px">
<marquee style="width:100%" scrollamount=6 onMouseOver="this.scrollAmount=3" onMouseOut="this.scrollAmount=6" onClick="handleClick(this)">
<form name=datef>
<input readonly type=text style="border:0px;background:buttonface;font-family:Microsoft Sans Serif;font-weight:bold" size=42 name=ield value=Loading...>
</form>
</marquee>
</div>
</body>
</html>

--------------------------------------------------------------------------------------------
 
25 Dec. 2006 - 11:30 p455w0rd
The above code has been corrected. There was a bug where I c&p'ed the part of the code that adds a zero to the seconds below 10 (it showed "0XX" XX being the current minute). Also fixed midnight hour showing up as zero (0:12:16 AM). I know this is really simple. I created it more as a tool to learn form as far as positioning and just what is possible. You could modify it, as I plan to do, to show different time/date formats while scrolling upward. If anyone would like any help, just post back. I completely coded this from memory (haven't messed with html, css, or JS in over a year), so I expected a few bugs-It works perfectly now...
 
Please log-in to post.
You need to be logged in to post. To log-in, or to register an account go -there.
 
Options
Login | Help | Profile | User list | Display last  
 days 


../Msgboard/General customization/taskbar date and time tickerTop

xhtml 1.1