git ssb

0+

Rômulo Alves / dat-letnice



Tree: 90bca5c148200ba5c7993f3c8c2bf41653877172

Files: 90bca5c148200ba5c7993f3c8c2bf41653877172 / js / letnice.js

1884 bytesRaw
1function Year()
2{
3 let base = document.getElementById("center");
4 let year = new Date().getFullYear();
5
6 const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
7 const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
8
9 let count = 1;
10 let month = 0;
11
12 let style = "day";
13
14 base.innerHTML += `<p class="y">${year}</p>`
15
16 while(month < 12)
17 {
18 base.innerHTML += `
19 <div class="month">
20 <p class="m">${monthNames[new Date(year, month).getMonth()].substr(0,3)}</p>
21 <svg class="graph" id="${monthNames[month]}">
22 ${dayLabels()}
23 ${populateMonth(month)}
24 </svg></div>`
25 month++
26 }
27
28 function dayLabels()
29 {
30 let html = "";
31 let y = 0;
32
33 for(i = 0; i < 7; i++)
34 {
35 y = i * 14;
36 html += `<text class="dayLabel" x="5" y='${y}' dy="10">${dayNames[i].substr(0,1)}</text>`
37 }
38 return html;
39 }
40
41 function populateMonth(month)
42 {
43 html = "";
44 monthLength = new Date(year, month+1, 0).getDate();
45 let date = 0;
46 let x = 0;
47 let y = 0;
48
49 while(date < monthLength)
50 {
51 x += 14;
52 let week = 0
53
54 while(week < 7 && date != monthLength)
55 {
56 y = week * 14;
57 let day = new Date(year, month, date);
58
59 console.log(day);
60 console.log(new Date().getMonth());
61
62 if(day.getDay() != week)
63 {
64 style = "null";
65 date--
66 }
67 else if(day == new Date())
68 {
69 style = "today";
70 }
71 else
72 {
73 style = "day";
74 }
75
76 html += `<rect class='${style}' x='${x}' y='${y}' title='${date+1}' width="12px" height="12px" rx="2" ry="2" onclick=""></rect>`
77 week++
78 date++
79 count++
80 }
81 }
82 return html;
83 }
84
85}

Built with git-ssb-web