UNPKG

holidaylights

Version:

Very simple JavaScript plugin to display festive and pleasing (but not over-powering) effects to your website based on the time of year. Should be suitable for business websites.

869 lines (727 loc) 29.7 kB
document.addEventListener('DOMContentLoaded', function() { var styles = ` body { overflow: auto !important; } #christmasLights { position: fixed; top: 0px; left: 0px; width: 100%; height: 50px; z-index: 50; overflow: hidden; pointer-events: none; } .lightrope { text-align: center; white-space: nowrap; overflow: hidden; position: absolute; z-index: 1; margin: -15px 0 0 0; padding: 0; pointer-events: none; width: 100%; } .lightrope li { position: relative; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; list-style: none; margin: 0; padding: 0; display: block; width: 12px; height: 28px; border-radius: 50%; margin: 20px; display: inline-block; background: #00f7a5; box-shadow: 0px 4.6666666667px 24px 3px #00f7a5; -webkit-animation-name: flash-1; animation-name: flash-1; -webkit-animation-duration: 2s; animation-duration: 2s; } .lightrope li:nth-child(2n+1) { background: cyan; box-shadow: 0px 4.6666666667px 24px 3px rgba(0, 255, 255, 0.5); -webkit-animation-name: flash-2; animation-name: flash-2; -webkit-animation-duration: 0.4s; animation-duration: 0.4s; } .lightrope li:nth-child(4n+2) { background: #f70094; box-shadow: 0px 4.6666666667px 24px 3px #f70094; -webkit-animation-name: flash-3; animation-name: flash-3; -webkit-animation-duration: 1.1s; animation-duration: 1.1s; } .lightrope li:nth-child(odd) { -webkit-animation-duration: 1.8s; animation-duration: 1.8s; } .lightrope li:nth-child(3n+1) { -webkit-animation-duration: 1.4s; animation-duration: 1.4s; } .lightrope li:before { content: ""; position: absolute; background: #222; width: 10px; height: 9.3333333333px; border-radius: 3px; top: -4.6666666667px; left: 1px; } .lightrope li:after { content: ""; top: -14px; left: 9px; position: absolute; width: 52px; height: 18.6666666667px; border-bottom: solid #222 2px; border-radius: 50%; } .lightrope li:last-child:after { content: none; } .lightrope li:first-child { margin-left: -40px; } @-webkit-keyframes flash-1 { 0%, 100% { background: #00f7a5; box-shadow: 0px 4.6666666667px 24px 3px #00f7a5; } 50% { background: rgba(0, 247, 165, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(0, 247, 165, 0.2); } } @keyframes flash-1 { 0%, 100% { background: #00f7a5; box-shadow: 0px 4.6666666667px 24px 3px #00f7a5; } 50% { background: rgba(0, 247, 165, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(0, 247, 165, 0.2); } } @-webkit-keyframes flash-2 { 0%, 100% { background: cyan; box-shadow: 0px 4.6666666667px 24px 3px cyan; } 50% { background: rgba(0, 255, 255, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(0, 255, 255, 0.2); } } @keyframes flash-2 { 0%, 100% { background: cyan; box-shadow: 0px 4.6666666667px 24px 3px cyan; } 50% { background: rgba(0, 255, 255, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(0, 255, 255, 0.2); } } @-webkit-keyframes flash-3 { 0%, 100% { background: #f70094; box-shadow: 0px 4.6666666667px 24px 3px #f70094; } 50% { background: rgba(247, 0, 148, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(247, 0, 148, 0.2); } } @keyframes flash-3 { 0%, 100% { background: #f70094; box-shadow: 0px 4.6666666667px 24px 3px #f70094; } 50% { background: rgba(247, 0, 148, 0.4); box-shadow: 0px 4.6666666667px 24px 3px rgba(247, 0, 148, 0.2); } } /* Snow styling */ .snow { position: fixed; top: 0; left: 0; width: 100%; text-align: center; z-index: 50; overflow: none; /* Pass-through click events */ pointer-events: none; /* Encourage hardware acceleration */ /* 20vh per row of flakes - adjust falling animation too */ transform: translate3d(0, -20vh, 0); /* Flex used to space the i tags evenly horizontally. Plays nicely at inbetween widths */ /* Temporarily disable if you are adjusting the number of flakes on screen */ display:flex; justify-content: space-between; /* Allow for multi row snowflakes */ flex-wrap: wrap; } /* Generic styling of snowflakes, default animation and transform */ [class^="snow_flake"] { will-change: transform; display: inline-block; transform: translate3d(0, 0, 0); backface-visibility: hidden; perspective: 1000; animation: falling; animation-iteration-count: infinite; /* Filter is completely optional and may cause performance issues on low powered GPUs. */ /* filter: drop-shadow(0 1px 1px rgba(0,0,0,.125)) blur(1px); */ background-size: contain; background-repeat: no-repeat; backface-visibility: hidden; /* Snowflake image */ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96' fill='%23fff' fill-rule='evenodd'%3E%3Cpath d='M38.2 65l1-9.7 6.8-3.8v7.8L38.2 65zM58 65l-8-5.8v-7.8l6.8 4 1 9.6zm9.8-17l-9 3.8-6.6-3.8 7-4 8.6 4zm-39.4 0l8.7-4 7 4-6.5 3.8-8.8-4zM58 31l-1 9.6-7 4v-8l8-5.7zm-19.8 0l7.8 5.5v8l-6.7-3.8-1-9.8zm12-17L60.5 3.5l2.8 3-13.3 13v12L63 22l-1.7 16 10.2-5.7 5-18.3 4 1-4 14.4 12.2-7 2 3.6-12 7L93 37l-1.3 3.8-18.2-5-10.2 5.8L78 48l-14.7 6.4 10 5.6 18-5 1.2 4-14.3 3.8L90.6 70l-2 3.5L76 66.3l4 14.4-4 1-5-18.2-9.8-5.6L63 73.3 50 64v11.6L63.3 89l-2.8 3L50 81.5V96h-4V81.5L35.4 92l-2.8-3L46 75.8V64.4l-12.8 9.3 1.7-16-10.5 6-5 18-4-1 4-14.3-12.5 7L5 70l13-7.2-14.5-4 1-3.8L23 60l10-5.7L18.3 48l14.4-6.4-10.2-6-18.3 5-1-3.8 14.3-4-12.2-7 2-3.4 12.2 7-4-14.4 4-1 5 18.2 10.4 6-2-16 13 9.2V19.8L32.4 6.3l3-2.8L46 14V0h4v14z'/%3E%3C/svg%3E"); } /* Four sizes, each requires individual origins set */ [class^="snow_flake"]:nth-child(4n+0) { width: 2.5rem; height: 2.5rem; transform-origin: -5% -5%; } [class^="snow_flake"]:nth-child(4n+1) { width: 2rem; height: 2rem; transform-origin: 15% 0; } [class^="snow_flake"]:nth-child(4n+2) { width: 1.5rem; height: 1.5rem; transform-origin: 0 -30%; } [class^="snow_flake"]:nth-child(4n+3) { width: 1rem; height: 1rem; transform-origin: -100% -100%; } /* Keep first snowflake close to the edge */ [class^="snow_flake"]:first-child { transform-origin: 60% 40%; } /* Delay the start times */ [class^="snow_flake"]:nth-of-type(5n+0) { animation-delay: 0s; } [class^="snow_flake"]:nth-of-type(5n+1) { animation-delay: 2s; } [class^="snow_flake"]:nth-of-type(5n+2) { animation-delay: 4s; } [class^="snow_flake"]:nth-of-type(5n+3) { animation-delay: 6s; } [class^="snow_flake"]:nth-of-type(5n+4) { animation-delay: 8s; } /* Animation durations are calculated to be multiples of each other +/- a few seconds for initial delays */ [class^="snow_flake"]:nth-child(3n+0) { animation-duration: 12s; } [class^="snow_flake"]:nth-child(3n+1) { animation-duration: 18s; } [class^="snow_flake"]:nth-child(3n+2) { animation-duration: 24s; } /* Tweak timing functions - a tad more random */ [class^="snow_flake"]:nth-of-type(6n+0) { animation-timing-function: ease-in-out; } [class^="snow_flake"]:nth-of-type(6n+1) { animation-timing-function: ease-out; } [class^="snow_flake"]:nth-of-type(6n+2) { animation-timing-function: ease; } [class^="snow_flake"]:nth-of-type(6n+3) { animation-timing-function: ease-in; } [class^="snow_flake"]:nth-of-type(6n+4) { animation-timing-function: linear; } [class^="snow_flake"]:nth-of-type(6n+5) { animation-timing-function: cubic-bezier(0.2, 0.3, 0.8, 0.9); } /* Tweak opacity - more randomness */ [class^="snow_flake"]:nth-of-type(7n+0) {opacity: 0.6;} [class^="snow_flake"]:nth-of-type(7n+1) {opacity: 0.9;} [class^="snow_flake"]:nth-of-type(7n+2) {opacity: 0.5;} [class^="snow_flake"]:nth-of-type(7n+4) {opacity: 0.8;} [class^="snow_flake"]:nth-of-type(7n+6) {opacity: 0.7;} /* Filter is completely optional, and it may cause performance issues on low powered GPUs. */ [class^="snow_flake"]:nth-of-type(3n+0) { filter: drop-shadow(0 1px 1px rgba(0,0,0,.125)); } [class^="snow_flake"]:nth-of-type(3n+1) { filter: blur(1px); } /* Increase number of snowflakes at common device widths */ .snow_flake-600px, .snow_flake-768px, .snow_flake-1024px, .snow_flake-1280px, .snow_flake-1366px, .snow_flake-1440px, .snow_flake-1600px, .snow_flake-1800px, .snow_flake-1920px { display: none; } @media (min-width: 300px) { .snow_flake-600px { display: inline-block; } } @media (min-width: 600px) { .snow_flake-600px { display: inline-block; } } @media (min-width: 768px) { .snow_flake-768px { display: inline-block; } } @media (min-width: 1024px) { .snow_flake-1024px { display: inline-block; } } @media (min-width: 1280px) { .snow_flake-1280px { display: inline-block; } } @media (min-width: 1366px) { .snow_flake-1366px { display: inline-block; } } @media (min-width: 1600px) { .snow_flake-1600px { display: inline-block; } } @media (min-width: 1800px) { .snow_flake-1800px { display: inline-block; } } @media (min-width: 1920px) { .snow_flake-1920px { display: inline-block; } } /* Animation for all snowflakes */ @keyframes falling { from { transform: translate(0, 0) rotate(0deg) scale(0.8); } to { transform: translate(0, 120vh) rotate(360deg) scale(1.2); } } /* Falling leaves styling */ .leaves { position: fixed; top: 0; left: 0; width: 100%; text-align: center; z-index: 50; overflow: none; /* Pass-through click events */ pointer-events: none; /* Encourage hardware acceleration */ /* 20vh per row of leaves - adjust leaves-falling animation too */ transform: translate3d(0, -20vh, 0); /* Flex used to space the i tags evenly horizontally. Plays nicely at inbetween widths */ /* Temporarily disable if you are adjusting the number of leaves on screen */ display:flex; justify-content: space-between; /* Allow for multi row leaves */ flex-wrap: wrap; } /* Generic styling of leaves, default animation and transform */ [class^="leaf"] { will-change: transform; display: inline-block; transform: translate3d(0, 0, 0); backface-visibility: hidden; perspective: 1000; animation: leaves-falling; animation-iteration-count: infinite; /* Filter is completely optional and may cause performance issues on low powered GPUs. */ /* filter: drop-shadow(0 1px 1px rgba(0,0,0,.125)) blur(1px); */ background-size: contain; background-repeat: no-repeat; backface-visibility: hidden; /* Leaf image */ background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' width='50px' height='60px' viewBox='0 0 50 60' enable-background='new 0 0 50 60' xml:space='preserve'%3E%3Cimage id='image0' width='50' height='60' x='0' y='0' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAA8CAYAAAAkNenBAAAABGdBTUEAALGPC/xhBQAAACBjSFJN%0AAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAA%0ACXBIWXMAABJ0AAASdAHeZh94AAAAB3RJTUUH5QEBFQEIAqy2rAAAFVFJREFUaN7NmnnUZ0V55z9V%0Adetuv/Xdt96hG+wB2SZoQM6AigtGJsGRgJlROJyBOc6JwTEGzajRDJnDSVyik2gwJDlmokZNFBJj%0ANAM6A8gOEdLsdPfb3W93v/tvvfutW/NHxj4hQNO0EuY55/5xt7r1uc+3nqp6zoO1llf6SFeXmP/S%0AZ4+c7/njT3HPR6954KW04fD/gT145ZtstrpGudb5Lyvf+dqnh2lE+OozXlIb8uXoWH/f00e9X6Qx%0AB++7HYDOd79OsrZK7tY4/N1bPl14DUq3SVnaVx7klvN22O/8x3cc6ckjv/vRZ92///Jz7J3vudAC%0ALH/lD+34pp0gFRkKKzVVWWFfIshPXVrL3/4zmiMt5I/u4eaff50N84iVx37EzIXvEBP/6nSe+uA7%0AbNHrMTW3gwcvf4O1FeAo6s0R4iRlvbJoAcsLCy/pu8Lal0b+QmaLnANf/X3W/u6bdvXgIRzhcrgw%0AeFVFSEV42s+wYeerp5e+ddNiL3cZmZ7AVC5FVSG1Q2c4JDaGhnZx0yHd/hr+aWdw8R/+tTiW77+o%0AtO679AILsP/mr/HgjZ954T8iFcuf+Yg9sGcfvuezJjQ1x+WQleA4dO6/m6f//IuLmVenEBVaeKRY%0AKg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54U+qSrhbQVWhRo7eK4Hr4vWV7uMtLyaTcdgrBGrdFA+zVc18VVEoeYOz5/wU+n%0ABOknAQEQQGPnFUxfeo9onHmtiNJ1qDpUZcX9e4ecstlFiII86yGqBE8OcW2KJ0rcSlKsLDJcnn9Z%0AQY6rXssAS498hdv+9Fp7+7zmYx/5vHBkhFebQCkNSKR2iVcX6a7Nr5/0+mtfdmkdV/BWwH333XbD%0A3qHLtb/+p2Lj6a9/3ucaczAFLzsEwHGVt/7FF67mI1eO23t/8LVXvNT2uMtl//x/XMWuB79lz3nL%0ABx88+/xL/0V+9rHYS6oyvflPPrD+8P232I0nv5WLLvvwv36lO39cIH/5R7/69R/e9uWRzSdfyDUf%0A+vIx1xr+i9mxanBlcQ9fvOFy+0qPhRc6/i/vSAlju+8zPQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAy%0AMS0wMS0wMVQyMTowMTowOCswMDowMILrK4oAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDEtMDFU%0AMjE6MDE6MDgrMDA6MDDztpM2AAAAAElFTkSuQmCC' /%3E%3C/svg%3E%0A"); } /* Four sizes, each requires individual origins set */ [class^="leaf"]:nth-child(4n+0) { width: 2.5rem; height: 2.5rem; transform-origin: -5% -5%; } [class^="leaf"]:nth-child(4n+1) { width: 2rem; height: 2rem; transform-origin: 15% 0; } [class^="leaf"]:nth-child(4n+2) { width: 1.5rem; height: 1.5rem; transform-origin: 0 -30%; } [class^="leaf"]:nth-child(4n+3) { width: 1rem; height: 1rem; transform-origin: -100% -100%; } /* Keep first leaf close to the edge */ [class^="leaf"]:first-child { transform-origin: 60% 40%; } /* Delay the start times */ [class^="leaf"]:nth-of-type(5n+0) { animation-delay: 0s; } [class^="leaf"]:nth-of-type(5n+1) { animation-delay: 2s; } [class^="leaf"]:nth-of-type(5n+2) { animation-delay: 4s; } [class^="leaf"]:nth-of-type(5n+3) { animation-delay: 6s; } [class^="leaf"]:nth-of-type(5n+4) { animation-delay: 8s; } /* Animation durations are calculated to be multiples of each other +/- a few seconds for initial delays */ [class^="leaf"]:nth-child(3n+0) { animation-duration: 12s; } [class^="leaf"]:nth-child(3n+1) { animation-duration: 18s; } [class^="leaf"]:nth-child(3n+2) { animation-duration: 24s; } /* Tweak timing functions - a tad more random */ [class^="leaf"]:nth-of-type(6n+0) { animation-timing-function: ease-in-out; } [class^="leaf"]:nth-of-type(6n+1) { animation-timing-function: ease-out; } [class^="leaf"]:nth-of-type(6n+2) { animation-timing-function: ease; } [class^="leaf"]:nth-of-type(6n+3) { animation-timing-function: ease-in; } [class^="leaf"]:nth-of-type(6n+4) { animation-timing-function: linear; } [class^="leaf"]:nth-of-type(6n+5) { animation-timing-function: cubic-bezier(0.2, 0.3, 0.8, 0.9); } /* Tweak opacity - more randomness */ [class^="leaf"]:nth-of-type(7n+0) {opacity: 0.6;} [class^="leaf"]:nth-of-type(7n+1) {opacity: 0.9;} [class^="leaf"]:nth-of-type(7n+2) {opacity: 0.5;} [class^="leaf"]:nth-of-type(7n+4) {opacity: 0.8;} [class^="leaf"]:nth-of-type(7n+6) {opacity: 0.7;} /* Filter is completely optional, and it may cause performance issues on low powered GPUs. */ [class^="leaf"]:nth-of-type(3n+0) { filter: drop-shadow(0 1px 1px rgba(0,0,0,.125)); } /* Increase number of snowflakes at common device widths */ .leaf-600px, .leaf-768px, .leaf-1024px, .leaf-1280px, .leaf-1366px, .leaf-1440px, .leaf-1600px, .leaf-1800px, .leaf-1920px { display: none; } @media (min-width: 300px) { .leaf-600px { display: inline-block; } } @media (min-width: 600px) { .leaf-600px { display: inline-block; } } @media (min-width: 768px) { .leaf-768px { display: inline-block; } } @media (min-width: 1024px) { .leaf-1024px { display: inline-block; } } @media (min-width: 1280px) { .leaf-1280px { display: inline-block; } } @media (min-width: 1366px) { .leaf-1366px { display: inline-block; } } @media (min-width: 1600px) { .leaf-1600px { display: inline-block; } } @media (min-width: 1800px) { .leaf-1800px { display: inline-block; } } @media (min-width: 1920px) { .leaf-1920px { display: inline-block; } } /* Animation for all leaves */ @keyframes leaves-falling { from { transform: translate(0, 0) rotate(0deg) scale(0.8); } to { transform: translate(0, 120vh) rotate(360deg) scale(1.2); } } /* Heart Animation Styling */ @keyframes heartfade { 0% { opacity: 1; } 50% { opacity: 0; } } .heart { z-index: 50; animation: heartfade 6s linear; position: absolute; } .heart:before, .heart:after { content: ""; background-color: #fc2a62; position: absolute; height: 30px; width: 45px; border-radius: 15px 0px 0px 15px; } .heart:before { transform: rotate(45deg); } .heart:after { left: 10.5px; transform: rotate(135deg); }`; var styleSheet = document.createElement('style'); styleSheet.type = 'text/css'; styleSheet.innerText = styles; document.head.appendChild(styleSheet); function generateHeartsOnClick() { function generateHeart(x, y, xBound, xStart, scale) { var heart = document.createElement('div'); heart.setAttribute('class', 'heart'); brd.appendChild(heart); heart.time = duration; heart.x = x; heart.y = y; heart.bound = xBound; heart.direction = xStart; heart.style.left = heart.x + 'px'; heart.style.top = heart.y + 'px'; heart.scale = scale; heart.style.transform = 'scale(' + scale + ',' + scale + ')'; if (hearts === null) hearts = []; hearts.push(heart); return heart; } function frame() { var current = Date.now(); var deltaTime = current - before; before = current; for (i in hearts) { var heart = hearts[i]; heart.time -= deltaTime; if (heart.time > 0) { heart.y -= speed; heart.style.top = heart.y + 'px'; heart.style.left = heart.x + heart.direction * heart.bound * Math.sin(heart.y * heart.scale / 30) / heart.y * 100 + "px"; } else { heart.parentNode.removeChild(heart); hearts.splice(i, 1); } } } function check() { if (down) { var start = 1 - Math.round(Math.random()) * 2; var scale = Math.random() * Math.random() * 0.8 + 0.2; var bound = 30 + Math.random() * 20; generateHeart(event.pageX - brd.offsetLeft + cursorXOffset, event.pageY - brd.offsetTop + cursorYOffset, bound, start, scale); } } var brd = document.createElement('div'); document.body.insertBefore(brd, document.getElementById('board')); var duration = 3000; var speed = 0.5; var cursorXOffset = 0; var cursorYOffset = 195; var hearts = []; var down = false; var event = null; document.onmousedown = function (e) { down = true; event = e; }; document.onmouseup = function (e) { down = false; }; document.onmousemove = function (e) { event = e; }; document.ontouchstart = function (e) { down = true; event = e.touches[0]; }; document.ontouchend = function (e) { down = false; }; document.ontouchmove = function (e) { event = e.touches[0]; }; var before = Date.now(); var id = setInterval(frame, 5); var gr = setInterval(check, 100); } function putUpChristmasLights() { var div = document.createElement('div'); div.id = 'christmasLights'; var ul = document.createElement('ul'); ul.setAttribute('class','lightrope'); for(var i=0; i<50; i++) { var li = document.createElement('li'); ul.appendChild(li); } div.appendChild(ul); document.body.insertBefore(div, document.body.childNodes[0]); } function letItSnow() { var div = document.createElement('div'); div.className = 'snow'; div.innerHTML = ` <i class=snow_flake></i> <i class=snow_flake></i> <i class=snow_flake></i> <i class=snow_flake-600px></i> <i class=snow_flake-600px></i> <i class=snow_flake-600px></i> <i class=snow_flake-600px></i> <i class=snow_flake-768px></i> <i class=snow_flake-768px></i> <i class=snow_flake-1024px></i> <i class=snow_flake-1024px></i> <i class=snow_flake-1024px></i> <i class=snow_flake-1280px></i> <i class=snow_flake-1280px></i> <i class=snow_flake-1366px></i> <i class=snow_flake-1600px></i> <i class=snow_flake-1600px></i> <i class=snow_flake-1800px></i> <i class=snow_flake-1800px></i> <i class=snow_flake-1920px></i> <i class=snow_flake-1920px></i>`; document.body.insertBefore(div, document.body.childNodes[0]); } function leavesAreFalling() { var div = document.createElement('div'); div.className = 'leaves'; div.innerHTML = ` <i class=leaf></i> <i class=leaf></i> <i class=leaf-600px></i> <i class=leaf-768px></i> <i class=leaf-1024px></i> <i class=leaf-1280px></i> <i class=leaf-1366px></i> <i class=leaf-1600px></i> <i class=leaf-1800px></i> <i class=leaf-1920px></i>`; document.body.insertBefore(div, document.body.childNodes[0]); } // Get the current date var currentDate = new Date(); // Get the numeric representation of the month. // JavaScripts starts with month 0, so we add 1 var currentMonth = currentDate.getMonth() + 1; // Get the day of the month var currentDay = currentDate.getDate(); // Autumn Actions if (currentMonth === 9 || currentMonth === 10 || currentMonth === 11) { // Leaves fall during the Autumn months leavesAreFalling(); } // Winter Actions if (currentMonth === 12 || currentMonth === 1 || currentMonth === 2) { // It snows during the Winter months letItSnow(); // We put up the Christmas lights in December if (currentMonth === 12) { putUpChristmasLights(); } // On Valentine's Day generate little hearts on click if (currentMonth === 2 && currentDay === 14) { generateHeartsOnClick(); } } /* For testing */ // letItSnow(); // leavesAreFalling(); // putUpChristmasLights(); // generateHeartsOnClick(); });