Last active
August 29, 2015 14:24
-
-
Save bperel/07f582fe09db876acbcd to your computer and use it in GitHub Desktop.
Time board
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
<html> | |
<head> | |
<link type="text/css" rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<div id="time-board"> </div> | |
<form id="destination"> | |
<input type="text" id="destination_month" name="month" /> | |
<input type="text" id="destination_day" name="day" /> | |
<input type="text" id="destination_year" name="year" /> | |
<input type="text" id="destination_hour" name="hour" /> | |
<input type="text" id="destination_minute" name="minute" /> | |
</form> | |
<form id="now"> | |
<input readonly="readonly" type="text" id="now_month" name="month" /> | |
<input readonly="readonly" type="text" id="now_day" name="day" /> | |
<input readonly="readonly" type="text" id="now_year" name="year" /> | |
<input readonly="readonly" type="text" id="now_hour" name="hour" /> | |
<input readonly="readonly" type="text" id="now_minute" name="minute" /> | |
</form> | |
<button id="validate">Great scott ! Way to go Marty !</button> | |
<script type="text/javascript" src="script.js"></script> | |
</body> | |
</html> |
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 now = new Date(); | |
document.getElementById('now_month').value = now.getMonth(); | |
document.getElementById('now_day').value = now.getDate(); | |
document.getElementById('now_year').value = now.getFullYear(); | |
document.getElementById('now_hour').value = now.getHours(); | |
document.getElementById('now_minute').value = now.getMinutes(); | |
document.getElementById('validate').onclick = function() { | |
var SESSION = { | |
REFERENCE_TIME: "reference_time" | |
}; | |
var month = document.getElementById('destination_month').value; | |
var day = document.getElementById('destination_day').value; | |
var year = document.getElementById('destination_year').value; | |
var hour = document.getElementById('destination_hour').value; | |
var minute = document.getElementById('destination_minute').value; | |
var new_date = null; | |
if (month !== '') { | |
new_date = new Date(year, month, day, hour, minute, 0, 0); | |
} | |
if (isNaN(new_date)) { | |
alert('Invalid date'); | |
} | |
else if (new_date == null) { | |
localStorage.removeItem(SESSION.REFERENCE_TIME); | |
alert("Reference time has been set to the normal time"); | |
} | |
else { | |
localStorage.setItem(SESSION.REFERENCE_TIME, new_date); | |
alert("Reference time has been set to "+new_date); | |
} | |
}; |
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
#time-board { | |
background: url('time_board.png') no-repeat; | |
width: 576px; | |
height: 228px; | |
position: absolute; | |
} | |
form { | |
position: absolute; | |
} | |
form#destination { | |
top: 45px; | |
margin-left: -5px; | |
} | |
form#now { | |
top: 160px; | |
margin-left: -10px; | |
} | |
form#now input { | |
color: gray; | |
} | |
input[type="text"] { | |
background-color: black; | |
color: white; | |
z-index: 2; | |
border: 0; | |
margin-left: 20px; | |
height: 35px; | |
font-size: 36px; | |
font-family: "digital", serif; | |
text-align: center; | |
} | |
input[name="month"] | |
{ | |
width: 110px; | |
} | |
input[name="year"] { | |
width: 140px; | |
} | |
form#destination input[name="year"] { | |
width: 130px; | |
} | |
input[name="day"], | |
input[name="hour"], | |
input[name="minute"]{ | |
width: 60px; | |
} | |
input[name="hour"] { | |
margin-left: 40px; | |
} | |
form#now input[name="minute"] { | |
margin-left: 25px; | |
} | |
@font-face { | |
font-family: "digital"; | |
src: url("digital-7.regular.ttf"); | |
} | |
button { | |
margin-top: 250px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment