git ssb

0+

Rômulo Alves / dat-letnice



Commit 92b6ea22d3063d3c4ba129b9b83fb81efddf48d2

today

nomand committed on 6/5/2018, 11:43:26 AM
Parent: d08a3a6601b13e0a142432e22e7a18003d16f0db

Files changed

css/style.csschanged
js/letnice.jschanged
css/style.cssView
@@ -34,9 +34,9 @@
3434 svg.graph text {font-family: 'input_mono_regular'; stroke:none; fill:#8b8b8b; font-size:14px; text-anchor: middle; }
3535 svg.graph text.dayLabel { font-size: 10px; }
3636 svg.graph rect { stroke:none }
3737 svg.graph rect.null { fill: none; stroke: none;}
38-svg.graph rect.today { fill:#ffffff; stroke: #000000;}
38+svg.graph rect.today { fill:#ff1e00; }
3939 svg.graph rect.day { fill:#8b8b8b; }
4040 svg.graph rect.weekend { fill:#747474 }
4141 svg.graph rect.gone { fill:#000000 }
4242 svg.graph path { stroke-linecap: butt; stroke-dasharray: 1,1; fill:none; stroke:#333; stroke-width:13px }
js/letnice.jsView
@@ -2,18 +2,14 @@
22 {
33 let base = document.getElementById("center");
44
55 const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
6- const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
6+ const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
77
88 let year = new Date().getFullYear();
99 let month = 0;
10+ let today = new Date(year, new Date().getMonth(), new Date().getDate()-1, 0);
1011 let style = "day";
11-
12- function doHeader()
13- {
14- return `<div class="header"><p class="y">${year}</p><p class="p">${yearProgress(year) + "%"}</p></div>`;
15- }
1612
1713 while(month < 12)
1814 {
1915 base.innerHTML += `<div class="month">
@@ -25,16 +21,27 @@
2521 </svg></div>`
2622 month++
2723 }
2824
25+ function doHeader()
26+ {
27+ return `<div class="header"><p class="y">${year}</p><p class="p">${yearProgress(year) + "%"}</p></div>`;
28+ }
29+
30+ function yearProgress(year)
31+ {
32+ progress = new Date() - new Date(year, 0, 1, 0);
33+ return ((progress/31536000000)*100).toFixed(2);
34+ }
35+
2936 function doLabels()
3037 {
3138 let html = "";
3239 let y = 0;
3340
3441 for(i = 0; i < 7; i++)
3542 {
36- y = (i * 14)+1;
43+ y = (i * 14) + 1;
3744 html += `<text class="dayLabel" x="5" y='${y}' dy="10">${dayNames[i].substr(0,1)}</text>`
3845 }
3946 return html;
4047 }
@@ -45,20 +52,19 @@
4552 monthLength = new Date(year, month+1, 0).getDate();
4653 let date = 0;
4754 let x = 0;
4855 let y = 0;
49- let today = new Date(year, new Date().getMonth(), new Date().getDate(), 0);
50-
56+
5157 while(date < monthLength)
5258 {
5359 x += 14;
54- let week = 0
60+ let week = 0;
5561
5662 while(week < 7 && date != monthLength)
5763 {
5864 y = week * 14 + 2;
59- let day = new Date(year, month, date);
60-
65+ let day = new Date(year, month, date, 0);
66+
6167 if(day.getDay() != week)
6268 {
6369 style = "null";
6470 date--
@@ -70,23 +76,20 @@
7076 else if(day.getDay() == 5 || day.getDay() == 6)
7177 {
7278 style = "weekend";
7379 }
80+ else if(String(day) == String(today))
81+ {
82+ style = "today";
83+ }
7484 else
7585 {
7686 style = "day";
7787 }
78-
79- html += `<rect class='${style}' x='${x}' y='${y}' title='${dayNames[week] + "_" + (date+1)}' width="12px" height="12px" rx="2" ry="2" onclick=""></rect>`
88+ html += `<rect class='${style}' x='${x}' y='${y}' title='${(date+1) == 0 ? "null" : dayNames[week] + " " + (date+1)}' width="12px" height="12px" rx="2" ry="2" onclick=""></rect>`
8089 week++
8190 date++
8291 }
8392 }
8493 return html;
8594 }
86-
87- function yearProgress(year)
88- {
89- progress = new Date() - new Date(year, 0, 1, 0);
90- return ((progress/31536000000)*100).toFixed(2);
91- }
9295 }

Built with git-ssb-web