function Year() { let base = document.getElementById("center"); const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] let year = new Date().getFullYear(); let month = 0; let style = "day"; function doHeader() { return `

${year}

${yearProgress(2018) + "%"}

`; } while(month < 12) { base.innerHTML += `
${month==0?doHeader():""}

${monthNames[new Date(year, month).getMonth()].substr(0,2)}

${doLabels()} ${doMonth(month)}
` month++ } function doLabels() { let html = ""; let y = 0; for(i = 0; i < 7; i++) { y = (i * 14)+1; html += `${dayNames[i].substr(0,1)}` } return html; } function doMonth(month) { html = ""; monthLength = new Date(year, month+1, 0).getDate(); let date = 0; let x = 0; let y = 0; while(date < monthLength) { x += 14; let week = 0 while(week < 7 && date != monthLength) { y = week * 14 + 2; let day = new Date(year, month, date); if(day.getDay() != week) { style = "null"; date-- } else if(day < new Date()) { style = "gone"; } else if(day.getDay() == 5 || day.getDay() == 6) { style = "weekend"; } else { style = "day"; } html += `` week++ date++ } } return html; } function yearProgress(year) { progress = new Date() - new Date(year, 0, 1, 0); return (progress/31536000000).toFixed(2); } }