feat: Update app and windows
- Move setAttributesAccordingToPosition to HippieTaskbar - Use TimeDisplay inside HippieTaskbar - Add readJsonFile and loadJson to app - Initialize taskbar with config from data/windows.json - Update jshint globals
This commit is contained in:
parent
b67a8a893a
commit
0c16b43ec7
5 changed files with 102 additions and 48 deletions
|
|
@ -394,20 +394,6 @@ function centerElementUnderCursor(event, element) {
|
|||
element.style.top = `${y}px`;
|
||||
}
|
||||
|
||||
function setAttributesAccordingToPosition(element, position, attributes) {
|
||||
'use strict';
|
||||
|
||||
element.classList.remove(...Object.values(attributes).map(pos => pos.className));
|
||||
Object.keys(attributes[position].styles).forEach(key => {
|
||||
element.style[key] = '';
|
||||
});
|
||||
|
||||
element.classList.add(attributes[position].className);
|
||||
Object.entries(attributes[position].styles).forEach(([key, value]) => {
|
||||
element.style[key] = value;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt eine Zahl zwischen <min> und <max> aus.
|
||||
* Die Werte <min> und <max> sind dabei mit eingeschlossen.
|
||||
|
|
@ -556,9 +542,37 @@ function zeroFill(number, width) {
|
|||
// Retrieved 2026-03-08, License - CC BY-SA 4.0
|
||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
class RandomPixelCanvas {
|
||||
constructor(containerElement, options = {}) {
|
||||
this.container = containerElement;
|
||||
async function readJsonFile(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.readAsText(file);
|
||||
reader.onload = function () {
|
||||
try {
|
||||
resolve(JSON.parse(reader.result));
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
};
|
||||
reader.onerror = function () {
|
||||
reject(reader.error);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function loadJson(filePath) {
|
||||
try {
|
||||
const response = await fetch(filePath);
|
||||
|
||||
if (!response.ok) throw new Error(`Failed to load file: ${response.status}`);
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error loading file:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
class RandomPixelPlaceholder {
|
||||
constructor(parent, options = {}) {
|
||||
this.container = parent;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue