fix data, remove logging, improve code

This commit is contained in:
Thomas Rupprecht 2021-09-23 02:28:20 +02:00
parent 50a55ff68b
commit 52e0ea105e
2 changed files with 5 additions and 6 deletions

View File

@ -31,11 +31,11 @@ async function updateBadge(open) {
}
function sendNotification(open) {
browser.notifications.create('notification-id', {
browser.notifications.create('status-change', {
type: 'basic',
iconUrl: browser.runtime.getURL('icons/logo.svg'),
title: 'Space Status',
message: `Space ist jetzt ${open ? 'offen' : 'geschlossen'}.`
message: `Space ist jetzt ${open ? 'offen' : 'geschlossen'}.`,
iconUrl: browser.runtime.getURL('icons/logo.svg')
});
}

View File

@ -15,7 +15,6 @@ async function init() {
try {
const page = await browser.runtime.getBackgroundPage();
console.log(page);
updateNextEvent(page.calendar);
updateSpaceApiJson(page.spaceApi);
@ -49,7 +48,7 @@ function updateNextEvent(nextEvents) {
const timeElement = document.createElement('time');
strongElement.textContent = nextEventDateEvent.name;
timeElement.datetime = beginDate.toISOString();
const dateNode = document.createTextNode(beginDate.toLocaleString([], {dateStyle: "short", timeStyle: "short"}));
const dateNode = document.createTextNode(beginDate.toLocaleString([], {dateStyle: "medium", timeStyle: "short"}));
// divElement.innerText = '';
divElement.append(strongElement);
divElement.append(document.createTextNode(' '));
@ -75,7 +74,7 @@ function updateSpaceApiJson(spaceApi) {
function updateState(spaceApi) {
const stateElement = document.getElementById('state');
const since = new Date(spaceApi.state.lastchange * 1000);
const sinceStr = ` seit <time datetime="${since.toISOString()}">${since.toLocaleString([], {dateStyle: "short", timeStyle: "short"})}</time>`;
const sinceStr = ` seit <time datetime="${since.toISOString()}">${since.toLocaleString([], {dateStyle: "medium", timeStyle: "short"})}</time>`;
if (spaceApi.state.open) {
stateElement.innerHTML = `<img src="../icons/font-awesome/lock-open-solid.svg" width="19" height="19" alt="Offen" />Offen ${sinceStr}`;
} else {