highlighting upcoming holiday
This commit is contained in:
parent
1494a7cd24
commit
bd8a17b2cc
51
index.html
51
index.html
|
@ -174,6 +174,8 @@ const utcs = { "UTC-11" : "-11", "UTC-10" : "-10", "UTC-9" : "-9",
|
||||||
"UTC+10" : "10", "UTC+11" : "11" };
|
"UTC+10" : "10", "UTC+11" : "11" };
|
||||||
var buttons = "";
|
var buttons = "";
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
var nextholiday = false;
|
||||||
|
var currentholiday = false;
|
||||||
for (var u in utcs) {
|
for (var u in utcs) {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
buttons += '<input type="button" onclick="document.getElementById(' + "'soltable'" + ').innerHTML = makeTable(';
|
buttons += '<input type="button" onclick="document.getElementById(' + "'soltable'" + ').innerHTML = makeTable(';
|
||||||
|
@ -226,18 +228,38 @@ function tableRow(cy, timeoutput, UTC, oneyearinp = false) {
|
||||||
else stringout += cy;
|
else stringout += cy;
|
||||||
}
|
}
|
||||||
var Imbolc = new Date(ss[cy-1].getTime() + ((ve[cy].getTime() - ss[cy-1].getTime()) / 2));
|
var Imbolc = new Date(ss[cy-1].getTime() + ((ve[cy].getTime() - ss[cy-1].getTime()) / 2));
|
||||||
stringout += '<td class = "even">' + formatedDate(Imbolc, timeoutput, UTC) + "</td>";
|
stringout += '<td class="even im">' + formatedDate(Imbolc, timeoutput, UTC) + "</td>";
|
||||||
stringout += '<td>' + formatedDate(ve[cy], timeoutput, UTC) + "</td>";
|
stringout += '<td class="os">' + formatedDate(ve[cy], timeoutput, UTC) + "</td>";
|
||||||
var Beltane = new Date(ve[cy].getTime() + ((ns[cy].getTime() - ve[cy].getTime()) / 2));
|
var Beltane = new Date(ve[cy].getTime() + ((ns[cy].getTime() - ve[cy].getTime()) / 2));
|
||||||
stringout += '<td class = "even">' + formatedDate(Beltane, timeoutput, UTC) + "</td>";
|
stringout += '<td class="even be">' + formatedDate(Beltane, timeoutput, UTC) + "</td>";
|
||||||
stringout += '<td>' + formatedDate(ns[cy], timeoutput, UTC) + "</td>";
|
stringout += '<td class="ku">' + formatedDate(ns[cy], timeoutput, UTC) + "</td>";
|
||||||
var Lughnasadh = new Date(ns[cy].getTime() + ((ae[cy].getTime() - ns[cy].getTime()) / 2));
|
var Lughnasadh = new Date(ns[cy].getTime() + ((ae[cy].getTime() - ns[cy].getTime()) / 2));
|
||||||
stringout += '<td class = "even">' + formatedDate(Lughnasadh, timeoutput, UTC) + "</td>";
|
stringout += '<td class="even lu">' + formatedDate(Lughnasadh, timeoutput, UTC) + "</td>";
|
||||||
stringout += '<td>' + formatedDate(ae[cy], timeoutput, UTC) + "</td>";
|
stringout += '<td class="ma">' + formatedDate(ae[cy], timeoutput, UTC) + "</td>";
|
||||||
var Samhain = new Date(ae[cy].getTime() + ((ss[cy].getTime() - ae[cy].getTime()) / 2));
|
var Samhain = new Date(ae[cy].getTime() + ((ss[cy].getTime() - ae[cy].getTime()) / 2));
|
||||||
stringout += '<td class = "even">' + formatedDate(Samhain, timeoutput, UTC) + "</td>";
|
stringout += '<td class="even sa">' + formatedDate(Samhain, timeoutput, UTC) + "</td>";
|
||||||
stringout += '<td>' + formatedDate(ss[cy], timeoutput, UTC) + "</td>";
|
stringout += '<td class="yu">' + formatedDate(ss[cy], timeoutput, UTC) + "</td>";
|
||||||
return stringout;
|
|
||||||
|
if (cy == now.getFullYear()) {
|
||||||
|
var wheeldaystime = [ ss[cy-1].getTime(), Imbolc.getTime(), ve[cy].getTime(), Beltane.getTime(),
|
||||||
|
ns[cy].getTime(), Lughnasadh.getTime(), ae[cy].getTime(), Samhain.getTime(),
|
||||||
|
ss[cy].getTime(), ve[cy+1].getTime()]
|
||||||
|
var wheeldays = [ "prev", "im", "os", "be", "ku", "lu", "ma", "sa", "yu", "next" ]
|
||||||
|
Number.prototype.isBetween = function (a, b) {
|
||||||
|
return a <= this && this <= b;
|
||||||
|
};
|
||||||
|
for (let i = 1; i < 10; i++) {
|
||||||
|
if ((Date.now()).isBetween(wheeldaystime[i-1], wheeldaystime[i]))
|
||||||
|
nextholiday = i;
|
||||||
|
}
|
||||||
|
if ((wheeldaystime[nextholiday] - (Date.now())) < 86400000)
|
||||||
|
currentholiday = wheeldays[nextholiday];
|
||||||
|
if (((Date.now()) - wheeldaystime[nextholiday-1]) < 43200000)
|
||||||
|
currentholiday = wheeldays[nextholiday-1];
|
||||||
|
nextholiday = wheeldays[nextholiday];
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringout;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTable(UTC, timeoutput) {
|
function makeTable(UTC, timeoutput) {
|
||||||
|
@ -275,8 +297,9 @@ function makeTable(UTC, timeoutput) {
|
||||||
for (var i = 1; i <= 15; i++) {
|
for (var i = 1; i <= 15; i++) {
|
||||||
var currentyear = (now.getFullYear() - 8 + i);
|
var currentyear = (now.getFullYear() - 8 + i);
|
||||||
if (currentyear == now.getFullYear()) fulltable += '<tr class = "currentyear">';
|
if (currentyear == now.getFullYear()) fulltable += '<tr class = "currentyear">';
|
||||||
else if (i % 2 == 0 ) fulltable += '<tr class = "even">';
|
else if (currentyear == (now.getFullYear() + 1)) fulltable += '<tr class = "odd nextyear">';
|
||||||
else fulltable += '<tr class = "odd">'
|
else if (i % 2 == 0 ) fulltable += '<tr class = "even">';
|
||||||
|
else fulltable += '<tr class = "odd">'
|
||||||
fulltable += tableRow(currentyear, timeoutput, UTC) + "</tr>";
|
fulltable += tableRow(currentyear, timeoutput, UTC) + "</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +331,12 @@ function makeTable(UTC, timeoutput) {
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
if (nextholiday == "next") var nextselector = ".nextyear>." + nextholiday;
|
||||||
|
else var nextselector = ".currentyear>." + nextholiday;
|
||||||
|
if (currentholiday) var curselector = ".currentyear>." + currentholiday;
|
||||||
|
document.querySelector(nextselector).style.color = "yellow";
|
||||||
|
document.querySelector(curselector).style.color = "red";
|
||||||
|
|
||||||
const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(),
|
const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(),
|
||||||
0, 0)) / (1000 * 60 * 60 * 24));
|
0, 0)) / (1000 * 60 * 60 * 24));
|
||||||
var daynumber = dayOfYear(new Date());
|
var daynumber = dayOfYear(new Date());
|
||||||
|
|
Loading…
Reference in New Issue