Skip to content

Commit

Permalink
uh, it helps to delete the code I want to replace...
Browse files Browse the repository at this point in the history
  • Loading branch information
cellio committed Jun 2, 2021
1 parent 05d1e97 commit 220aac8
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions public/assets/community/judaism.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,56 +601,3 @@ window.addEventListener("load", async () => {
});



/////////
window.addEventListener("load", async () => {
const container = document.createElement('div');
container.innerHTML = "<div class='widget--body'><div class='_cal_label'>Today is:</div><div class='_cal_val'>loading date...</div></div>";
container.classList.add('widget', 'has-margin-4');

const disclaimerNotice = document.querySelector('.widget.is-yellow:first-child');
disclaimerNotice.parentNode.insertBefore(container, disclaimerNotice.nextSibling);

const result = await fetch('https://www.hebcal.com/hebcal?v=1&cfg=json&year=now&month=now&d=on&o=on');
const response = await result.json()

const parsedData = response.items.reduce((rv, x) => {
(rv[x.date] = rv[x.date] || []).push(x);
return rv;
}, {});

let now = new Date();
if (now.getHours() > 20) {
now.setDate(now.getDate() + 1);
}

now = now.toISOString().substr(0, 10);

const fields = parsedData[now];
container.querySelector('._cal_val').innerHTML = "";

fields.forEach(field => {
const fieldContainer = document.createElement('div');
fieldContainer.classList.add('has-font-size-larger', 'h-fw-bold', 'h-m-t-2');
container.querySelector('._cal_val').appendChild(fieldContainer);

fieldContainer.innerText = field.title;
});

const DAY_LIST = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];

let today = new Date();
if (today.getHours() > 20) {
today.setDate(today.getDate() + 1);
}

const todayDay = DAY_LIST[(today.getDay() + 6) % 7];
today.setDate(today.getDate() - 1);
const yesterdayDay = DAY_LIST[(today.getDay() + 6) % 7];

const fieldContainer = document.createElement('div');
fieldContainer.classList.add('h-m-t-2', 'has-font-size-caption');
container.querySelector('._cal_val').appendChild(fieldContainer);

fieldContainer.innerText = yesterdayDay + ' night (' + todayDay + ')';
});

0 comments on commit 220aac8

Please sign in to comment.