use config

This commit is contained in:
Thomas Rupprecht 2018-12-27 15:16:18 +01:00
parent 8575efd2c7
commit 428c37496c
5 changed files with 40 additions and 6 deletions

View File

@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>/usr/space</title>
<script src="../config.js"></script>
<script type="module" src="index.js"></script>
</head>
</html>

View File

@ -3,7 +3,7 @@ const fetchJson = (url) => {
};
const fetchCalendar = (days = null) => {
let url = 'https://usrspace.at/calendar.php?o=json';
let url = Config.calenderUrl + '?o=json';
if (days) {
url += '&r=' + days;
}
@ -11,14 +11,14 @@ const fetchCalendar = (days = null) => {
};
const fetchSpaceApi = () => {
return fetchJson('https://usrspace.at/spaceapi');
return fetchJson(Config.spaceApiUrl);
};
const updateBadge = (open) => {
let badgeText, badgeColor;
if (open) {
badgeText = browser.browserAction.setBadgeText({text: 'open'});
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: '#00ff00'});
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: Config.openColor});
} else {
badgeText = browser.browserAction.setBadgeText({text: ''});
badgeColor = browser.browserAction.setBadgeBackgroundColor({color: null});
@ -53,4 +53,4 @@ const fetchNewData = () => {
fetchNewData();
setInterval(() => {
fetchNewData();
}, 5 * 60 * 1000);
}, Config.refreshTimeout);

32
config.js Normal file
View File

@ -0,0 +1,32 @@
window.Config = {
refreshTimeout: 1000 * 60 * 5, // 5min,
spaceApiUrl: 'https://usrspace.at/spaceapi',
calenderUrl: 'https://usrspace.at/calendar.php',
openColor: '#00ff00',
quickLinks: [
{
url: 'https://usrspace.at/',
img: 'icons/font-awesome/home-solid.svg',
alt: 'Home',
text: 'Homepage'
},
{
url: 'https://www.usrspace.at/w/',
img: 'icons/font-awesome/wikipedia-w-brands.svg',
alt: 'Wiki',
text: 'Wiki'
},
{
url: 'https://gitlab.usrspace.at/',
img: 'icons/font-awesome/gitlab-brands.svg',
alt: 'Gitlab',
text: 'Gitlab'
},
{
url: 'https://cloud.usrspace.at/',
img: 'icons/font-awesome/cloud-solid.svg',
alt: 'Cloud',
text: 'NextCloud'
}
]
};

View File

@ -1,5 +1,5 @@
body {
max-width: 360px;
width: 360px;
}
h2 {

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>/usr/space</title>
<link rel="stylesheet" href="index.css"/>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<header class="panel-section panel-section-header">
@ -38,6 +38,7 @@
<h2>Infos</h2>
<pre id="space-api"><code>loading...</code></pre>
<script src="../config.js"></script>
<script src="index.js"></script>
</body>
</html>