forked from XimeX/usrspace-browser-addon
reformat code
This commit is contained in:
parent
a025fc9d36
commit
cfc6e98097
|
@ -1,85 +1,85 @@
|
|||
const fetchJson = (url) => {
|
||||
return fetch(url).then((response) => (response.json()));
|
||||
return fetch(url).then((response) => (response.json()));
|
||||
};
|
||||
|
||||
const fetchCalendar = (days = 28) => {
|
||||
let url = Config.calenderUrl + '?o=json';
|
||||
if (days) {
|
||||
url += '&r=' + days;
|
||||
}
|
||||
return fetchJson(url);
|
||||
let url = Config.calenderUrl + '?o=json';
|
||||
if (days) {
|
||||
url += '&r=' + days;
|
||||
}
|
||||
return fetchJson(url);
|
||||
};
|
||||
|
||||
const fetchSpaceApi = () => {
|
||||
return fetchJson(Config.spaceApiUrl);
|
||||
return fetchJson(Config.spaceApiUrl);
|
||||
};
|
||||
|
||||
const updateBadge = (open) => {
|
||||
let badgeText, badgeColor;
|
||||
if (open) {
|
||||
badgeText = browser.browserAction.setBadgeText({text: 'open'});
|
||||
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: Config.openColor});
|
||||
} else {
|
||||
badgeText = browser.browserAction.setBadgeText({text: ''});
|
||||
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: null});
|
||||
}
|
||||
Promise.all([badgeText, badgeColor])
|
||||
.then()
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
let badgeText, badgeColor;
|
||||
if (open) {
|
||||
badgeText = browser.browserAction.setBadgeText({text: 'open'});
|
||||
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: Config.openColor});
|
||||
} else {
|
||||
badgeText = browser.browserAction.setBadgeText({text: ''});
|
||||
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: null});
|
||||
}
|
||||
Promise.all([badgeText, badgeColor])
|
||||
.then()
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
const sendNotification = (open) => {
|
||||
browser.notifications.create('notification-id', {
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/logo.svg'),
|
||||
title: 'Space Status',
|
||||
message: 'Space ist jetzt ' + (open ? 'offen' : 'geschlossen') + '.'
|
||||
});
|
||||
browser.notifications.create('notification-id', {
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/logo.svg'),
|
||||
title: 'Space Status',
|
||||
message: 'Space ist jetzt ' + (open ? 'offen' : 'geschlossen') + '.'
|
||||
});
|
||||
};
|
||||
|
||||
const fetchNewData = () => {
|
||||
fetchCalendar().then((json) => {
|
||||
window.calendar = json;
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
fetchCalendar().then((json) => {
|
||||
window.calendar = json;
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
fetchSpaceApi().then((json) => {
|
||||
if (window.spaceApi && window.spaceApi.state.open !== json.state.open) {
|
||||
sendNotification(json.state.open)
|
||||
}
|
||||
window.spaceApi = json;
|
||||
updateBadge(window.spaceApi.state.open);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
fetchSpaceApi().then((json) => {
|
||||
if (window.spaceApi && window.spaceApi.state.open !== json.state.open) {
|
||||
sendNotification(json.state.open)
|
||||
}
|
||||
window.spaceApi = json;
|
||||
updateBadge(window.spaceApi.state.open);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
let intervalHandler = null;
|
||||
|
||||
const stopFetching = () => {
|
||||
if (intervalHandler !== null) {
|
||||
clearInterval(intervalHandler);
|
||||
intervalHandler = null;
|
||||
}
|
||||
if (intervalHandler !== null) {
|
||||
clearInterval(intervalHandler);
|
||||
intervalHandler = null;
|
||||
}
|
||||
};
|
||||
const startFetching = () => {
|
||||
fetchNewData();
|
||||
if (intervalHandler === null) {
|
||||
intervalHandler = setInterval(() => {
|
||||
fetchNewData();
|
||||
}, Config.refreshTimeout);
|
||||
}
|
||||
fetchNewData();
|
||||
if (intervalHandler === null) {
|
||||
intervalHandler = setInterval(() => {
|
||||
fetchNewData();
|
||||
}, Config.refreshTimeout);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('offline', () => {
|
||||
stopFetching();
|
||||
stopFetching();
|
||||
});
|
||||
window.addEventListener('online', () => {
|
||||
startFetching();
|
||||
startFetching();
|
||||
});
|
||||
if (window.navigator.onLine) {
|
||||
startFetching();
|
||||
startFetching();
|
||||
}
|
||||
|
|
60
config.js
60
config.js
|
@ -1,32 +1,32 @@
|
|||
window.Config = {
|
||||
refreshTimeout: 1000 * 60 * 5, // 5min,
|
||||
spaceApiUrl: 'https://www.usrspace.at/spaceapi.json',
|
||||
calenderUrl: 'https://www.usrspace.at/calendar.php',
|
||||
openColor: '#33cc33',
|
||||
quickLinks: [
|
||||
{
|
||||
url: 'https://www.usrspace.at/',
|
||||
img: 'icons/font-awesome/home-solid.svg',
|
||||
alt: 'Home',
|
||||
text: 'Homepage'
|
||||
},
|
||||
{
|
||||
url: 'https://wiki.usrspace.at/',
|
||||
img: 'icons/font-awesome/wikipedia-w-brands.svg',
|
||||
alt: 'Wiki',
|
||||
text: 'Wiki'
|
||||
},
|
||||
{
|
||||
url: 'https://gitea.usrspace.at/',
|
||||
img: 'icons/gitea-brands.svg',
|
||||
alt: 'Gitea',
|
||||
text: 'Gitea'
|
||||
},
|
||||
{
|
||||
url: 'https://cloud.usrspace.at/',
|
||||
img: 'icons/font-awesome/cloud-solid.svg',
|
||||
alt: 'Cloud',
|
||||
text: 'Nextcloud'
|
||||
}
|
||||
]
|
||||
refreshTimeout: 1000 * 60 * 5, // 5min,
|
||||
spaceApiUrl: 'https://www.usrspace.at/spaceapi.json',
|
||||
calenderUrl: 'https://www.usrspace.at/calendar.php',
|
||||
openColor: '#33cc33',
|
||||
quickLinks: [
|
||||
{
|
||||
url: 'https://www.usrspace.at/',
|
||||
img: 'icons/font-awesome/home-solid.svg',
|
||||
alt: 'Home',
|
||||
text: 'Homepage'
|
||||
},
|
||||
{
|
||||
url: 'https://wiki.usrspace.at/',
|
||||
img: 'icons/font-awesome/wikipedia-w-brands.svg',
|
||||
alt: 'Wiki',
|
||||
text: 'Wiki'
|
||||
},
|
||||
{
|
||||
url: 'https://gitea.usrspace.at/',
|
||||
img: 'icons/gitea-brands.svg',
|
||||
alt: 'Gitea',
|
||||
text: 'Gitea'
|
||||
},
|
||||
{
|
||||
url: 'https://cloud.usrspace.at/',
|
||||
img: 'icons/font-awesome/cloud-solid.svg',
|
||||
alt: 'Cloud',
|
||||
text: 'Nextcloud'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "/usr/space",
|
||||
"version": "0.6",
|
||||
"description": "An Add-on for the Hacker-/Maker-Space /usr/space.",
|
||||
"icons": {
|
||||
"48": "icons/logo.svg",
|
||||
"96": "icons/logo.svg"
|
||||
},
|
||||
"background": {
|
||||
"page": "background/index.html"
|
||||
},
|
||||
"browser_action": {
|
||||
"browser_style": true,
|
||||
//"chrome_style": true,
|
||||
"default_title": "/usr/space",
|
||||
//"default_icon": "icons/logo.svg",
|
||||
"default_icon": {
|
||||
"16": "icons/logo.svg",
|
||||
"32": "icons/logo.svg"
|
||||
},
|
||||
"default_area": "navbar",
|
||||
"default_popup": "popup/index.html"
|
||||
},
|
||||
"permissions": [
|
||||
"https://www.usrspace.at/*",
|
||||
"webRequest",
|
||||
"notifications"
|
||||
],
|
||||
"author": "Thomas Rupprecht"
|
||||
//"developer": {
|
||||
// "name": "Thomas Rupprecht",
|
||||
// "url": "https://blog.ximex.at/"
|
||||
//}
|
||||
"manifest_version": 2,
|
||||
"name": "/usr/space",
|
||||
"version": "0.6",
|
||||
"description": "An Add-on for the Hacker-/Maker-Space /usr/space.",
|
||||
"icons": {
|
||||
"48": "icons/logo.svg",
|
||||
"96": "icons/logo.svg"
|
||||
},
|
||||
"background": {
|
||||
"page": "background/index.html"
|
||||
},
|
||||
"browser_action": {
|
||||
"browser_style": true,
|
||||
//"chrome_style": true,
|
||||
"default_title": "/usr/space",
|
||||
//"default_icon": "icons/logo.svg",
|
||||
"default_icon": {
|
||||
"16": "icons/logo.svg",
|
||||
"32": "icons/logo.svg"
|
||||
},
|
||||
"default_area": "navbar",
|
||||
"default_popup": "popup/index.html"
|
||||
},
|
||||
"permissions": [
|
||||
"https://www.usrspace.at/*",
|
||||
"webRequest",
|
||||
"notifications"
|
||||
],
|
||||
"author": "Thomas Rupprecht"
|
||||
//"developer": {
|
||||
// "name": "Thomas Rupprecht",
|
||||
// "url": "https://blog.ximex.at/"
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
body {
|
||||
width: 360px;
|
||||
width: 360px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 12px 8px 8px;
|
||||
margin: 12px 8px 8px;
|
||||
}
|
||||
summary {
|
||||
margin: 12px 8px 8px;
|
||||
margin: 12px 8px 8px;
|
||||
}
|
||||
summary > h2 {
|
||||
margin: 0;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.panel-list-item > .icon {
|
||||
text-align: center;
|
||||
width: 23px;
|
||||
margin-right: 4px;
|
||||
text-align: center;
|
||||
width: 23px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.panel-list-item > .icon > img {
|
||||
vertical-align: text-bottom;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
#state {
|
||||
margin: 0 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
#state > img {
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 4px;
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
margin: 0 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
#calendar > div > img {
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 4px;
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#space-api {
|
||||
margin: 0;
|
||||
padding: 0 8px;
|
||||
height: 240px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
background-color: #ebebeb;
|
||||
margin: 0;
|
||||
padding: 0 8px;
|
||||
height: 240px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
background-color: #ebebeb;
|
||||
}
|
||||
#space-api code {
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>/usr/space</title>
|
||||
<link rel="stylesheet" href="index.css" />
|
||||
<meta charset="utf-8">
|
||||
<title>/usr/space</title>
|
||||
<link rel="stylesheet" href="index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!--<header class="panel-section panel-section-header">
|
||||
<div class="icon-section-header"><img src="../icons/logo.svg" width="32" height="32" alt="/usr/space" /></div>
|
||||
<div class="text-section-header">/usr/space</div>
|
||||
</header>-->
|
||||
<section>
|
||||
<h2>Aktueller Status</h2>
|
||||
<div id="state">loading...</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Links</h2>
|
||||
<div class="panel-section panel-section-list">
|
||||
<div class="panel-list-item link" data-url="https://www.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/home-solid.svg" width="19" height="19" alt="Home" /></div>
|
||||
<div class="text">Homepage</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://wiki.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/wikipedia-w-brands.svg" width="19" height="19" alt="Wiki" /></div>
|
||||
<div class="text">Wiki</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://gitea.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/gitea-brands.svg" width="19" height="19" alt="Gitea" /></div>
|
||||
<div class="text">Gitea</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://cloud.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/cloud-solid.svg" width="19" height="19" alt="Cloud" /></div>
|
||||
<div class="text">Nextcloud</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Nächster Termin</h2>
|
||||
<div id="calendar">loading...</div>
|
||||
</section>
|
||||
<section>
|
||||
<details>
|
||||
<summary><h2>SpaceApi JSON</h2></summary>
|
||||
<pre id="space-api"><code>loading...</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<!--<header class="panel-section panel-section-header">
|
||||
<div class="icon-section-header"><img src="../icons/logo.svg" width="32" height="32" alt="/usr/space" /></div>
|
||||
<div class="text-section-header">/usr/space</div>
|
||||
</header>-->
|
||||
<section>
|
||||
<h2>Aktueller Status</h2>
|
||||
<div id="state">loading...</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Links</h2>
|
||||
<div class="panel-section panel-section-list">
|
||||
<div class="panel-list-item link" data-url="https://www.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/home-solid.svg" width="19" height="19" alt="Home" /></div>
|
||||
<div class="text">Homepage</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://wiki.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/wikipedia-w-brands.svg" width="19" height="19" alt="Wiki" /></div>
|
||||
<div class="text">Wiki</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://gitea.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/gitea-brands.svg" width="19" height="19" alt="Gitea" /></div>
|
||||
<div class="text">Gitea</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
<div class="panel-list-item link" data-url="https://cloud.usrspace.at/">
|
||||
<div class="icon"><img src="../icons/font-awesome/cloud-solid.svg" width="19" height="19" alt="Cloud" /></div>
|
||||
<div class="text">Nextcloud</div>
|
||||
<div class="text-shortcut"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Nächster Termin</h2>
|
||||
<div id="calendar">loading...</div>
|
||||
</section>
|
||||
<section>
|
||||
<details>
|
||||
<summary><h2>SpaceApi JSON</h2></summary>
|
||||
<pre id="space-api"><code>loading...</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
|
||||
<script type="application/javascript" src="../browser-polyfill.js"></script>
|
||||
<script type="application/javascript" src="../config.js"></script>
|
||||
<script type="application/javascript" src="index.js"></script>
|
||||
<script type="application/javascript" src="../browser-polyfill.js"></script>
|
||||
<script type="application/javascript" src="../config.js"></script>
|
||||
<script type="application/javascript" src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
118
popup/index.js
118
popup/index.js
|
@ -1,77 +1,77 @@
|
|||
Array.from(document.getElementsByClassName('link')).forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
const newTab = browser.tabs.create({
|
||||
url: event.currentTarget.dataset.url
|
||||
});
|
||||
newTab.then((data) => {
|
||||
// console.log(data);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
element.addEventListener('click', (event) => {
|
||||
const newTab = browser.tabs.create({
|
||||
url: event.currentTarget.dataset.url
|
||||
});
|
||||
newTab.then((data) => {
|
||||
// console.log(data);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
browser.runtime.getBackgroundPage().then((page) => {
|
||||
updateNextEvent(page.calendar);
|
||||
updateSpaceApiJson(page.spaceApi);
|
||||
updateState(page.spaceApi);
|
||||
updateNextEvent(page.calendar);
|
||||
updateSpaceApiJson(page.spaceApi);
|
||||
updateState(page.spaceApi);
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const updateNextEvent = (nextEvents) => {
|
||||
const calendarElement = document.getElementById('calendar');
|
||||
calendarElement.innerText = '';
|
||||
const calendarElement = document.getElementById('calendar');
|
||||
calendarElement.innerText = '';
|
||||
|
||||
if (nextEvents.length === 0) {
|
||||
const hintNode = document.createTextNode('Keine Termine in den nächsten 4 Wochen!');
|
||||
const strongElement = document.createElement('strong');
|
||||
strongElement.append(hintNode);
|
||||
calendarElement.append(strongElement);
|
||||
return;
|
||||
}
|
||||
if (nextEvents.length === 0) {
|
||||
const hintNode = document.createTextNode('Keine Termine in den nächsten 4 Wochen!');
|
||||
const strongElement = document.createElement('strong');
|
||||
strongElement.append(hintNode);
|
||||
calendarElement.append(strongElement);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextEventDate = nextEvents[0].begin.substr(0, 10);
|
||||
const nextEventDateEvents = nextEvents.filter((nextEvent) => (nextEvent.begin.startsWith(nextEventDate)));
|
||||
const nextEventDate = nextEvents[0].begin.substr(0, 10);
|
||||
const nextEventDateEvents = nextEvents.filter((nextEvent) => (nextEvent.begin.startsWith(nextEventDate)));
|
||||
|
||||
nextEventDateEvents.forEach((nextEventDateEvent) => {
|
||||
const divElement = document.createElement('div');
|
||||
divElement.innerHTML = '<img src="../icons/font-awesome/clock-regular.svg" width="19" height="19" alt="Clock" />';
|
||||
const beginDate = new Date(nextEventDateEvent.begin);
|
||||
const strongElement = document.createElement('strong');
|
||||
const timeElement = document.createElement('time');
|
||||
strongElement.textContent = nextEventDateEvent.name;
|
||||
timeElement.datetime = beginDate.toISOString();
|
||||
const dateNode = document.createTextNode(beginDate.toLocaleString());
|
||||
// divElement.innerText = '';
|
||||
divElement.append(strongElement);
|
||||
divElement.append(document.createTextNode(' '));
|
||||
divElement.append(timeElement);
|
||||
timeElement.append(dateNode);
|
||||
if (nextEventDateEvent.location) {
|
||||
const locationNode = document.createTextNode(' (' + nextEventDateEvent.location + ')');
|
||||
divElement.append(locationNode);
|
||||
}
|
||||
calendarElement.append(divElement);
|
||||
});
|
||||
nextEventDateEvents.forEach((nextEventDateEvent) => {
|
||||
const divElement = document.createElement('div');
|
||||
divElement.innerHTML = '<img src="../icons/font-awesome/clock-regular.svg" width="19" height="19" alt="Clock" />';
|
||||
const beginDate = new Date(nextEventDateEvent.begin);
|
||||
const strongElement = document.createElement('strong');
|
||||
const timeElement = document.createElement('time');
|
||||
strongElement.textContent = nextEventDateEvent.name;
|
||||
timeElement.datetime = beginDate.toISOString();
|
||||
const dateNode = document.createTextNode(beginDate.toLocaleString());
|
||||
// divElement.innerText = '';
|
||||
divElement.append(strongElement);
|
||||
divElement.append(document.createTextNode(' '));
|
||||
divElement.append(timeElement);
|
||||
timeElement.append(dateNode);
|
||||
if (nextEventDateEvent.location) {
|
||||
const locationNode = document.createTextNode(' (' + nextEventDateEvent.location + ')');
|
||||
divElement.append(locationNode);
|
||||
}
|
||||
calendarElement.append(divElement);
|
||||
});
|
||||
};
|
||||
|
||||
const updateSpaceApiJson = (spaceApi) => {
|
||||
const spaceApiElement = document.querySelector('#space-api code');
|
||||
const json = JSON.stringify(spaceApi, null, 2).replace(/ /g, ' ').replace(/\n/g, '<br/>');
|
||||
spaceApiElement.innerHTML = json;
|
||||
// const jsonNode = document.createTextNode(json);
|
||||
// spaceApiElement.innerText = '';
|
||||
// spaceApiElement.append(jsonNode);
|
||||
const spaceApiElement = document.querySelector('#space-api code');
|
||||
const json = JSON.stringify(spaceApi, null, 2).replace(/ /g, ' ').replace(/\n/g, '<br/>');
|
||||
spaceApiElement.innerHTML = json;
|
||||
// const jsonNode = document.createTextNode(json);
|
||||
// spaceApiElement.innerText = '';
|
||||
// spaceApiElement.append(jsonNode);
|
||||
};
|
||||
|
||||
const updateState = (spaceApi) => {
|
||||
const stateElement = document.getElementById('state');
|
||||
const since = new Date(spaceApi.state.lastchange * 1000);
|
||||
const sinceStr = ' seit <time datetime="' + since.toISOString() + '">' + since.toLocaleString() + '</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 {
|
||||
stateElement.innerHTML = '<img src="../icons/font-awesome/lock-solid.svg" width="19" height="19" alt="Geschlossen" />Geschlossen' + sinceStr;
|
||||
}
|
||||
const stateElement = document.getElementById('state');
|
||||
const since = new Date(spaceApi.state.lastchange * 1000);
|
||||
const sinceStr = ' seit <time datetime="' + since.toISOString() + '">' + since.toLocaleString() + '</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 {
|
||||
stateElement.innerHTML = '<img src="../icons/font-awesome/lock-solid.svg" width="19" height="19" alt="Geschlossen" />Geschlossen' + sinceStr;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue