js/letnice.jsView |
---|
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" ] |
3 | | - |
4 | | -function Year(y) |
| 1 | +function Year(letnice) |
5 | 2 | { |
6 | 3 | let base = document.getElementById("center"); |
| 4 | + base.innerHTML = ""; |
| 5 | + let year; |
7 | 6 | |
8 | | - let year = String(y).replace("#", ""); |
| 7 | + isNaN(letnice) ? year = new Date().getFullYear() : year = String(letnice).replace("#", "").substr(0,4); |
9 | 8 | |
| 9 | + location.hash = year; |
| 10 | + |
| 11 | + const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; |
| 12 | + const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] |
| 13 | + |
10 | 14 | let month = 0; |
11 | | - let today = new Date(year, new Date().getMonth(), new Date().getDate()-1, 0); |
| 15 | + let today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()-1, 0); |
12 | 16 | let style = ""; |
13 | | - |
| 17 | + |
14 | 18 | while(month < 12) |
15 | 19 | { |
16 | 20 | base.innerHTML += `<div class="month"> |
17 | 21 | ${month==0?doHeader():""} |
24 | 28 | } |
25 | 29 | |
26 | 30 | function doHeader() |
27 | 31 | { |
28 | | - return `<div class="header"><p class="y">${year}<a onclick="changeHash(1);">+</a><a onclick="changeHash(-1);">-</a></p><p class="p">${yearProgress(year) + "%"}</p></div>`; |
| 32 | + 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>`; |
29 | 33 | } |
30 | 34 | |
31 | 35 | function yearProgress(year) |
32 | 36 | { |
63 | 67 | while(week < 7 && date != monthLength) |
64 | 68 | { |
65 | 69 | y = week * 14 + 2; |
66 | 70 | let day = new Date(year, month, date, 0); |
67 | | - |
| 71 | + |
68 | 72 | if(day.getDay() != week) |
69 | 73 | { |
70 | 74 | style = "null"; |
71 | 75 | date-- |
94 | 98 | return html; |
95 | 99 | } |
96 | 100 | } |
97 | 101 | |
98 | | -function changeHash(i) |
| 102 | +function scrollYear(i) |
99 | 103 | { |
100 | 104 | location.hash = parseInt(location.hash.replace('#','')) + parseInt(i); |
101 | 105 | } |
102 | 106 | |