git ssb

0+

Rômulo Alves / dat-letnice



Commit 124dbb2584f5552a836d76f360f5dbea2f44567c

date readout

nomand committed on 6/8/2018, 8:58:33 AM
Parent: ef0751d9471c9b98e2d6b16b219973f15ec53912

Files changed

css/style.csschanged
js/letnice.jschanged
css/style.cssView
@@ -23,9 +23,9 @@
2323 }
2424
2525 .month { margin: 10px; display: inline-block; width:100px; height: 130px; }
2626 .header { margin: 0px 0px 40px 10px; text-align: left; align-content: flex-start;}
27-.footer { margin: 20px 0px 0px 10px; text-align: left; height: 20px;}
27+.footer { margin: 20px 0px 0px 10px; text-align: left; height: 20px; }
2828
2929 p { margin: 0px; }
3030
3131 .y { font-size: 40px; font-weight: bold; }
@@ -38,9 +38,9 @@
3838 svg.graph { color:white; width: 100%; height: 100px; }
3939 svg.graph text {font-family: 'input_mono_regular'; stroke:none; fill:#8b8b8b; font-size:14px; text-anchor: middle; }
4040 svg.graph text.dayLabel { font-size: 10px; }
4141 svg.graph rect { stroke:none; }
42-svg.graph rect:hover { fill: #f011f0 !important; cursor:pointer}
42+svg.graph rect:hover { fill: #ff1e00 !important; cursor:pointer}
4343 svg.graph rect.null { fill: none; stroke: none;}
4444 svg.graph rect.today { fill:#ff1e00; }
4545 svg.graph rect.day { fill:#8b8b8b; }
4646 svg.graph rect.weekend { fill:#747474 }
js/letnice.jsView
@@ -1,12 +1,7 @@
1-function UpdateFooter(month, date)
2-{
3- footer.innerHTML = `${monthNames[month]}, ${date}`;
4-}
1+const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
2+const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
53
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-
94 function Year(letnice)
105 {
116 let base = document.getElementById("center");
127 base.innerHTML = "";
@@ -14,10 +9,8 @@
149
1510 isNaN(letnice) || letnice==null ? year = new Date().getFullYear() : year = String(letnice).replace("#", "").substr(0,4);
1611 window.location.hash = year;
1712
18-
19-
2013 let month = 0;
2114 let today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()-1, 0);
2215 let style = "";
2316 let footer = "";
@@ -39,9 +32,9 @@
3932 footer = document.getElementById("footer");
4033
4134 function doHeader()
4235 {
43- return `<div class="header"><p class="y">${year}<a onclick="scrollYear(-1);">-</a><a onclick="scrollYear(1);">+</a></p><p class="p">${yearProgress(year)}</p></div>`;
36+ return `<div class="header"><p class="y">${year}<a onclick="getYear(-1);">-</a><a onclick="getYear(1);">+</a></p><p class="p">${yearProgress(year)}</p></div>`;
4437 }
4538
4639 function doFooter(content)
4740 {
@@ -108,19 +101,29 @@
108101 else
109102 {
110103 style = "day";
111104 }
112- 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="UpdateFooter('${month}', '${(date+1)}')"></rect>`
105+ 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="UpdateFooter('${year}', '${month}', '${(date+1)}', '${week}')"></rect>`
113106 week++
114107 date++
115108 }
116109 }
117110 return html;
118111 }
119112 }
120113
121-function scrollYear(i)
114+function UpdateFooter(year, month, date, week)
122115 {
116+ let diff = ((new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0) - new Date(year, month, date))/86400000);
117+ let num = Math.abs(diff).toFixed();
118+ let calc;
119+
120+ diff < 0 ? calc = `In ${num} Day${num>1?'s':''}.` : diff == 0 ? calc = `Today.`: calc = `${num} Day${num>1?'s':''} ago.`
121+ footer.innerHTML = `${monthNames[month]} ${date}, ${dayNames[week]}. ${calc}`;
122+}
123+
124+function getYear(i)
125+{
123126 location.hash = parseInt(location.hash.replace('#','')) + parseInt(i);
124127 }
125128
126129 window.onhashchange = function()

Built with git-ssb-web