Commit 3e066192afe0e2526a7c7fb27edc12975fff2216
future past
nomand committed on 6/6/2018, 11:41:33 AMParent: 1f6537ee5b47f8d5332b0334c11845264d6264d9
Files changed
js/letnice.js | changed |
js/letnice.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 | base.innerHTML = ""; |
5 | 5 | let year; |
6 | 6 | |
7 | 7 | isNaN(letnice) || letnice==null ? year = new Date().getFullYear() : year = String(letnice).replace("#", "").substr(0,4); |
8 | - location.hash = year; | |
8 | + window.location.hash = year; | |
9 | 9 | |
10 | 10 | const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; |
11 | 11 | const dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ] |
12 | 12 | |
@@ -28,15 +28,18 @@ | ||
28 | 28 | } |
29 | 29 | |
30 | 30 | function doHeader() |
31 | 31 | { |
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>`; | |
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>`; | |
33 | 33 | } |
34 | 34 | |
35 | 35 | function yearProgress(year) |
36 | 36 | { |
37 | - progress = new Date() - new Date(year, 0, 1, 0); | |
38 | - return ((progress/31536000000)*100).toFixed(2); | |
37 | + diff = new Date() - new Date(year, 0, 1, 0); | |
38 | + progress = ((diff/31536000000)*100).toFixed(2); | |
39 | + yd = Math.abs((progress / 100).toFixed(2)); | |
40 | + | |
41 | + return progress < 0 ? yd + ` YEARS AWAY` : progress > 100 ? yd + ` YEARS AGO` : progress+"%"; | |
39 | 42 | } |
40 | 43 | |
41 | 44 | function doLabels() |
42 | 45 | { |
Built with git-ssb-web