Created
April 12, 2014 17:10
-
-
Save evaldas-raisutis/10546311 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
#calendar { | |
margin-top:5em; | |
width: 100%; | |
} | |
#month { | |
text-align:center; | |
text-transform:uppercase; | |
} | |
.day { | |
display:inline; | |
width:13.285%; | |
height: 13.285%; | |
padding: 3% 0.5%; | |
float:left; | |
text-align:center; | |
font-size:1.2em | |
} | |
.day:hover { | |
background-color: lightgray; | |
} | |
.hasEvent { | |
background-color:blue; | |
} |
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> | |
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="calendar"> | |
<div id="month"></div> | |
<div id="days"></div> | |
</div> | |
</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 days = [ | |
{ | |
"day": 1, | |
"events": [ | |
{ | |
"id": "123h123h12h31", | |
"day": 2, | |
"title": "Clean" | |
}, | |
{ | |
"id": "j23h23h123", | |
"day": 21, | |
"title": "Clean" | |
}, | |
{ | |
"id": "o12ifdfb", | |
"day": 22, | |
"title": "Clean" | |
} | |
] | |
}, | |
{ | |
"day": 2, | |
"events": [ | |
] | |
} | |
]; | |
var month = { | |
"title": "january", | |
"days": days.length | |
}; | |
$("#month").text(month.title); | |
days.forEach(function(day) { | |
var elem = $("<div>"+day.day+"</div>"); | |
elem.addClass("day"); | |
if( day.events.length > 0) elem.addClass("hasEvent"); | |
elem.appendTo("#days"); | |
}); | |
// for each day in a month, render days and append to calendar | |
// for(var x = 1; x <= month.days; x++) { | |
// $("<div>" + x + "</div>") | |
// .addClass("day") | |
// .addClass("day-" + x) | |
// .appendTo("#days"); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment