forked from XimeX/usrspace-browser-addon
fix data, remove logging, improve code
This commit is contained in:
parent
50a55ff68b
commit
52e0ea105e
|
@ -31,11 +31,11 @@ async function updateBadge(open) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendNotification(open) {
|
function sendNotification(open) {
|
||||||
browser.notifications.create('notification-id', {
|
browser.notifications.create('status-change', {
|
||||||
type: 'basic',
|
type: 'basic',
|
||||||
iconUrl: browser.runtime.getURL('icons/logo.svg'),
|
|
||||||
title: 'Space Status',
|
title: 'Space Status',
|
||||||
message: `Space ist jetzt ${open ? 'offen' : 'geschlossen'}.`
|
message: `Space ist jetzt ${open ? 'offen' : 'geschlossen'}.`,
|
||||||
|
iconUrl: browser.runtime.getURL('icons/logo.svg')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ async function init() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const page = await browser.runtime.getBackgroundPage();
|
const page = await browser.runtime.getBackgroundPage();
|
||||||
console.log(page);
|
|
||||||
|
|
||||||
updateNextEvent(page.calendar);
|
updateNextEvent(page.calendar);
|
||||||
updateSpaceApiJson(page.spaceApi);
|
updateSpaceApiJson(page.spaceApi);
|
||||||
|
@ -49,7 +48,7 @@ function updateNextEvent(nextEvents) {
|
||||||
const timeElement = document.createElement('time');
|
const timeElement = document.createElement('time');
|
||||||
strongElement.textContent = nextEventDateEvent.name;
|
strongElement.textContent = nextEventDateEvent.name;
|
||||||
timeElement.datetime = beginDate.toISOString();
|
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.innerText = '';
|
||||||
divElement.append(strongElement);
|
divElement.append(strongElement);
|
||||||
divElement.append(document.createTextNode(' '));
|
divElement.append(document.createTextNode(' '));
|
||||||
|
@ -75,7 +74,7 @@ function updateSpaceApiJson(spaceApi) {
|
||||||
function updateState(spaceApi) {
|
function updateState(spaceApi) {
|
||||||
const stateElement = document.getElementById('state');
|
const stateElement = document.getElementById('state');
|
||||||
const since = new Date(spaceApi.state.lastchange * 1000);
|
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) {
|
if (spaceApi.state.open) {
|
||||||
stateElement.innerHTML = `<img src="../icons/font-awesome/lock-open-solid.svg" width="19" height="19" alt="Offen" />Offen ${sinceStr}`;
|
stateElement.innerHTML = `<img src="../icons/font-awesome/lock-open-solid.svg" width="19" height="19" alt="Offen" />Offen ${sinceStr}`;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue