js/letnice.jsView |
---|
1 | | -function Year() |
| 1 | +function Year(y) |
2 | 2 | { |
3 | 3 | let base = document.getElementById("center"); |
4 | | - |
| 4 | + |
5 | 5 | const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; |
6 | 6 | const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] |
7 | 7 | |
8 | | - let year = new Date().getFullYear(); |
| 8 | + let year = y; |
| 9 | + window.location.hash = year; |
| 10 | + |
9 | 11 | let month = 0; |
10 | 12 | let today = new Date(year, new Date().getMonth(), new Date().getDate()-1, 0); |
11 | 13 | let style = "day"; |
12 | 14 | |
23 | 25 | } |
24 | 26 | |
25 | 27 | function doHeader() |
26 | 28 | { |
27 | | - return `<div class="header"><p class="y">${year}</p><p class="p">${yearProgress(year) + "%"}</p></div>`; |
| 29 | + 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>`; |
28 | 30 | } |
29 | 31 | |
30 | 32 | function yearProgress(year) |
31 | 33 | { |
91 | 93 | } |
92 | 94 | } |
93 | 95 | return html; |
94 | 96 | } |
| 97 | +} |
| 98 | + |
| 99 | +function changeHash(i) |
| 100 | +{ |
| 101 | + location.hash = parseInt(location.hash.replace('#','')) + parseInt(i); |
| 102 | +} |
| 103 | + |
| 104 | +window.onhashchange = function() |
| 105 | +{ |
| 106 | + if (location.hash.length > 0) |
| 107 | + { |
| 108 | + Year(parseInt(location.hash.replace('#',''))); |
| 109 | + } |
95 | 110 | } |