From 52e0ea105e24bd5d5f18a2c6277bc64460eb963a Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Thu, 23 Sep 2021 02:28:20 +0200 Subject: [PATCH] fix data, remove logging, improve code --- background/index.js | 6 +++--- popup/index.js | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/background/index.js b/background/index.js index 24744cd..b510c61 100644 --- a/background/index.js +++ b/background/index.js @@ -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') }); } diff --git a/popup/index.js b/popup/index.js index b237e8b..207e561 100644 --- a/popup/index.js +++ b/popup/index.js @@ -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 `; + const sinceStr = ` seit `; if (spaceApi.state.open) { stateElement.innerHTML = `OffenOffen ${sinceStr}`; } else {