<body onLoad="Reset();" onUnload="stopclock();"> <script language="JavaScript"> <!-- var timerID = null; var timerRunning = false; var logTime = false; var logSeconds = 0; var logMinutes = 0; var logHours = 0; var stopHours = 0; var stopMinutes = 0; var stopSeconds = 0; var startHours = 0; var startMinutes = 0; var startSeconds = 0; var newSeconds = 0; var newMinutes = 0; var newHours = 0; var reset = false; function Reset() { logTime = false; logSeconds = 0; logMinutes = 0; logHours = 0; stopHours = 0; stopMinutes = 0; stopSeconds = 0; startHours = 0; startMinutes = 0; startSeconds = 0; newSeconds = 0; newMinutes = 0; newHours = 0; reset = true; stopclock(); } function UpdateTimerOnStart() { var now = new Date(); if (reset == true) { stopHours = now.getHours(); stopMinutes = now.getMinutes(); stopSeconds = now.getSeconds(); reset = false; } startHours = now.getHours(); startMinutes = now.getMinutes(); startSeconds = now.getSeconds(); if (startSeconds >= stopSeconds) { newSeconds = startSeconds - stopSeconds; } else { startMinutes -= 1; newSeconds = (startSeconds + 60) - stopSeconds; } if (startMinutes >= stopMinutes) { newMinutes = startMinutes - stopMinutes; } else { startHours -= 1; newMinutes = (startMinutes + 60) - stopMinutes; } newHours = startHours - stopHours; logSeconds = newSeconds; logMinutes = newMinutes; logHours = newHours; if (logSeconds >= 60) { logMinutes += 1; logSeconds = 0; } if (logMinutes >= 60) { logHours += 1; logMinutes = 0; } document.forms[0].elements[2].value = logHours; document.forms[0].elements[3].value = logMinutes; document.forms[0].elements[4].value = logSeconds; startclock (); } function startclock () { stopclock(); time(); } function stopclock () { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function time () { var now = new Date(); var ampm = (now.getHours() >= 12) ? " P.M." : " A.M." var hours = now.getHours(); hours = ((hours > 12) ? hours - 12 : hours); var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes(); var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds(); var timeValue =(" " + hours + minutes + seconds + " " + ampm); document.forms[0].elements[0].value = timeValue; if (logTime == false) { var logonTime =(" " + hours + minutes + seconds + " " + ampm); stopHours = now.getHours(); stopMinutes = now.getMinutes(); stopSeconds = now.getSeconds(); document.forms[0].elements[1].value = logonTime; } logTime = true logSeconds += 1; if (logSeconds >= 60) { logMinutes += 1; logSeconds = 0; } if (logMinutes >= 60) { logHours += 1; logMinutes = 0; } document.forms[0].elements[2].value = logHours; document.forms[0].elements[3].value = logMinutes; document.forms[0].elements[4].value = logSeconds; timerID = setTimeout("time()",1000); timerRunning = true; } // --> </script> <center> <form> <table border="3" width="450"> <tr> <td align="center"><FONT COLOR=0000FF SIZE=+1><STRONG>Aktußlnφ Φas</STRONG></FONT><TD align="center"><FONT COLOR=0000FF SIZE=+1><STRONG>╚as p°ihlßÜenφ</STRONG></FONT></TR><TR><TD align="center"><INPUT TYPE="text" NAME="local" SIZE=16 VALUE="Aktußlnφ Φas"><TD align="center"><INPUT TYPE="text" NAME="logon" SIZE=16 VALUE="╚as p°ihlßÜenφ"> </tr> </table> <br> <table border="3" width="450"> <tr> <td align="center"><FONT COLOR=0000FF SIZE=+1><STRONG>Hodiny</STRONG></FONT><TD align="center"><FONT COLOR=0000FF SIZE=+1><STRONG>Minuty</STRONG></FONT> <td align="center"><FONT COLOR=0000FF SIZE=+1><STRONG>Sekundy</STRONG></FONT> </tr> <tr> <td align="center"><INPUT TYPE="text" NAME="hours" SIZE=4 Value="--"> <td align="center"><INPUT TYPE="text" NAME="mins" SIZE=4 Value="--"> <td align="center"><INPUT TYPE="text" NAME="secs" SIZE=4 Value="--"> </tr> </table> <br> <INPUT TYPE="button" value="Start" onClick="UpdateTimerOnStart()"> <INPUT TYPE="button" value="Pauza" onClick="stopclock()"> <INPUT TYPE="reset" value="Vynuluj" onClick="Reset()"></FORM> </center> |