Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <div id="year">
- </div>
- <style>
- #year{
- width: 702px;
- height: 91px;
- display: flex;
- flex-direction: column;
- flex-wrap: wrap;
- align-content: flex-start;
- }
- #year div{
- width: 11px;
- height: 11px;
- background-color: #eeeeee;
- margin: 1px;
- }
- </style>
- <script>
- var now = Date.now();
- var date = now - 1000 * 60 *60 * 24 * (377 - (6-(new Date()).getDay()));
- var colors = ['#eee', '#d6e685', '#8cc665', '#44a340', '#1e6823'];
- var calendar = {
- 'Sun': 0.2,
- 'Mon': 0.8,
- 'Tue': 1.1,
- 'Wed': 1.2,
- 'Thu': 1.3,
- 'Fri': 0.7,
- 'Sat': 0.3,
- 'January': 0.8,
- 'February': 1,
- 'March': 1,
- 'April': 1,
- 'May': 0.7,
- 'June': 0.3,
- 'July': 0.7,
- 'August': 1,
- 'September': 1,
- 'October': 1,
- 'November': 1,
- 'December': 0.8,
- 'January 1,': 0.05,
- 'January 2,': 0.05,
- 'January 3,': 0.05,
- 'January 4,': 0.05,
- 'January 5,': 0.05,
- 'January 7,': 0.05,
- 'May 1,': 0.1,
- 'May 9,': 0.1,
- 'February 23,': 0.1,
- 'March 8,': 0.1,
- 'November 4,': 0.1
- };
- while(date <= now){
- var day = document.createElement('div');
- day.title = (new Date(date)).toLocaleString('en', { weekday: 'short', month: 'long', year: 'numeric', day: 'numeric' });
- year.appendChild(day);
- var alpha = 1;
- for(key in calendar)if(RegExp(key).test(day.title)) alpha *= calendar[key];
- day.style.backgroundColor = colors[Math.min(Math.round(Math.random()*alpha*5),4)];
- date += 1000 * 60 * 60 * 24;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement