js/letnice.jsView |
---|
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" ] |
5 | 3 | |
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 | 4 | function Year(letnice) |
10 | 5 | { |
11 | 6 | let base = document.getElementById("center"); |
12 | 7 | base.innerHTML = ""; |
14 | 9 | |
15 | 10 | isNaN(letnice) || letnice==null ? year = new Date().getFullYear() : year = String(letnice).replace("#", "").substr(0,4); |
16 | 11 | window.location.hash = year; |
17 | 12 | |
18 | | - |
19 | | - |
20 | 13 | let month = 0; |
21 | 14 | let today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()-1, 0); |
22 | 15 | let style = ""; |
23 | 16 | let footer = ""; |
39 | 32 | footer = document.getElementById("footer"); |
40 | 33 | |
41 | 34 | function doHeader() |
42 | 35 | { |
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>`; |
44 | 37 | } |
45 | 38 | |
46 | 39 | function doFooter(content) |
47 | 40 | { |
108 | 101 | else |
109 | 102 | { |
110 | 103 | style = "day"; |
111 | 104 | } |
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>` |
113 | 106 | week++ |
114 | 107 | date++ |
115 | 108 | } |
116 | 109 | } |
117 | 110 | return html; |
118 | 111 | } |
119 | 112 | } |
120 | 113 | |
121 | | -function scrollYear(i) |
| 114 | +function UpdateFooter(year, month, date, week) |
122 | 115 | { |
| 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 | +{ |
123 | 126 | location.hash = parseInt(location.hash.replace('#','')) + parseInt(i); |
124 | 127 | } |
125 | 128 | |
126 | 129 | window.onhashchange = function() |