git ssb

0+

Rômulo Alves / dat-letnice



Tree: f5d74ba1c132d473aa200f852562f7954b512854

Files: f5d74ba1c132d473aa200f852562f7954b512854 / js / letnice.js

1946 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)-1;
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 if(day.getDay() != week)
60 {
61 style = "null";
62 date--
63 }
64 else if(day.getDay() == 5 || day.getDay() == 6)
65 {
66 style = "weekend";
67 }
68 else if(day == new Date())
69 {
70 style = "today";
71 }
72 else
73 {
74 style = "day";
75 }
76
77 html += `<rect class='${style}' x='${x}' y='${y}' title='${dayNames[week] + "_" + (date+1)}' width="12px" height="12px" rx="2" ry="2" onclick=""></rect>`
78 week++
79 date++
80 count++
81 }
82 }
83 return html;
84 }
85}

Built with git-ssb-web