2020-06-07 09:18:09 +02:00
|
|
|
let dock = document.getElementById('dock');
|
2020-06-04 02:14:24 +02:00
|
|
|
|
|
|
|
// Generate button from user
|
|
|
|
const generateFromManual = (id, icon, callback) => {
|
|
|
|
|
2020-06-07 09:18:09 +02:00
|
|
|
let customButtonCallback;
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-07 09:18:09 +02:00
|
|
|
const dockButton = document.createElement('div');
|
2020-06-04 02:35:05 +02:00
|
|
|
dockButton.id = 'button' + id;
|
|
|
|
dockButton.className = 'dockButton';
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-04 02:35:05 +02:00
|
|
|
dockButton.onmouseup = callback;
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-07 09:18:09 +02:00
|
|
|
const buttonImage = document.createElement('div');
|
2020-06-04 02:14:24 +02:00
|
|
|
buttonImage.id = 'buttonImage' + id;
|
2020-06-04 02:35:05 +02:00
|
|
|
buttonImage.className = 'dockButtonImage';
|
2020-06-04 02:14:24 +02:00
|
|
|
buttonImage.style.background = "url('assets/buttons/" + icon + ".svg')";
|
|
|
|
buttonImage.style.backgroundSize = 'cover';
|
|
|
|
|
2020-06-04 02:35:05 +02:00
|
|
|
dockButton.appendChild(buttonImage);
|
|
|
|
dock.appendChild(dockButton);
|
2020-06-04 02:14:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Generate buttons from array
|
|
|
|
const generateFromList = () => {
|
|
|
|
|
2020-06-07 09:18:09 +02:00
|
|
|
for (let i = 0; i < (dockSites.length); i++) {
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-07 09:18:09 +02:00
|
|
|
const site = dockSites[i].site;
|
|
|
|
const icon = dockSites[i].icon;
|
|
|
|
const url = dockSites[i].url;
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-05 00:19:31 +02:00
|
|
|
// Create a href
|
2020-06-07 09:18:09 +02:00
|
|
|
const aDock = document.createElement('a');
|
2020-06-05 00:18:34 +02:00
|
|
|
aDock.className = 'dockLink';
|
|
|
|
aDock.href = url;
|
|
|
|
|
2020-06-05 00:19:31 +02:00
|
|
|
// Create div container
|
2020-06-07 09:18:09 +02:00
|
|
|
const dockButton = document.createElement('div');
|
2020-06-04 02:35:05 +02:00
|
|
|
dockButton.id = 'button' + i;
|
|
|
|
dockButton.className = 'dockButton';
|
2020-06-04 02:14:24 +02:00
|
|
|
|
2020-06-05 00:19:31 +02:00
|
|
|
// Create div container for button icon
|
2020-06-07 09:18:09 +02:00
|
|
|
const buttonImage = document.createElement('div');
|
2020-06-04 02:14:24 +02:00
|
|
|
buttonImage.id = 'buttonImage' + i;
|
2020-06-04 02:35:05 +02:00
|
|
|
buttonImage.className = 'dockButtonImage';
|
2020-06-04 02:14:24 +02:00
|
|
|
buttonImage.style.background = "url('assets/webcons/" + icon + ".svg')";
|
|
|
|
buttonImage.style.backgroundSize = 'cover';
|
|
|
|
|
|
|
|
// Append divs
|
2020-06-04 02:35:05 +02:00
|
|
|
dockButton.appendChild(buttonImage);
|
2020-06-05 00:18:34 +02:00
|
|
|
aDock.appendChild(dockButton);
|
|
|
|
dock.appendChild(aDock);
|
2020-06-04 02:14:24 +02:00
|
|
|
};
|
2020-06-04 02:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const populateDock = () => {
|
|
|
|
|
|
|
|
// Create launcher button
|
|
|
|
generateFromManual(
|
|
|
|
'Launch',
|
|
|
|
'launch',
|
|
|
|
() => {
|
2020-06-04 06:15:59 +02:00
|
|
|
// Toggle web menu
|
|
|
|
toggleWebMenu();
|
2020-06-04 02:39:09 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Create dock buttons fetched from sites-list.js
|
|
|
|
generateFromList();
|
2020-06-04 02:14:24 +02:00
|
|
|
|
|
|
|
// Create weather button
|
|
|
|
generateFromManual(
|
|
|
|
'Weather',
|
|
|
|
'weather',
|
|
|
|
() => {
|
2020-06-04 05:46:21 +02:00
|
|
|
// Toggle weather screen
|
|
|
|
toggleWeatherScreen();
|
2020-06-04 02:14:24 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Create menu button
|
|
|
|
generateFromManual(
|
|
|
|
'Dashboard',
|
|
|
|
'dashboard',
|
|
|
|
() => {
|
|
|
|
// Toggle dashboard
|
2020-06-04 04:23:40 +02:00
|
|
|
toggleDashboard();
|
2020-06-04 02:14:24 +02:00
|
|
|
}
|
|
|
|
);
|
2020-06-04 02:39:09 +02:00
|
|
|
|
2020-06-04 02:14:24 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 02:39:09 +02:00
|
|
|
// Populate dock
|
|
|
|
window.onload = populateDock();
|
2020-06-04 02:14:24 +02:00
|
|
|
|