Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <div id="year">
  9. </div>
  10. <style>
  11. #year{
  12. width: 702px;
  13. height: 91px;
  14. display: flex;
  15. flex-direction: column;
  16. flex-wrap: wrap;
  17. align-content: flex-start;
  18. }
  19. #year div{
  20. width: 11px;
  21. height: 11px;
  22. background-color: #eeeeee;
  23. margin: 1px;
  24. }
  25. </style>
  26. <script>
  27. var now = Date.now();
  28. var date = now - 1000 * 60 *60 * 24 * (377 - (6-(new Date()).getDay()));
  29.  
  30. var colors = ['#eee', '#d6e685', '#8cc665', '#44a340', '#1e6823'];
  31.  
  32. var calendar = {
  33. 'Sun': 0.2,
  34. 'Mon': 0.8,
  35. 'Tue': 1.1,
  36. 'Wed': 1.2,
  37. 'Thu': 1.3,
  38. 'Fri': 0.7,
  39. 'Sat': 0.3,
  40.  
  41. 'January': 0.8,
  42. 'February': 1,
  43. 'March': 1,
  44. 'April': 1,
  45. 'May': 0.7,
  46. 'June': 0.3,
  47. 'July': 0.7,
  48. 'August': 1,
  49. 'September': 1,
  50. 'October': 1,
  51. 'November': 1,
  52. 'December': 0.8,
  53.  
  54. 'January 1,': 0.05,
  55. 'January 2,': 0.05,
  56. 'January 3,': 0.05,
  57. 'January 4,': 0.05,
  58. 'January 5,': 0.05,
  59. 'January 7,': 0.05,
  60. 'May 1,': 0.1,
  61. 'May 9,': 0.1,
  62. 'February 23,': 0.1,
  63. 'March 8,': 0.1,
  64. 'November 4,': 0.1
  65. };
  66.  
  67. while(date <= now){
  68. var day = document.createElement('div');
  69. day.title = (new Date(date)).toLocaleString('en', { weekday: 'short', month: 'long', year: 'numeric', day: 'numeric' });
  70. year.appendChild(day);
  71.  
  72. var alpha = 1;
  73. for(key in calendar)if(RegExp(key).test(day.title)) alpha *= calendar[key];
  74. day.style.backgroundColor = colors[Math.min(Math.round(Math.random()*alpha*5),4)];
  75. date += 1000 * 60 * 60 * 24;
  76. }
  77. </script>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement