Team:KAIST-Korea/Test Count

From 2011.igem.org

(Difference between revisions)
Line 1: Line 1:
-
<html>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<head>
+
<html xmlns="http://www.w3.org/1999/xhtml" >
 +
<head><title></title>
 +
<style type="text/css"> input { width:30px; text-align:center } </style>
 +
    <script type="text/javascript">
 +
        var arrMonth = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
 +
        var arrDate = new Array(2009, 12, 25); //목표 날짜를 입력하세요
 +
        var arrTime = new Array(0, 0, 0);
 +
       
 +
        function Dday_countdown() {
 +
            var now = new Date();
 +
            var nYear = now.getYear();
 +
            var nMonth = now.getMonth();
 +
            var nDay = now.getDate();
 +
            var nHour = now.getHours();
 +
            var nMin = now.getMinutes();
 +
            var nSec = now.getSeconds();
 +
            var stmp = String(now.getMilliseconds());
 +
            var nmSec = (stmp.length == 1 ? "00" + stmp : stmp.length == 2 ? "0" + stmp : stmp);
 +
            var strnow = arrMonth[nMonth] + " " + nDay + ", " + nYear + " " + nHour + ":" + nMin + ":" + nSec;
 +
            var strfuture = arrMonth[arrDate[1] - 1] + " " + (arrDate[2] + 1) + ", " + arrDate[0] + " " + arrTime[0] + ":" + arrTime[1] + ":" + arrTime[2];
 +
           
 +
            var d_date = Date.parse(strfuture) - Date.parse(strnow);
   
   
-
 
+
            d_day = Math.floor(d_date / 86400000);
-
<title>Countdown</title>
+
            stmp = String(Math.floor((d_date % 86400000) / 3600000));
 +
            d_hour = stmp.length == 1 ? "0" + stmp : stmp;
 +
            stmp = String(Math.floor(((d_date % 86400000) % 3600000) / 60000));
 +
            d_min = stmp.length == 1 ? "0" + stmp : stmp;
 +
            stmp = String(Math.floor((((d_date % 86400000) % 3600000) % 60000) / 1000));
 +
            d_sec = stmp.length == 1 ? "0" + stmp : stmp;
   
   
-
<script type='text/javascript' src='/res/js/jquery-1.3.2.min.js'></script>
+
            var sDate = arrDate[0] + "년" + arrDate[1] + "월" + arrDate[2] + "일 까지 ";
 +
           
 +
            var oTimeCnt = document.getElementById("Timecount");
 +
            if (d_day == 0) oTimeCnt.innerHTML = " D-Day 입니다.";
 +
            else if (d_day <= -1) oTimeCnt.innerHTML = Math.abs(d_day) + ":" + (String(Math.abs(d_hour)).length == 1 ? "0" + Math.abs(d_hour) : Math.abs(d_hour)) + ":" + (String(Math.abs(d_min)).length == 1 ? "0" + Math.abs(d_min) : Math.abs(d_min)) + ":" + (String(Math.abs(d_sec)).length == 1 ? "0" + Math.abs(d_sec) : Math.abs(d_sec)) + ":" + nmSec + "지났습니다.";
 +
            else oTimeCnt.innerHTML = sDate + d_day + "일" + d_hour + "시" + d_min + "분" + d_sec + "초" + nmSec + "남았습니다.";
   
   
-
<script type='text/javascript' src='/res/js/jquery.timers-1.1.2.js'></script>
+
            setTimeout("Dday_countdown()", 10);
-
+
        }
-
<script type='text/javascript'>
+
        window.onload = Dday_countdown;
-
+
    </script>
-
var isFirst = true;
+
  </head>
-
+
  <body>
-
var endTime = new Date(2011, 11, 8, 15, 19, 30);
+
  <div style="border:solid 1px #000000; width:400px; text-align:center; font-size:15px; font-family:@맑은 고딕" id="Timecount"></div>
-
+
  </body>
-
var nowTime = new Date(2011, 7, 8, 15, 19, 30);
+
  </html>
-
+
-
var timeLeft = (endTime - nowTime) / 1000;
+
-
+
-
var timeSinceLast = 0;
+
-
+
-
$(document).ready(function(){
+
-
+
-
$(this).everyTime(1000, "countTimer", function(){
+
-
+
-
if (isFirst === true || timeLeft == -1 || (timeLeft < 300 && timeSinceLast >= 60)) {
+
-
+
-
var nt = new Date().getTime();
+
-
+
-
$.get("timesync.php?nowtime=" + nt, function(data) {
+
-
+
-
nowTime = eval('new Date(' + data + ')');
+
-
+
-
timeLeft = (endTime - nowTime) / 1000;
+
-
+
-
});
+
-
+
-
isFirst = false;
+
-
+
-
timeSinceLast = 0;
+
-
+
-
}
+
-
+
-
var outputString = '';
+
-
+
-
if (timeLeft <= 0) {
+
-
+
-
outputString = '종료';
+
-
+
-
}
+
-
+
-
else {
+
-
+
-
var dayCount = Math.floor(timeLeft / 86400);
+
-
+
-
var hourCount = Math.floor((timeLeft - dayCount * 86400) / 3600);
+
-
+
-
var minCount = Math.floor((timeLeft - (dayCount * 86400) - (hourCount * 3600)) / 60);
+
-
+
-
var secCount = timeLeft - (dayCount * 86400) - (hourCount * 3600) - (minCount * 60);
+
-
+
-
+
-
+
-
if (dayCount > 0) {
+
-
+
-
outputString = dayCount + '日+';
+
-
+
-
}
+
-
+
-
outputString += ((hourCount > 0) ? hourCount + ':' : '') + ((minCount < 10) ? '0' + minCount : minCount) + ':' + ((secCount < 10) ? '0' + secCount : secCount);
+
-
+
-
timeLeft -= 1;
+
-
+
-
timeSinceLast += 1;
+
-
+
-
}
+
-
+
-
$('#countDown').text(outputString);
+
-
+
-
});
+
-
+
-
});
+
-
+
-
 
+
-
</script>
+
-
   
+
-
 
+
-
</head>
+
-
   
+
-
<body>
+
-
   
+
-
<div><span id="countDown">A</span></div>
+
-
   
+
-
</body>
+
-
   
+
-
</html>
+

Revision as of 09:47, 8 July 2011

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">