Team:Kyoto/TimeLimit
From 2013.igem.org
(Difference between revisions)
(One intermediate revision not shown) | |||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
function update() { | function update() { | ||
- | |||
- | |||
- | |||
- | |||
// freeze 20130928 00:00 @ MIT | // freeze 20130928 00:00 @ MIT | ||
freeze = new Date(2013, 8, 28, 4, 0, 0); | freeze = new Date(2013, 8, 28, 4, 0, 0); | ||
Line 19: | Line 15: | ||
var time = freeze.getTime() - utc.getTime(); | var time = freeze.getTime() - utc.getTime(); | ||
time = Math.floor(time / 1000); | time = Math.floor(time / 1000); | ||
+ | var wrapper = document.getElementById("limit"); | ||
if (time < 0) { | if (time < 0) { | ||
- | |||
wrapper.style.color = "#f00"; | wrapper.style.color = "#f00"; | ||
wrapper.innerHTML = "Time Up!"; | wrapper.innerHTML = "Time Up!"; | ||
return; | return; | ||
} else if (time <= 1 * 3600) { | } else if (time <= 1 * 3600) { | ||
- | |||
wrapper.style.color = "#f00"; | wrapper.style.color = "#f00"; | ||
} else if (time <= 24 * 3600) { | } else if (time <= 24 * 3600) { | ||
- | |||
wrapper.style.color = "#ff0"; | wrapper.style.color = "#ff0"; | ||
} | } | ||
- | second | + | var second = ('0' + (time % 60)).slice(-2); |
time = Math.floor(time / 60); | time = Math.floor(time / 60); | ||
- | minute | + | var minute = ('0' + (time % 60)).slice(-2); |
time = Math.floor(time / 60); | time = Math.floor(time / 60); | ||
- | hour.innerHTML = | + | var hour = ('0' + (time)).slice(-2); |
+ | wrapper.innerHTML = hour + ':' + minute + ':' + second; | ||
} | } | ||
function resize() { | function resize() { | ||
- | var wrapper = document.getElementById(" | + | var wrapper = document.getElementById("limit"); |
var top = 300; | var top = 300; | ||
if (window.innerHeight != undefined) { | if (window.innerHeight != undefined) { | ||
Line 47: | Line 42: | ||
} | } | ||
wrapper.style.top = top + "px"; | wrapper.style.top = top + "px"; | ||
+ | |||
+ | var width = 1000; | ||
+ | if (window.innerWidth != undefined) { | ||
+ | width = window.innerWidth; | ||
+ | } else if (document.documentElement.clientWidth != undefined) { | ||
+ | width = document.documentElement.clientWidth; | ||
+ | } | ||
+ | if (width < 1000) { | ||
+ | wrapper.style.width = width + "px"; | ||
+ | wrapper.style.marginLeft = (-width / 2) + "px"; | ||
+ | var size = width / 5; | ||
+ | wrapper.style.fontSize = size + "px"; | ||
+ | wrapper.style.lineHeight = size + "px"; | ||
+ | wrapper.style.height = size + "px"; | ||
+ | wrapper.style.marginTop = (-size/2) + "px"; | ||
+ | } | ||
} | } | ||
Line 62: | Line 73: | ||
</script> | </script> | ||
<style type="text/css"> | <style type="text/css"> | ||
- | # | + | #limit { |
position: fixed; | position: fixed; | ||
width: 1000px; | width: 1000px; | ||
Line 75: | Line 86: | ||
color: #ddd; | color: #ddd; | ||
} | } | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
body { | body { | ||
background-color: #000; | background-color: #000; | ||
Line 103: | Line 101: | ||
} | } | ||
</style> | </style> | ||
- | <div id=" | + | <div id="limit"></div> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | </div> | + | |
</html> | </html> |
Latest revision as of 14:55, 26 September 2013