Created
June 19, 2013 10:32
-
-
Save chikoski/5813340 to your computer and use it in GitHub Desktop.
時計アプリ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CHARSET "UTF-8"; | |
body{ | |
background-color: #111; | |
background-repeat: no-repeat; | |
} | |
#clock{ | |
font-family: 'VT323', monospace, cursive; | |
color: #ff8c00; | |
font-size: 120px; | |
text-align: center; | |
position: absolute; | |
left: 0; | |
bottom: 50%; | |
width: 100%; | |
} | |
.hide{ | |
display: "none"; | |
} | |
.morning{ | |
background-image: url(../img/morning.jpg); | |
} | |
.morning #clock{ | |
color: #eee; | |
} | |
.daytime{ | |
background-image: url(../img/daytime.jpg); | |
} | |
.sunset{ | |
background-image: url(../img/sunset.jpg); | |
} | |
.sunset #clock{ | |
color: #111; | |
} | |
.night{ | |
background-image: url(../img/night.jpg); | |
} | |
.night #clock{ | |
color: #eee; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var clock; | |
var body; | |
var updateClock = function(now){ | |
var separator = ":"; | |
if(now.getSeconds() % 2 == 0){ | |
separator = " "; | |
} | |
var min = now.getMinutes(); | |
if(min < 10){ | |
min = "0" + min; | |
} | |
var text = now.getHours() + separator + min; | |
clock.innerHTML = text; | |
}; | |
var updateBackground = function(now){ | |
var hour = now.getHours(); | |
//var hour = 20; | |
if(hour < 10){ | |
body.setAttribute("class", "morning"); | |
}else if(hour < 13){ | |
body.setAttribute("class", "daytime"); | |
}else if(hour < 19){ | |
body.setAttribute("class", "sunset"); | |
}else{ | |
body.setAttribute("class", "night"); | |
} | |
}; | |
var update = function(){ | |
var now = new Date(); | |
updateClock(now); | |
updateBackground(now); | |
setTimeout(update, 1000); | |
}; | |
window.onload = function(){ | |
clock = document.getElementById("clock"); | |
body = document.getElementById("body"); | |
update(); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Clock</title> | |
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> | |
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.min.css"> | |
<link rel="stylesheet" type="text/css" href="css/app.css"> | |
<link href='http://fonts.googleapis.com/css?family=VT323' rel='stylesheet' type='text/css'> | |
</head> | |
<body id="body"> | |
<div class="navbar navbar-inverse navbar-fixed-top"> | |
<div class="navbar-inner"> | |
<div class="container-fluid"> | |
<span class="brand">Clock</span> | |
<ul class="nav"> | |
<li><a href="flickr.html">Flickr</a></li> | |
<li class="active"><a href="index.html">Clock</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<div class="container-fluid"> | |
<div id="clock"></div> | |
</div> | |
<script src="js/jquery-2.0.2.min.js"></script> | |
<script src="js/app.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment